mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 03:53:02 +00:00
fix: confirm dialog for group deletion
Introduced a confirmation modal before deleting groups in both the Group Registry and Comcol Role components. This ensures users explicitly confirm deletion, reducing accidental data loss. Updated relevant tests and added new translations for modal text.
(cherry picked from commit 57bf254bec
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
3acdb3124e
commit
29e8c29ade
@@ -9,7 +9,10 @@ import {
|
||||
UntypedFormBuilder,
|
||||
} from '@angular/forms';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
NgbModal,
|
||||
NgbTooltipModule,
|
||||
} from '@ng-bootstrap/ng-bootstrap';
|
||||
import {
|
||||
TranslateModule,
|
||||
TranslateService,
|
||||
@@ -27,6 +30,7 @@ import {
|
||||
defaultIfEmpty,
|
||||
map,
|
||||
switchMap,
|
||||
takeUntil,
|
||||
tap,
|
||||
} from 'rxjs/operators';
|
||||
|
||||
@@ -57,6 +61,7 @@ import {
|
||||
} from '../../core/shared/operators';
|
||||
import { PageInfo } from '../../core/shared/page-info.model';
|
||||
import { BtnDisabledDirective } from '../../shared/btn-disabled.directive';
|
||||
import { ConfirmationModalComponent } from '../../shared/confirmation-modal/confirmation-modal.component';
|
||||
import { hasValue } from '../../shared/empty.util';
|
||||
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
@@ -142,6 +147,7 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
||||
private paginationService: PaginationService,
|
||||
public requestService: RequestService,
|
||||
public dsoNameService: DSONameService,
|
||||
private modalService: NgbModal,
|
||||
) {
|
||||
this.currentSearchQuery = '';
|
||||
this.searchForm = this.formBuilder.group(({
|
||||
@@ -314,4 +320,30 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
||||
this.paginationService.clearPagination(this.config.id);
|
||||
}
|
||||
|
||||
confirmDelete(group: GroupDtoModel): void {
|
||||
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
||||
modalRef.componentInstance.name = this.dsoNameService.getName(group.group);
|
||||
modalRef.componentInstance.headerLabel = 'admin.access-control.epeople.table.edit.buttons.remove.modal.header';
|
||||
modalRef.componentInstance.infoLabel = 'admin.access-control.epeople.table.edit.buttons.remove.modal.info';
|
||||
modalRef.componentInstance.cancelLabel = 'admin.access-control.epeople.table.edit.buttons.remove.modal.cancel';
|
||||
modalRef.componentInstance.confirmLabel = 'admin.access-control.epeople.table.edit.buttons.remove.modal.confirm';
|
||||
modalRef.componentInstance.brandColor = 'danger';
|
||||
modalRef.componentInstance.confirmIcon = 'fas fa-trash';
|
||||
|
||||
const modalSub: Subscription = modalRef.componentInstance.response.pipe(
|
||||
takeUntil(modalRef.closed),
|
||||
).subscribe((result: boolean) => {
|
||||
if (result === true) {
|
||||
this.deleteGroup(group);
|
||||
}
|
||||
});
|
||||
|
||||
void modalRef.result.then().finally(() => {
|
||||
modalRef.close();
|
||||
if (modalSub && !modalSub.closed) {
|
||||
modalSub.unsubscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user