add status filter on description template type autocomplete lookup
This commit is contained in:
parent
ab1e025a75
commit
6767226b46
|
@ -12,6 +12,7 @@ import { catchError, map } from 'rxjs/operators';
|
||||||
import { nameof } from 'ts-simple-nameof';
|
import { nameof } from 'ts-simple-nameof';
|
||||||
import { ConfigurationService } from '../configuration/configuration.service';
|
import { ConfigurationService } from '../configuration/configuration.service';
|
||||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||||
|
import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DescriptionTemplateTypeService {
|
export class DescriptionTemplateTypeService {
|
||||||
|
@ -69,6 +70,17 @@ export class DescriptionTemplateTypeService {
|
||||||
valueAssign: (item: DescriptionTemplateType) => item.id,
|
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
|
// tslint:disable-next-line: member-ordering
|
||||||
multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||||
initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)),
|
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,
|
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();
|
const lookup: DescriptionTemplateTypeLookup = new DescriptionTemplateTypeLookup();
|
||||||
lookup.page = { size: 100, offset: 0 };
|
lookup.page = { size: 100, offset: 0 };
|
||||||
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
|
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
|
||||||
if (ids && ids.length > 0) { lookup.ids = ids; }
|
if (ids && ids.length > 0) { lookup.ids = ids; }
|
||||||
lookup.isActive = [IsActive.Active];
|
lookup.isActive = [IsActive.Active];
|
||||||
|
lookup.statuses = statuses;
|
||||||
lookup.project = {
|
lookup.project = {
|
||||||
fields: [
|
fields: [
|
||||||
nameof<DescriptionTemplateType>(x => x.id),
|
nameof<DescriptionTemplateType>(x => x.id),
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
<div class="hint">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-TYPE-HINT'| translate}}</div>
|
<div class="hint">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-TYPE-HINT'| translate}}</div>
|
||||||
<mat-form-field class="full-width basic-info-input">
|
<mat-form-field class="full-width basic-info-input">
|
||||||
<mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-SELECT-TYPE' | translate}}</mat-label>
|
<mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-SELECT-TYPE' | translate}}</mat-label>
|
||||||
<app-single-auto-complete [required]="false" [formControl]="formGroup.get('type')" placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-SELECT-TYPE' | translate}}" [configuration]="descriptionTemplateTypeService.singleAutocompleteConfiguration">
|
<app-single-auto-complete [required]="false" [formControl]="formGroup.get('type')" placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-SELECT-TYPE' | translate}}" [configuration]="singleAutocompleteDescriptionTemplateTypeConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('type').hasError('backendError')">{{formGroup.get('type').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="formGroup.get('type').hasError('backendError')">{{formGroup.get('type').getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="formGroup.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="formGroup.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
|
|
@ -43,6 +43,8 @@ import { ConfigurationService } from '@app/core/services/configuration/configura
|
||||||
import { LockService } from '@app/core/services/lock/lock.service';
|
import { LockService } from '@app/core/services/lock/lock.service';
|
||||||
import { LockTargetType } from '@app/core/common/enum/lock-target-type';
|
import { LockTargetType } from '@app/core/common/enum/lock-target-type';
|
||||||
import { Title } from '@angular/platform-browser';
|
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({
|
@Component({
|
||||||
|
@ -76,6 +78,9 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
usersMap: Map<Guid, User> = new Map<Guid, User>();
|
usersMap: Map<Guid, User> = new Map<Guid, User>();
|
||||||
userFormControl = new FormControl();
|
userFormControl = new FormControl();
|
||||||
|
|
||||||
|
singleAutocompleteDescriptionTemplateTypeConfiguration: SingleAutoCompleteConfiguration;
|
||||||
|
|
||||||
|
|
||||||
//Preview
|
//Preview
|
||||||
previewFieldSet: DescriptionTemplate = null;
|
previewFieldSet: DescriptionTemplate = null;
|
||||||
previewPropertiesFormGroup: UntypedFormGroup = null;
|
previewPropertiesFormGroup: UntypedFormGroup = null;
|
||||||
|
@ -137,6 +142,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.matomoService.trackPageView('Admin: DMP Blueprints');
|
this.matomoService.trackPageView('Admin: DMP Blueprints');
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
this.singleAutocompleteDescriptionTemplateTypeConfiguration = this.descriptionTemplateTypeService.getSingleAutocompleteConfiguration([DescriptionTemplateTypeStatus.Finalized]);
|
||||||
this.initModelFlags(this.route.snapshot.data['action']);
|
this.initModelFlags(this.route.snapshot.data['action']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue