mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 05:53:03 +00:00
[CST-5307] add confirmation modal when deleting the profile
This commit is contained in:
@@ -156,9 +156,15 @@ describe('ProfilePageResearcherFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteProfile', () => {
|
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', () => {
|
it('should delete the profile', () => {
|
||||||
component.deleteProfile(profile);
|
|
||||||
expect(researcherProfileService.delete).toHaveBeenCalledWith(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 { RemoteData } from '../../core/data/remote-data';
|
||||||
import { isNotEmpty } from '../../shared/empty.util';
|
import { isNotEmpty } from '../../shared/empty.util';
|
||||||
import { followLink } from '../../shared/utils/follow-link-config.model';
|
import { followLink } from '../../shared/utils/follow-link-config.model';
|
||||||
|
import { ConfirmationModalComponent } from '../../shared/confirmation-modal/confirmation-modal.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-profile-page-researcher-form',
|
selector: 'ds-profile-page-researcher-form',
|
||||||
@@ -113,6 +114,15 @@ export class ProfilePageResearcherFormComponent implements OnInit {
|
|||||||
* @param researcherProfile the profile to delete
|
* @param researcherProfile the profile to delete
|
||||||
*/
|
*/
|
||||||
deleteProfile(researcherProfile: ResearcherProfile): void {
|
deleteProfile(researcherProfile: ResearcherProfile): void {
|
||||||
|
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.processingDelete$.next(true);
|
||||||
this.researcherProfileService.delete(researcherProfile)
|
this.researcherProfileService.delete(researcherProfile)
|
||||||
.subscribe((deleted) => {
|
.subscribe((deleted) => {
|
||||||
@@ -123,6 +133,8 @@ export class ProfilePageResearcherFormComponent implements OnInit {
|
|||||||
this.processingDelete$.next(false);
|
this.processingDelete$.next(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the visibility of the given researcher profile.
|
* Toggle the visibility of the given researcher profile.
|
||||||
|
@@ -1361,6 +1361,14 @@
|
|||||||
|
|
||||||
"confirmation-modal.delete-eperson.confirm": "Delete",
|
"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",
|
"error.bitstream": "Error fetching bitstream",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user