feat: implement confirm dialog for project deletion and item removal in dynamic forms; enhance form field accessibility

This commit is contained in:
2026-02-15 05:47:32 +05:30
parent 58929ae6d4
commit 1806c6fb1f
7 changed files with 211 additions and 16 deletions
+25 -11
View File
@@ -5,6 +5,7 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { DynamicPopupComponent } from '../../shared/dynamic-popup/dynamic-popup';
import { DynamicFormConfig } from '../../shared/dynamic-form/dynamic-form-config';
import { ProjectDetailPopupComponent } from './project-detail-popup/project-detail-popup';
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog';
import { AdminQuery } from '../state/admin.query';
import { AdminStateService } from '../state/admin-state.service';
import { AdminService } from '../services/admin.service';
@@ -185,20 +186,33 @@ export class Projects implements OnInit, OnDestroy {
}
deleteProject(project: IProject): void {
if (!confirm(`Are you sure you want to delete "${project.name}"?`)) return;
const ref = this.dialog.open(ConfirmDialogComponent, {
data: {
title: 'Delete Project',
message: `Are you sure you want to delete "${project.name}"? This action cannot be undone.`
},
panelClass: 'dark-popup-panel',
width: '420px'
});
this.adminService.deleteProject(project.projectId)
ref.afterClosed()
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
const allProjects = this.adminQuery.getProjects();
const updatedList = (allProjects?.projects ?? []).filter(p => p.projectId !== project.projectId);
const categories = [...new Set(updatedList.flatMap(p => p.categories ?? []))];
.subscribe((confirmed: boolean) => {
if (!confirmed) return;
this.adminState.updateProjects({
projects: updatedList,
projectsCategories: categories.length ? categories : []
});
this.filter = 'All';
this.adminService.deleteProject(project.projectId)
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
const allProjects = this.adminQuery.getProjects();
const updatedList = (allProjects?.projects ?? []).filter(p => p.projectId !== project.projectId);
const categories = [...new Set(updatedList.flatMap(p => p.categories ?? []))];
this.adminState.updateProjects({
projects: updatedList,
projectsCategories: categories.length ? categories : []
});
this.filter = 'All';
});
});
}