mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-5307] add confirmation modal when deleting the profile
This commit is contained in:
@@ -156,9 +156,15 @@ describe('ProfilePageResearcherFormComponent', () => {
|
||||
});
|
||||
|
||||
describe('deleteProfile', () => {
|
||||
beforeEach(() => {
|
||||
const modalService = (component as any).modalService;
|
||||
spyOn(modalService, 'open').and.returnValue(Object.assign({ componentInstance: Object.assign({ response: observableOf(true) }) }));
|
||||
component.deleteProfile(profile);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should delete the profile', () => {
|
||||
component.deleteProfile(profile);
|
||||
|
||||
expect(researcherProfileService.delete).toHaveBeenCalledWith(profile);
|
||||
});
|
||||
|
||||
|
@@ -17,6 +17,7 @@ import { ProfileClaimService } from '../profile-claim/profile-claim.service';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { isNotEmpty } from '../../shared/empty.util';
|
||||
import { followLink } from '../../shared/utils/follow-link-config.model';
|
||||
import { ConfirmationModalComponent } from '../../shared/confirmation-modal/confirmation-modal.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-profile-page-researcher-form',
|
||||
@@ -113,15 +114,26 @@ export class ProfilePageResearcherFormComponent implements OnInit {
|
||||
* @param researcherProfile the profile to delete
|
||||
*/
|
||||
deleteProfile(researcherProfile: ResearcherProfile): void {
|
||||
this.processingDelete$.next(true);
|
||||
this.researcherProfileService.delete(researcherProfile)
|
||||
.subscribe((deleted) => {
|
||||
if (deleted) {
|
||||
this.researcherProfile$.next(null);
|
||||
this.researcherProfileItemId = null;
|
||||
}
|
||||
this.processingDelete$.next(false);
|
||||
});
|
||||
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
||||
modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-profile.header';
|
||||
modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-profile.info';
|
||||
modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-profile.cancel';
|
||||
modalRef.componentInstance.confirmLabel = 'confirmation-modal.delete-profile.confirm';
|
||||
modalRef.componentInstance.brandColor = 'danger';
|
||||
modalRef.componentInstance.confirmIcon = 'fas fa-trash';
|
||||
modalRef.componentInstance.response.pipe(take(1)).subscribe((confirm: boolean) => {
|
||||
if (confirm) {
|
||||
this.processingDelete$.next(true);
|
||||
this.researcherProfileService.delete(researcherProfile)
|
||||
.subscribe((deleted) => {
|
||||
if (deleted) {
|
||||
this.researcherProfile$.next(null);
|
||||
this.researcherProfileItemId = null;
|
||||
}
|
||||
this.processingDelete$.next(false);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1361,6 +1361,14 @@
|
||||
|
||||
"confirmation-modal.delete-eperson.confirm": "Delete",
|
||||
|
||||
"confirmation-modal.delete-profile.header": "Delete Profile",
|
||||
|
||||
"confirmation-modal.delete-profile.info": "Are you sure you want to delete your profile",
|
||||
|
||||
"confirmation-modal.delete-profile.cancel": "Cancel",
|
||||
|
||||
"confirmation-modal.delete-profile.confirm": "Delete",
|
||||
|
||||
|
||||
"error.bitstream": "Error fetching bitstream",
|
||||
|
||||
@@ -3666,7 +3674,7 @@
|
||||
"submission.import-external.preview.title.OrgUnit": "Organizational Unit Preview",
|
||||
|
||||
"submission.import-external.preview.title.Person": "Person Preview",
|
||||
|
||||
|
||||
"submission.import-external.preview.title.Project": "Project Preview",
|
||||
|
||||
"submission.import-external.preview.subtitle": "The metadata below was imported from an external source. It will be pre-filled when you start the submission.",
|
||||
|
Reference in New Issue
Block a user