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.
|
* This method will set everything to stale, which will cause the lists on this page to update.
|
||||||
*/
|
*/
|
||||||
reset() {
|
reset(): void {
|
||||||
this.epersonService.getBrowseEndpoint().pipe(
|
this.epersonService.getBrowseEndpoint().pipe(
|
||||||
take(1)
|
take(1),
|
||||||
).subscribe((href: string) => {
|
switchMap((href: string) => {
|
||||||
this.requestService.setStaleByHrefSubstring(href).pipe(take(1)).subscribe(() => {
|
return this.requestService.setStaleByHrefSubstring(href).pipe(
|
||||||
|
take(1),
|
||||||
|
);
|
||||||
|
})
|
||||||
|
).subscribe(()=>{
|
||||||
this.epersonService.cancelEditEPerson();
|
this.epersonService.cancelEditEPerson();
|
||||||
this.isEPersonFormShown = false;
|
this.isEPersonFormShown = false;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@ import {
|
|||||||
} from '@ng-dynamic-forms/core';
|
} from '@ng-dynamic-forms/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf, Subscription } from 'rxjs';
|
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 { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
|
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.
|
* 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.
|
* It'll either show a success or error message depending on whether the delete was successful or not.
|
||||||
*/
|
*/
|
||||||
delete() {
|
delete(): void {
|
||||||
this.epersonService.getActiveEPerson().pipe(take(1)).subscribe((eperson: EPerson) => {
|
this.epersonService.getActiveEPerson().pipe(
|
||||||
|
take(1),
|
||||||
|
switchMap((eperson: EPerson) => {
|
||||||
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
||||||
modalRef.componentInstance.dso = eperson;
|
modalRef.componentInstance.dso = eperson;
|
||||||
modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-eperson.header';
|
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.confirmLabel = 'confirmation-modal.delete-eperson.confirm';
|
||||||
modalRef.componentInstance.brandColor = 'danger';
|
modalRef.componentInstance.brandColor = 'danger';
|
||||||
modalRef.componentInstance.confirmIcon = 'fas fa-trash';
|
modalRef.componentInstance.confirmIcon = 'fas fa-trash';
|
||||||
modalRef.componentInstance.response.pipe(take(1)).subscribe((confirm: boolean) => {
|
|
||||||
if (confirm) {
|
return modalRef.componentInstance.response.pipe(
|
||||||
if (hasValue(eperson.id)) {
|
take(1),
|
||||||
this.epersonService.deleteEPerson(eperson).pipe(getFirstCompletedRemoteData()).subscribe((restResponse: RemoteData<NoContent>) => {
|
switchMap((confirm: boolean) => {
|
||||||
if (restResponse.hasSucceeded) {
|
if (confirm && hasValue(eperson.id)) {
|
||||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', { name: this.dsoNameService.getName(eperson) }));
|
this.canDelete$ = observableOf(false);
|
||||||
this.submitForm.emit();
|
return this.epersonService.deleteEPerson(eperson).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
map((restResponse: RemoteData<NoContent>) => ({ restResponse, eperson }))
|
||||||
|
);
|
||||||
} else {
|
} 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();
|
this.cancelForm.emit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop impersonating the EPerson
|
* 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
|
* Cancel the current edit when component is destroyed & unsub all subscriptions
|
||||||
*/
|
*/
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.onCancel();
|
|
||||||
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
|
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
|
||||||
this.paginationService.clearPagination(this.config.id);
|
this.paginationService.clearPagination(this.config.id);
|
||||||
if (hasValue(this.emailValueChangeSubscribe)) {
|
if (hasValue(this.emailValueChangeSubscribe)) {
|
||||||
|
Reference in New Issue
Block a user