mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge branch 'main' of https://bitbucket.org/4Science/dspace-angular into DURACOM-152
This commit is contained in:
@@ -287,14 +287,17 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* This method will set everything to stale, which will cause the lists on this page to update.
|
||||
*/
|
||||
reset() {
|
||||
reset(): void {
|
||||
this.epersonService.getBrowseEndpoint().pipe(
|
||||
take(1)
|
||||
).subscribe((href: string) => {
|
||||
this.requestService.setStaleByHrefSubstring(href).pipe(take(1)).subscribe(() => {
|
||||
take(1),
|
||||
switchMap((href: string) => {
|
||||
return this.requestService.setStaleByHrefSubstring(href).pipe(
|
||||
take(1),
|
||||
);
|
||||
})
|
||||
).subscribe(()=>{
|
||||
this.epersonService.cancelEditEPerson();
|
||||
this.isEPersonFormShown = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
} from '@ng-dynamic-forms/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf, Subscription } from 'rxjs';
|
||||
import { debounceTime, switchMap, take } from 'rxjs/operators';
|
||||
import { debounceTime, finalize, map, switchMap, take } from 'rxjs/operators';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
|
||||
@@ -463,8 +463,10 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
||||
* Deletes the EPerson from the Repository. The EPerson will be the only that this form is showing.
|
||||
* It'll either show a success or error message depending on whether the delete was successful or not.
|
||||
*/
|
||||
delete() {
|
||||
this.epersonService.getActiveEPerson().pipe(take(1)).subscribe((eperson: EPerson) => {
|
||||
delete(): void {
|
||||
this.epersonService.getActiveEPerson().pipe(
|
||||
take(1),
|
||||
switchMap((eperson: EPerson) => {
|
||||
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
||||
modalRef.componentInstance.dso = eperson;
|
||||
modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-eperson.header';
|
||||
@@ -473,23 +475,32 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
||||
modalRef.componentInstance.confirmLabel = 'confirmation-modal.delete-eperson.confirm';
|
||||
modalRef.componentInstance.brandColor = 'danger';
|
||||
modalRef.componentInstance.confirmIcon = 'fas fa-trash';
|
||||
modalRef.componentInstance.response.pipe(take(1)).subscribe((confirm: boolean) => {
|
||||
if (confirm) {
|
||||
if (hasValue(eperson.id)) {
|
||||
this.epersonService.deleteEPerson(eperson).pipe(getFirstCompletedRemoteData()).subscribe((restResponse: RemoteData<NoContent>) => {
|
||||
if (restResponse.hasSucceeded) {
|
||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', { name: this.dsoNameService.getName(eperson) }));
|
||||
this.submitForm.emit();
|
||||
|
||||
return modalRef.componentInstance.response.pipe(
|
||||
take(1),
|
||||
switchMap((confirm: boolean) => {
|
||||
if (confirm && hasValue(eperson.id)) {
|
||||
this.canDelete$ = observableOf(false);
|
||||
return this.epersonService.deleteEPerson(eperson).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((restResponse: RemoteData<NoContent>) => ({ restResponse, eperson }))
|
||||
);
|
||||
} else {
|
||||
this.notificationsService.error('Error occured when trying to delete EPerson with id: ' + eperson.id + ' with code: ' + restResponse.statusCode + ' and message: ' + restResponse.errorMessage);
|
||||
return observableOf(null);
|
||||
}
|
||||
}),
|
||||
finalize(() => this.canDelete$ = observableOf(true))
|
||||
);
|
||||
})
|
||||
).subscribe(({ restResponse, eperson }: { restResponse: RemoteData<NoContent> | null, eperson: EPerson }) => {
|
||||
if (restResponse?.hasSucceeded) {
|
||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', { name: this.dsoNameService.getName(eperson) }));
|
||||
} else {
|
||||
this.notificationsService.error(`Error occurred when trying to delete EPerson with id: ${eperson?.id} with code: ${restResponse?.statusCode} and message: ${restResponse?.errorMessage}`);
|
||||
}
|
||||
this.cancelForm.emit();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop impersonating the EPerson
|
||||
@@ -523,7 +534,6 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
||||
* Cancel the current edit when component is destroyed & unsub all subscriptions
|
||||
*/
|
||||
ngOnDestroy(): void {
|
||||
this.onCancel();
|
||||
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
|
||||
this.paginationService.clearPagination(this.config.id);
|
||||
if (hasValue(this.emailValueChangeSubscribe)) {
|
||||
|
Reference in New Issue
Block a user