diff --git a/dmp-frontend/src/app/core/services/description-template-type/description-template-type.service.ts b/dmp-frontend/src/app/core/services/description-template-type/description-template-type.service.ts index 4b8666439..8788a96a9 100644 --- a/dmp-frontend/src/app/core/services/description-template-type/description-template-type.service.ts +++ b/dmp-frontend/src/app/core/services/description-template-type/description-template-type.service.ts @@ -12,6 +12,7 @@ import { catchError, map } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service'; +import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status'; @Injectable() export class DescriptionTemplateTypeService { @@ -69,6 +70,17 @@ export class DescriptionTemplateTypeService { valueAssign: (item: DescriptionTemplateType) => item.id, }; + public getSingleAutocompleteConfiguration(statuses?: DescriptionTemplateTypeStatus[]): SingleAutoCompleteConfiguration { + return { + initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(null, null, null, statuses ? statuses: null)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(searchQuery, null, null, statuses ? statuses: null)).pipe(map(x => x.items)), + getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), + displayFn: (item: DescriptionTemplateType) => item.name, + titleFn: (item: DescriptionTemplateType) => item.name, + valueAssign: (item: DescriptionTemplateType) => item.id, + }; + } + // tslint:disable-next-line: member-ordering multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = { initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)), @@ -79,12 +91,24 @@ export class DescriptionTemplateTypeService { valueAssign: (item: DescriptionTemplateType) => item.id, }; - private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DescriptionTemplateTypeLookup { + public getMultipleAutoCompleteSearchConfiguration(statuses?: DescriptionTemplateTypeStatus[]): MultipleAutoCompleteConfiguration { + return { + initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(null, excludedItems ? excludedItems : null, null, statuses ? statuses: null)).pipe(map(x => x.items)), + filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(searchQuery, excludedItems, null, statuses ? statuses: null)).pipe(map(x => x.items)), + getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(null, null, selectedItems)).pipe(map(x => x.items)), + displayFn: (item: DescriptionTemplateType) => item.name, + titleFn: (item: DescriptionTemplateType) => item.name, + valueAssign: (item: DescriptionTemplateType) => item.id, + }; + } + + private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[], statuses?: DescriptionTemplateTypeStatus[]): DescriptionTemplateTypeLookup { const lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup(); lookup.page = { size: 100, offset: 0 }; if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } if (ids && ids.length > 0) { lookup.ids = ids; } lookup.isActive = [IsActive.Active]; + lookup.statuses = statuses; lookup.project = { fields: [ nameof(x => x.id), diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html index 54cceb530..5220ff6c9 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html @@ -82,7 +82,7 @@
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-TYPE-HINT'| translate}}
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-SELECT-TYPE' | translate}} - + {{formGroup.get('type').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index f3cb1c249..b0f972580 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts @@ -43,6 +43,8 @@ import { ConfigurationService } from '@app/core/services/configuration/configura import { LockService } from '@app/core/services/lock/lock.service'; import { LockTargetType } from '@app/core/common/enum/lock-target-type'; import { Title } from '@angular/platform-browser'; +import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; +import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status'; @Component({ @@ -76,6 +78,9 @@ export class DescriptionTemplateEditorComponent extends BaseEditor = new Map(); userFormControl = new FormControl(); + singleAutocompleteDescriptionTemplateTypeConfiguration: SingleAutoCompleteConfiguration; + + //Preview previewFieldSet: DescriptionTemplate = null; previewPropertiesFormGroup: UntypedFormGroup = null; @@ -137,6 +142,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor