check whether the contact is assigned when deleting
This commit is contained in:
parent
7b231589fa
commit
211b68b41c
2 changed files with 21 additions and 3 deletions
|
|
@ -12,7 +12,7 @@ import { FirebaseService } from '../../../services/firebase.service';
|
|||
styleUrl: './contact-delete.component.scss',
|
||||
})
|
||||
export class ContactDeleteComponent {
|
||||
@Input() currentUserId!: string;
|
||||
@Input() currentUserId: string = '';
|
||||
|
||||
constructor(
|
||||
private sharedService: SharedService,
|
||||
|
|
@ -25,6 +25,22 @@ export class ContactDeleteComponent {
|
|||
this.router.navigate(['contacts']);
|
||||
this.sharedService.isDeleteContactDialogOpen = false;
|
||||
this.sharedService.isAnyDialogOpen = false;
|
||||
this.checkIfContactAnAssigned();
|
||||
}
|
||||
|
||||
checkIfContactAnAssigned() {
|
||||
const tasks = this.firebaseService.getAllTasks();
|
||||
|
||||
tasks.forEach((task) => {
|
||||
const index = task.assigned.indexOf(this.currentUserId);
|
||||
if (index !== -1) {
|
||||
task.assigned.splice(index, 1);
|
||||
const { id, ...taskWithoutIds } = task;
|
||||
if (task.id) {
|
||||
this.firebaseService.replaceTaskData(task.id, taskWithoutIds);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteCancle() {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
<p> (du)</p>
|
||||
}
|
||||
</div>
|
||||
@if(user.uId === "") {
|
||||
<div class="btns">
|
||||
<div class="btn btn-edit">
|
||||
<img src="./../../../../assets/img/contact/edit.svg" alt="" />
|
||||
|
|
@ -62,6 +63,7 @@
|
|||
<div class="btn-mobile" (click)="toggleNav()">
|
||||
<img src="./../../../assets/img/contact/points.svg" alt="check" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="contact word-wrap">
|
||||
|
|
@ -77,13 +79,13 @@
|
|||
<a [href]="'tel:' + user.phone">
|
||||
<span>{{ user.phone }}</span>
|
||||
</a>
|
||||
}
|
||||
} @if(user.uId !== "") {
|
||||
<p>{{ "contacts.contactLastOnline" | translate }}</p>
|
||||
@if(user.status) {
|
||||
<span>{{ "contacts.contactLastOnlineTxt" | translate }}</span>
|
||||
} @else {
|
||||
<span>{{ convertTimestamp(user.lastLogin) }}</span>
|
||||
}
|
||||
} }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue