From 27180c5960ac4e4f163899f38c0471b1a5bf8244 Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 1 Mar 2019 09:31:03 +0100 Subject: [PATCH] Applied feedback --- config/environment.default.js | 7 ++++++- .../edit-in-place-field.component.html | 1 - .../item-metadata/item-metadata.component.spec.ts | 2 +- .../item-metadata/item-metadata.component.ts | 12 +++++++----- src/app/core/registry/registry.service.ts | 15 ++++++++++++--- src/app/shared/utils/auto-focus.directive.ts | 9 ++++++++- src/config/global-config.interface.ts | 2 ++ src/config/item-page-config.interface.ts | 7 +++++++ 8 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 src/config/item-page-config.interface.ts diff --git a/config/environment.default.js b/config/environment.default.js index d46dc10dee..b8eae1ccff 100644 --- a/config/environment.default.js +++ b/config/environment.default.js @@ -79,5 +79,10 @@ module.exports = { code: 'nl', label: 'Nederlands', active: false, - }] + }], + item: { + edit: { + undoTimeout: 10000 // 10 seconds + } + } }; diff --git a/src/app/+item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.html b/src/app/+item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.html index 05eb03dd12..e9c5de95ca 100644 --- a/src/app/+item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.html +++ b/src/app/+item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.html @@ -1,4 +1,3 @@ -
diff --git a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts index 674e41e13f..f2cd74fc2f 100644 --- a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.spec.ts @@ -158,7 +158,7 @@ describe('ItemMetadataComponent', () => { { provide: Router, useValue: router }, { provide: ActivatedRoute, useValue: routeStub }, { provide: NotificationsService, useValue: notificationsService }, - { provide: GLOBAL_CONFIG, useValue: { notifications: { timeOut: 10 } } as any }, + { provide: GLOBAL_CONFIG, useValue: { item: { edit: { undoTimeout: 10 } } } as any }, { provide: RegistryService, useValue: metadataFieldService }, ], schemas: [ NO_ERRORS_SCHEMA diff --git a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts index 1d5c1064ba..6b3e05c818 100644 --- a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts +++ b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts @@ -47,8 +47,10 @@ export class ItemMetadataComponent implements OnInit { * The time span for being able to undo discarding changes */ private discardTimeOut: number; - - private notitifactionPrefix = 'item.edit.metadata.notifications.'; + /** + * Prefix for this component's notification translate keys + */ + private notificationsPrefix = 'item.edit.metadata.notifications.'; /** * Observable with a list of strings with all existing metadata field keys @@ -81,7 +83,7 @@ export class ItemMetadataComponent implements OnInit { this.item = item; }); - this.discardTimeOut = this.EnvConfig.notifications.timeOut; + this.discardTimeOut = this.EnvConfig.item.edit.undoTimeout; this.url = this.router.url; if (this.url.indexOf('?') > 0) { this.url = this.url.substr(0, this.url.indexOf('?')); @@ -207,7 +209,7 @@ export class ItemMetadataComponent implements OnInit { * @param key */ private getNotificationTitle(key: string) { - return this.translateService.instant(this.notitifactionPrefix + key + '.title'); + return this.translateService.instant(this.notificationsPrefix + key + '.title'); } /** @@ -215,7 +217,7 @@ export class ItemMetadataComponent implements OnInit { * @param key */ private getNotificationContent(key: string) { - return this.translateService.instant(this.notitifactionPrefix + key + '.content'); + return this.translateService.instant(this.notificationsPrefix + key + '.content'); } diff --git a/src/app/core/registry/registry.service.ts b/src/app/core/registry/registry.service.ts index dbc60eeec0..87410394a0 100644 --- a/src/app/core/registry/registry.service.ts +++ b/src/app/core/registry/registry.service.ts @@ -173,6 +173,12 @@ export class RegistryService { return this.rdb.toRemoteDataObservable(requestEntryObs, payloadObs); } + /** + * Retrieve all existing metadata fields as a paginated list + * @param pagination Pagination options to determine which page of metadata fields should be requested + * When no pagination is provided, all metadata fields are requested in one large page + * @returns an observable that emits a remote data object with a page of metadata fields + */ public getAllMetadataFields(pagination?: PaginationComponentOptions): Observable>> { if (hasNoValue(pagination)) { pagination = { currentPage: 1, pageSize: 10000 } as any; @@ -557,10 +563,13 @@ export class RegistryService { }); } + /** + * Retrieve a filtered paginated list of metadata fields + * @param query {string} The query to filter the field names by + * @returns an observable that emits a remote data object with a page of metadata fields that match the query + */ queryMetadataFields(query: string): Observable>> { - /** - * This should come directly from the server in the future - */ + /* TODO This should come directly from the server in the future */ return this.getAllMetadataFields().pipe( map((rd: RemoteData>) => { const filteredFields: MetadataField[] = rd.payload.page.filter( diff --git a/src/app/shared/utils/auto-focus.directive.ts b/src/app/shared/utils/auto-focus.directive.ts index b009754412..a2d860a8e1 100644 --- a/src/app/shared/utils/auto-focus.directive.ts +++ b/src/app/shared/utils/auto-focus.directive.ts @@ -1,12 +1,19 @@ import { Directive, AfterViewInit, ElementRef, Input } from '@angular/core'; import { isNotEmpty } from '../empty.util'; +/** + * Directive to set focus on an element when it is rendered + */ @Directive({ selector: '[dsAutoFocus]' }) export class AutoFocusDirective implements AfterViewInit { - @Input() autoFocusSelector: string; + /** + * Optional input to specify which element in a component should get the focus + * If left empty, the component itself will get the focus + */ + @Input() autoFocusSelector: string = undefined; constructor(private el: ElementRef) { } diff --git a/src/config/global-config.interface.ts b/src/config/global-config.interface.ts index 6d1d4da6f9..59cc21a3b2 100644 --- a/src/config/global-config.interface.ts +++ b/src/config/global-config.interface.ts @@ -5,6 +5,7 @@ import { UniversalConfig } from './universal-config.interface'; import { INotificationBoardOptions } from './notifications-config.interfaces'; import { FormConfig } from './form-config.interfaces'; import {LangConfig} from './lang-config.interface'; +import { ItemPageConfig } from './item-page-config.interface'; export interface GlobalConfig extends Config { ui: ServerConfig; @@ -19,4 +20,5 @@ export interface GlobalConfig extends Config { debug: boolean; defaultLanguage: string; languages: LangConfig[]; + item: ItemPageConfig; } diff --git a/src/config/item-page-config.interface.ts b/src/config/item-page-config.interface.ts new file mode 100644 index 0000000000..c76d2cdb01 --- /dev/null +++ b/src/config/item-page-config.interface.ts @@ -0,0 +1,7 @@ +import { Config } from './config.interface'; + +export interface ItemPageConfig extends Config { + edit: { + undoTimeout: number; + } +}