Applied feedback

This commit is contained in:
lotte
2019-03-01 09:31:03 +01:00
parent 8125f56009
commit 27180c5960
8 changed files with 43 additions and 12 deletions

View File

@@ -79,5 +79,10 @@ module.exports = {
code: 'nl',
label: 'Nederlands',
active: false,
}]
}],
item: {
edit: {
undoTimeout: 10000 // 10 seconds
}
}
};

View File

@@ -1,4 +1,3 @@
<!--{{metadata?.uuid}}-->
<td>
<div class="metadata-field">
<div *ngIf="!(editable | async)">

View File

@@ -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

View File

@@ -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');
}

View File

@@ -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<RemoteData<PaginatedList<MetadataField>>> {
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<RemoteData<PaginatedList<MetadataField>>> {
/**
* 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<PaginatedList<MetadataField>>) => {
const filteredFields: MetadataField[] = rd.payload.page.filter(

View File

@@ -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) {
}

View File

@@ -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;
}

View File

@@ -0,0 +1,7 @@
import { Config } from './config.interface';
export interface ItemPageConfig extends Config {
edit: {
undoTimeout: number;
}
}