Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
ab5fc150a4
|
@ -86,6 +86,17 @@ export class PrefillingSourceService {
|
||||||
titleFn: (item: PrefillingSource) => item.label,
|
titleFn: (item: PrefillingSource) => item.label,
|
||||||
valueAssign: (item: PrefillingSource) => item.id,
|
valueAssign: (item: PrefillingSource) => item.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public getSingleAutocompleteConfiguration(ids: Guid[]): SingleAutoCompleteConfiguration {
|
||||||
|
return {
|
||||||
|
initialItems: (data?: any) => this.query(this.buildAutocompleteLookup(null, null, ids && ids.length > 0 ? ids: null)).pipe(map(x => x.items)),
|
||||||
|
filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteLookup(searchQuery, null, ids && ids.length > 0 ? ids: null)).pipe(map(x => x.items)),
|
||||||
|
getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])),
|
||||||
|
displayFn: (item: PrefillingSource) => item.label,
|
||||||
|
titleFn: (item: PrefillingSource) => item.label,
|
||||||
|
valueAssign: (item: PrefillingSource) => item.id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public multipleAutocompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
public 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)),
|
||||||
|
@ -96,6 +107,17 @@ export class PrefillingSourceService {
|
||||||
valueAssign: (item: PrefillingSource) => item.id,
|
valueAssign: (item: PrefillingSource) => item.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public getMltipleAutocompleteConfiguration(ids: Guid[]): MultipleAutoCompleteConfiguration {
|
||||||
|
return {
|
||||||
|
initialItems: (excludedItems: any[], data?: any) => this.query(this.buildAutocompleteLookup(null, excludedItems ? excludedItems : null, ids && ids.length > 0 ? ids: null)).pipe(map(x => x.items)),
|
||||||
|
filterFn: (searchQuery: string, excludedItems: any[]) => this.query(this.buildAutocompleteLookup(searchQuery, excludedItems, ids && ids.length > 0 ? ids: null)).pipe(map(x => x.items)),
|
||||||
|
getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteLookup(null, null, selectedItems)).pipe(map(x => x.items)),
|
||||||
|
displayFn: (item: PrefillingSource) => item.label,
|
||||||
|
titleFn: (item: PrefillingSource) => item.label,
|
||||||
|
valueAssign: (item: PrefillingSource) => item.id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): PrefillingSourceLookup {
|
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): PrefillingSourceLookup {
|
||||||
const lookup: PrefillingSourceLookup = new PrefillingSourceLookup();
|
const lookup: PrefillingSourceLookup = new PrefillingSourceLookup();
|
||||||
lookup.page = { size: 100, offset: 0 };
|
lookup.page = { size: 100, offset: 0 };
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTempl
|
||||||
import { Description, DescriptionExternalIdentifier, DescriptionField, DescriptionPropertyDefinition, DescriptionPropertyDefinitionFieldSet, DescriptionPropertyDefinitionFieldSetItem, DescriptionReference, DescriptionReferenceData, DescriptionTag } from '@app/core/model/description/description';
|
import { Description, DescriptionExternalIdentifier, DescriptionField, DescriptionPropertyDefinition, DescriptionPropertyDefinitionFieldSet, DescriptionPropertyDefinitionFieldSetItem, DescriptionReference, DescriptionReferenceData, DescriptionTag } from '@app/core/model/description/description';
|
||||||
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp';
|
import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp';
|
||||||
|
import { PrefillingSource } from '@app/core/model/prefilling-source/prefilling-source';
|
||||||
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
|
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
|
||||||
import { Reference } from '@app/core/model/reference/reference';
|
import { Reference } from '@app/core/model/reference/reference';
|
||||||
import { Tag } from '@app/core/model/tag/tag';
|
import { Tag } from '@app/core/model/tag/tag';
|
||||||
|
@ -127,6 +128,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
|
||||||
// (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
// (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
|
||||||
// (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
// (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
|
||||||
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
|
||||||
|
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.prefillingSources), nameof<PrefillingSource>(x => x.id)].join('.'),
|
||||||
|
|
||||||
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
|
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
|
||||||
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
|
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<mat-form-field class="col-md-12">
|
<mat-form-field class="col-md-12">
|
||||||
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillingSourceId')"
|
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillingSourceId')"
|
||||||
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}"
|
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}"
|
||||||
[configuration]="prefillingSourceService.singleAutocompleteConfiguration" (optionSelected)="changePreffillingSource($event)">
|
[configuration]="singlePrefillingSourceAutoCompleteConfiguration" (optionSelected)="changePreffillingSource($event)">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
<mat-error *ngIf="prefillForm.get('prefillingSourceId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="prefillForm.get('prefillingSourceId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
<mat-form-field class="col-md-12">
|
<mat-form-field class="col-md-12">
|
||||||
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('data')"
|
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('data')"
|
||||||
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
|
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
|
||||||
[configuration]="prefillAutoCompleteConfiguration">
|
[configuration]="prefillObjectAutoCompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,7 +28,8 @@ import { DescriptionPrefillingRequestEditorModel } from "./prefill-description-e
|
||||||
export class PrefillDescriptionDialogComponent extends BaseComponent implements OnInit {
|
export class PrefillDescriptionDialogComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
progressIndication = false;
|
progressIndication = false;
|
||||||
prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
singlePrefillingSourceAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
|
prefillObjectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
prefillSelected: boolean = false;
|
prefillSelected: boolean = false;
|
||||||
prefillForm: UntypedFormGroup;
|
prefillForm: UntypedFormGroup;
|
||||||
|
|
||||||
|
@ -49,13 +50,16 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
const availablePrefillingSourcesIds = this.dmp.blueprint.definition.sections.filter(x => x.id === this.dmpSectionId)[0].prefillingSources?.map(x => x.id) || null;
|
||||||
|
this.singlePrefillingSourceAutoCompleteConfiguration = this.prefillingSourceService.getSingleAutocompleteConfiguration(availablePrefillingSourcesIds);
|
||||||
|
|
||||||
this.progressIndicationService.getProgressIndicationObservable().pipe(takeUntil(this._destroyed)).subscribe(x => {
|
this.progressIndicationService.getProgressIndicationObservable().pipe(takeUntil(this._destroyed)).subscribe(x => {
|
||||||
setTimeout(() => { this.progressIndication = x; });
|
setTimeout(() => { this.progressIndication = x; });
|
||||||
});
|
});
|
||||||
const editorModel = new DescriptionPrefillingRequestEditorModel();
|
const editorModel = new DescriptionPrefillingRequestEditorModel();
|
||||||
this.prefillForm = editorModel.buildForm(null, false);
|
this.prefillForm = editorModel.buildForm(null, false);
|
||||||
|
|
||||||
this.prefillAutoCompleteConfiguration = {
|
this.prefillObjectAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchDescriptions.bind(this),
|
filterFn: this.searchDescriptions.bind(this),
|
||||||
loadDataOnStart: false,
|
loadDataOnStart: false,
|
||||||
displayFn: (item: Prefilling) => (item.label.length > 60) ? (item.label.substr(0, 60) + "...") : item.label,
|
displayFn: (item: Prefilling) => (item.label.length > 60) ? (item.label.substr(0, 60) + "...") : item.label,
|
||||||
|
|
Loading…
Reference in New Issue