diff --git a/.gitignore b/.gitignore index bdd0d4e589..7d065aca06 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,5 @@ package-lock.json /nbproject/ junit.xml + +/src/mirador-viewer/config.local.js diff --git a/src/app/access-control/epeople-registry/epeople-registry.component.ts b/src/app/access-control/epeople-registry/epeople-registry.component.ts index 706dcab690..fb045ebb88 100644 --- a/src/app/access-control/epeople-registry/epeople-registry.component.ts +++ b/src/app/access-control/epeople-registry/epeople-registry.component.ts @@ -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; }); } } diff --git a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts index c60de00aed..d009d56058 100644 --- a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts +++ b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts @@ -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) => { - 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) => ({ restResponse, eperson })) + ); + } else { + return observableOf(null); + } + }), + finalize(() => this.canDelete$ = observableOf(true)) + ); + }) + ).subscribe(({ restResponse, eperson }: { restResponse: RemoteData | 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)) { diff --git a/src/app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component.html b/src/app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component.html index 87c7937b1b..0ae3da6847 100644 --- a/src/app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component.html +++ b/src/app/browse-by/browse-by-taxonomy-page/browse-by-taxonomy-page.component.html @@ -6,5 +6,9 @@ (deselect)="onDeselect($event)"> - {{ 'browse.taxonomy.button' | translate }} + + {{ 'browse.taxonomy.button' | translate }} diff --git a/src/app/core/data/request.service.ts b/src/app/core/data/request.service.ts index 94a6020975..1f6680203e 100644 --- a/src/app/core/data/request.service.ts +++ b/src/app/core/data/request.service.ts @@ -331,7 +331,7 @@ export class RequestService { map((request: RequestEntry) => isStale(request.state)), filter((stale: boolean) => stale), take(1), - ); + ); } /** diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index d0a723ae12..ac0da7e15d 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -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", diff --git a/src/mirador-viewer/index.js b/src/mirador-viewer/config.default.js similarity index 88% rename from src/mirador-viewer/index.js rename to src/mirador-viewer/config.default.js index 6cc4303f1f..71df8adcc3 100644 --- a/src/mirador-viewer/index.js +++ b/src/mirador-viewer/config.default.js @@ -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'; diff --git a/webpack/webpack.mirador.config.ts b/webpack/webpack.mirador.config.ts index c0083ded6e..7699cf1bdc 100644 --- a/webpack/webpack.mirador.config.ts +++ b/webpack/webpack.mirador.config.ts @@ -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'),