Merge branch 'main' into bugfix/addressing-#2276

This commit is contained in:
Paulo Graça
2023-06-09 11:02:26 +01:00
committed by GitHub
8 changed files with 74 additions and 37 deletions

2
.gitignore vendored
View File

@@ -39,3 +39,5 @@ package-lock.json
/nbproject/
junit.xml
/src/mirador-viewer/config.local.js

View File

@@ -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(() => {
this.epersonService.cancelEditEPerson();
this.isEPersonFormShown = false;
});
take(1),
switchMap((href: string) => {
return this.requestService.setStaleByHrefSubstring(href).pipe(
take(1),
);
})
).subscribe(()=>{
this.epersonService.cancelEditEPerson();
this.isEPersonFormShown = false;
});
}
}

View File

@@ -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,31 +463,42 @@ 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) => {
const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = eperson;
modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-eperson.header';
modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-eperson.info';
modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-eperson.cancel';
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();
} else {
this.notificationsService.error('Error occured when trying to delete EPerson with id: ' + eperson.id + ' with code: ' + restResponse.statusCode + ' and message: ' + restResponse.errorMessage);
}
this.cancelForm.emit();
});
}
}
});
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';
modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-eperson.info';
modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-eperson.cancel';
modalRef.componentInstance.confirmLabel = 'confirmation-modal.delete-eperson.confirm';
modalRef.componentInstance.brandColor = 'danger';
modalRef.componentInstance.confirmIcon = 'fas fa-trash';
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 {
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();
});
}
@@ -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)) {

View File

@@ -6,5 +6,9 @@
(deselect)="onDeselect($event)">
</ds-vocabulary-treeview>
</div>
<a class="btn btn-primary" [routerLink]="['/search']" [queryParams]="queryParams">{{ 'browse.taxonomy.button' | translate }}</a>
<a class="btn btn-primary"
[routerLink]="['/search']"
[queryParams]="queryParams"
[queryParamsHandling]="'merge'">
{{ 'browse.taxonomy.button' | translate }}</a>
</div>

View File

@@ -331,7 +331,7 @@ export class RequestService {
map((request: RequestEntry) => isStale(request.state)),
filter((stale: boolean) => stale),
take(1),
);
);
}
/**

View File

@@ -775,6 +775,8 @@
"browse.comcol.by.subject": "By Subject",
"browse.comcol.by.srsc": "By Subject Category",
"browse.comcol.by.title": "By Title",
"browse.comcol.head": "Browse",

View File

@@ -1,4 +1,17 @@
import Mirador from 'mirador/dist/es/src/index';
// You can modify this default Mirador configuration file. However,
// you should consider creating a copy of this file named
// 'config.local.js'. If that file exists it will be used to build
// your local Mirador instance. This allows you to keep local
// Mirador configuration separate from this default distribution
// copy.
// For an example of all Mirador configuration options, see
// https://github.com/ProjectMirador/mirador/blob/master/src/config/settings.js
// You can add or remove plugins. When adding new plugins be sure to also
// import them into the project via your package.json dependencies.
import miradorShareDialogPlugin from 'mirador-share-plugin/es/MiradorShareDialog';
import miradorSharePlugin from 'mirador-share-plugin/es/miradorSharePlugin';
import miradorDownloadPlugin from 'mirador-dl-plugin/es/miradorDownloadPlugin';

View File

@@ -1,10 +1,13 @@
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
// @ts-ignore
const fs = require('fs');
module.exports = {
mode: 'production',
entry: {
mirador: './src/mirador-viewer/index.js'
mirador: fs.existsSync('./src/mirador-viewer/config.local.js')? './src/mirador-viewer/config.local.js' :
'./src/mirador-viewer/config.default.js'
},
output: {
path: path.resolve(__dirname, '..' , 'dist/iiif/mirador'),