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',
|
styleUrl: './contact-delete.component.scss',
|
||||||
})
|
})
|
||||||
export class ContactDeleteComponent {
|
export class ContactDeleteComponent {
|
||||||
@Input() currentUserId!: string;
|
@Input() currentUserId: string = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private sharedService: SharedService,
|
private sharedService: SharedService,
|
||||||
|
|
@ -25,6 +25,22 @@ export class ContactDeleteComponent {
|
||||||
this.router.navigate(['contacts']);
|
this.router.navigate(['contacts']);
|
||||||
this.sharedService.isDeleteContactDialogOpen = false;
|
this.sharedService.isDeleteContactDialogOpen = false;
|
||||||
this.sharedService.isAnyDialogOpen = 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() {
|
deleteCancle() {
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@
|
||||||
<p> (du)</p>
|
<p> (du)</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@if(user.uId === "") {
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
<div class="btn btn-edit">
|
<div class="btn btn-edit">
|
||||||
<img src="./../../../../assets/img/contact/edit.svg" alt="" />
|
<img src="./../../../../assets/img/contact/edit.svg" alt="" />
|
||||||
|
|
@ -62,6 +63,7 @@
|
||||||
<div class="btn-mobile" (click)="toggleNav()">
|
<div class="btn-mobile" (click)="toggleNav()">
|
||||||
<img src="./../../../assets/img/contact/points.svg" alt="check" />
|
<img src="./../../../assets/img/contact/points.svg" alt="check" />
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="contact word-wrap">
|
<div class="contact word-wrap">
|
||||||
|
|
@ -77,13 +79,13 @@
|
||||||
<a [href]="'tel:' + user.phone">
|
<a [href]="'tel:' + user.phone">
|
||||||
<span>{{ user.phone }}</span>
|
<span>{{ user.phone }}</span>
|
||||||
</a>
|
</a>
|
||||||
}
|
} @if(user.uId !== "") {
|
||||||
<p>{{ "contacts.contactLastOnline" | translate }}</p>
|
<p>{{ "contacts.contactLastOnline" | translate }}</p>
|
||||||
@if(user.status) {
|
@if(user.status) {
|
||||||
<span>{{ "contacts.contactLastOnlineTxt" | translate }}</span>
|
<span>{{ "contacts.contactLastOnlineTxt" | translate }}</span>
|
||||||
} @else {
|
} @else {
|
||||||
<span>{{ convertTimestamp(user.lastLogin) }}</span>
|
<span>{{ convertTimestamp(user.lastLogin) }}</span>
|
||||||
}
|
} }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue