From 3bab68265b7cd887ff86066b688efa1c78acccdd Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Fri, 13 Dec 2019 17:05:19 +0200 Subject: [PATCH] added grant id to displayfn --- .../multiple/multiple-auto-complete.component.ts | 2 +- .../single/single-auto-complete.component.ts | 2 +- .../ui/dmp/editor/grant-tab/grant-tab.component.ts | 12 ++++++++++-- .../grant-editor/grant-editor-wizard.component.ts | 13 +++++++++++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts index a81bf3b2f..53a023340 100644 --- a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts @@ -241,8 +241,8 @@ export class MultipleAutoCompleteComponent extends _CustomComponentMixinBase imp onContainerClick(event: MouseEvent) { event.stopPropagation(); - this._onInputFocus(); if (this.disabled) { return; } + this._onInputFocus(); if (!this.autocomplete.isOpen) { this.autocompleteTrigger.openPanel(); } diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts index 3d0f8788d..86000d024 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts @@ -262,8 +262,8 @@ export class SingleAutoCompleteComponent extends _CustomComponentMixinBase imple onContainerClick(event: MouseEvent) { event.stopPropagation(); - this._onInputFocus(); if (this.disabled) { return; } + this._onInputFocus(); if (!this.autocomplete.isOpen) { this.autocompleteTrigger.openPanel(); } diff --git a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts index b39fe23fe..b8e6797a6 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts @@ -45,6 +45,14 @@ export class GrantTabComponent extends BaseComponent implements OnInit { super(); } + getGrantIdText(item) { + if (item.reference != null && typeof item.reference == 'string') { + const parts = (item.reference as String).split('::'); + return parts.length > 1 ? ' (' + parts[parts.length - 1] + ')' : ''; + } + return ''; + } + ngOnInit() { const grantRequestItem: RequestItem = new RequestItem(); @@ -61,8 +69,8 @@ export class GrantTabComponent extends BaseComponent implements OnInit { this.grantAutoCompleteConfiguration = { filterFn: this.searchGrant.bind(this), initialItems: () => this.searchGrant(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], + displayFn: (item) => item['label'] + this.getGrantIdText(item), + titleFn: (item) => item['label'] + this.getGrantIdText(item), subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') }; diff --git a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts index de9f7f666..55b6f6fcc 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts +++ b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts @@ -17,6 +17,7 @@ import { ValidationErrorModel } from '@common/forms/validation/error-model/valid import { TranslateService } from '@ngx-translate/core'; import { Observable, of as observableOf } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +import { strict } from 'assert'; @Component({ selector: 'app-quick-wizard-grant-editor-component', @@ -44,6 +45,14 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit, super(); } + getGrantIdText(item) { + if (item.reference != null && typeof item.reference == 'string') { + const parts = (item.reference as String).split('::'); + return parts.length > 1 ? ' (' + parts[parts.length - 1] + ')' : ''; + } + return ''; + } + ngOnInit() { this.breadCrumbs = observableOf([{ parentComponentName: 'QuickCreate', @@ -57,8 +66,8 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit, this.grantAutoCompleteConfiguration = { filterFn: this.searchGrant.bind(this), initialItems: (extraData) => this.searchGrant(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], + displayFn: (item) => item['label'] + this.getGrantIdText(item), + titleFn: (item) => item['label'] + this.getGrantIdText(item), subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') };