add confirmation and icon red for delete

This commit is contained in:
2025-10-27 16:32:40 +11:00
parent cbb61b796f
commit 0282169320
2 changed files with 25 additions and 3 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
<td >{{item.photo}}</td> <td >{{item.photo}}</td>
<td> <td>
<button pButton type="button" icon="pi pi-times" class="p-button-rounded p-button-text p-button-raised" <button pButton type="button" icon="pi pi-times" class="p-button-rounded text-red-500 p-button-text p-button-raised mr-2"
(click)="remove(item.id)"></button> (click)="remove(item.id)"></button>
@if (item.id > 0) { @if (item.id > 0) {
+24 -2
View File
@@ -3,7 +3,7 @@ import { Component, OnInit, OnDestroy, inject, ChangeDetectorRef, signal, output
import { catchError, EMPTY, finalize, Subscription } from 'rxjs'; import { catchError, EMPTY, finalize, Subscription } from 'rxjs';
import { CommonUtilities, HttpUtility, LookupService } from '../shares'; import { CommonUtilities, HttpUtility, LookupService } from '../shares';
import { DialogService ,DynamicDialogConfig,DynamicDialogModule, DynamicDialogRef} from 'primeng/dynamicdialog'; import { DialogService ,DynamicDialogConfig,DynamicDialogModule, DynamicDialogRef} from 'primeng/dynamicdialog';
import { MessageService } from 'primeng/api'; import { ConfirmationService, MessageService } from 'primeng/api';
import { AddPhoto } from './add.photo'; import { AddPhoto } from './add.photo';
import { LookupEdit, PersonPhotoDto } from '../models'; import { LookupEdit, PersonPhotoDto } from '../models';
@@ -30,6 +30,7 @@ export class PhotoList implements OnInit, OnDestroy {
deletePersonPhoto: number[] = []; deletePersonPhoto: number[] = [];
private authenticationService = inject(AuthenticationService); private authenticationService = inject(AuthenticationService);
private cdr = inject(ChangeDetectorRef); private cdr = inject(ChangeDetectorRef);
private confirmationService = inject(ConfirmationService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private subscription: Subscription = new Subscription(); private subscription: Subscription = new Subscription();
downloadFile = signal(false); downloadFile = signal(false);
@@ -95,8 +96,29 @@ onClose(event: Event): void {
newSupportDoc(event: Event): void { newSupportDoc(event: Event): void {
this.showEdit(this._id--); this.showEdit(this._id--);
} }
remove(id: number): void { remove(id: number): void {
this.confirmationService.confirm({
message: 'Do you want to delete this record?',
header: 'Confirmation Delete',
icon: 'pi pi-info-circle',
rejectLabel: 'Cancel',
rejectButtonProps: {
label: 'Cancel',
severity: 'secondary',
outlined: true,
},
acceptButtonProps: {
label: 'Delete',
severity: 'danger',
},
accept: () => {
this.doRemove(id);
}
});
}
doRemove(id: number): void {
if (id < 0) if (id < 0)
{ {
const nlist = this.FileList.filter(x => x.id != id); const nlist = this.FileList.filter(x => x.id != id);