more description editor changes

This commit is contained in:
Diamantis Tziotzios 2024-02-08 19:48:14 +02:00
parent 313f5e3b3c
commit 174e57f62b
7 changed files with 88 additions and 192 deletions

View File

@ -555,7 +555,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
prepareForm(data: Description) { prepareForm(data: Description) {
try { try {
this.editorModel = data ? new DescriptionEditorModel().fromModel(data) : new DescriptionEditorModel(); this.editorModel = data ? new DescriptionEditorModel().fromModel(data, data.descriptionTemplate) : new DescriptionEditorModel();
this.item = data; this.item = data;
this.isDeleted = data ? data.isActive === IsActive.Inactive : false; this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
this.buildForm(); this.buildForm();
@ -584,17 +584,14 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
refreshOnNavigateToData(id?: Guid): void { refreshOnNavigateToData(id?: Guid): void {
this.formGroup.markAsPristine(); this.formGroup.markAsPristine();
let route = [];
if (id === null) { if (this.isNew) {
route.push('../..'); let route = [];
} else if (this.isNew) { route.push('/descriptions/overview/' + id);
route.push('../' + id); this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
} else { } else {
route.push('..'); this.refreshData();
} }
this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
} }
persistEntity(onSuccess?: (response) => void): void { persistEntity(onSuccess?: (response) => void): void {

View File

@ -312,7 +312,7 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des
if (item) { if (item) {
this.comment = item.comment; this.comment = item.comment;
this.ordinal = item.ordinal; this.ordinal = item.ordinal;
if (item.fields) { item.fields?.forEach((value, key) => this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(value, definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences))); } if (item.fields) { Object.keys(item.fields)?.forEach(key => this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(item.fields[key], definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences))); }
} }
return this; return this;
} }

View File

@ -187,164 +187,94 @@
</mat-form-field> </mat-form-field>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.EXTERNAL_DATASETS" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.EXTERNAL_DATASETS" class="col-12">
<div class="row"> <ng-container *ngIf="field.data.multipleSelect">
<mat-form-field class="col-md-12"> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Datasets" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<ng-container *ngIf="field.data.multipleSelect"> </ng-container>
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="externalDatasetAutoCompleteConfiguration" [required]="isRequired"> <ng-container *ngIf="!(field.data.multipleSelect)">
</app-multiple-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Datasets" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="externalDatasetAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.DATA_REPOSITORIES" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.DATA_REPOSITORIES" class="col-12">
<div class="row"> <ng-container *ngIf="field.data.multipleSelect">
<mat-form-field class="col-md-12"> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.DataRepositories" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<ng-container *ngIf="field.data.multipleSelect"> </ng-container>
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="dataRepositoriesAutoCompleteConfiguration" [required]="isRequired"> <ng-container *ngIf="!(field.data.multipleSelect)">
</app-multiple-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.DataRepositories" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="dataRepositoriesAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.PUB_REPOSITORIES" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.PUB_REPOSITORIES" class="col-12">
<div class="row"> <ng-container *ngIf="field.data.multipleSelect">
<mat-form-field class="col-md-12"> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.PubRepositories" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<ng-container *ngIf="field.data.multipleSelect"> </ng-container>
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="pubRepositoriesAutoCompleteConfiguration" [required]="isRequired"> <ng-container *ngIf="!(field.data.multipleSelect)">
</app-multiple-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.PubRepositories" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="pubRepositoriesAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.JOURNAL_REPOSITORIES" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.JOURNAL_REPOSITORIES" class="col-12">
<div class="row"> <ng-container *ngIf="field.data.multipleSelect">
<mat-form-field class="col-md-12"> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Journals" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<ng-container *ngIf="field.data.multipleSelect"> </ng-container>
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="journalRepositoriesAutoCompleteConfiguration" [required]="isRequired"> <ng-container *ngIf="!(field.data.multipleSelect)">
</app-multiple-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Journals" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="journalRepositoriesAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>\
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.TAXONOMIES" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.TAXONOMIES" class="col-12">
<div *ngIf="field.data" class="row"> <ng-container *ngIf="field.data.multipleSelect">
<mat-form-field class="col-md-12"> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Taxonomies" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<ng-container *ngIf="field.data.multipleSelect"> </ng-container>
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="taxonomiesAutoCompleteConfiguration" [required]="isRequired"> <ng-container *ngIf="!(field.data.multipleSelect)">
</app-multiple-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Taxonomies" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="taxonomiesAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.LICENSES" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.LICENSES" class="col-12">
<div *ngIf="field.data" class="row"> <ng-container *ngIf="field.data.multipleSelect">
<mat-form-field class="col-md-12"> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Licenses" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<ng-container *ngIf="field.data.multipleSelect"> </ng-container>
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="licensesAutoCompleteConfiguration" [required]="isRequired"> <ng-container *ngIf="!(field.data.multipleSelect)">
</app-multiple-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Licenses" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="licensesAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.PUBLICATIONS" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.PUBLICATIONS" class="col-12">
<div *ngIf="field.data" class="row"> <ng-container *ngIf="field.data.multipleSelect">
<mat-form-field class="col-md-12"> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Licenses" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<ng-container *ngIf="field.data.multipleSelect"> </ng-container>
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="publicationsAutoCompleteConfiguration" [required]="isRequired"> <ng-container *ngIf="!(field.data.multipleSelect)">
</app-multiple-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Licenses" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="publicationsAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.REGISTRIES" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.REGISTRIES" class="col-12">
<div class="row"> <ng-container *ngIf="field.data.multipleSelect">
<mat-form-field class="col-md-12"> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Registries" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<ng-container *ngIf="field.data.multipleSelect"> </ng-container>
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="registriesAutoCompleteConfiguration"> <ng-container *ngIf="!(field.data.multipleSelect)">
</app-multiple-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Registries" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container> </div>
<ng-container *ngIf="!(field.data.multipleSelect)"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.SERVICES" class="col-12">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="registriesAutoCompleteConfiguration" [required]="isRequired"> <ng-container *ngIf="field.data.multipleSelect">
</app-single-auto-complete> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Services" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> </ng-container>
</ng-container> <ng-container *ngIf="!(field.data.multipleSelect)">
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint> <app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Services" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
</mat-form-field> </ng-container>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.RESEARCHERS" class="col-12">
<ng-container *ngIf="field.data.multipleSelect">
<app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Researcher" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Researcher" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
</ng-container>
</div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.ORGANIZATIONS" class="col-12">
<ng-container *ngIf="field.data.multipleSelect">
<app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Organizations" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Organizations" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
</ng-container>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.SERVICES" class="col-12">
<div class="row">
<mat-form-field class="col-md-12">
<ng-container *ngIf="field.data.multipleSelect">
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="servicesAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="servicesAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.TAGS" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.TAGS" class="col-12">
<div class="row"> <div class="row">
@ -355,44 +285,6 @@
</div> </div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.RESEARCHERS" class="col-12">
<div class="row">
<mat-form-field class="col-md-12">
<ng-container *ngIf="field.data.multipleSelect">
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="researchersAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.ORGANIZATIONS" class="col-12">
<div class="row">
<mat-form-field class="col-md-12">
<ng-container *ngIf="field.data.multipleSelect">
<app-multiple-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('references')" [configuration]="organisationsAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('references').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-single-auto-complete placeholder="{{ (field.data.label | translate) + (isRequired? ' *': '') }}" [formControl]="propertiesFormGroup?.get(field.id).get('reference')" [configuration]="organisationsAutoCompleteConfiguration" [required]="isRequired">
</app-single-auto-complete>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('reference').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
</mat-error>
</ng-container>
<mat-hint>{{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}</mat-hint>
</mat-form-field>
</div>
</div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.DATASET_IDENTIFIER" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.DATASET_IDENTIFIER" class="col-12">
<div class="row" *ngIf="datasetIdInitialized"> <div class="row" *ngIf="datasetIdInitialized">
<mat-form-field class="col-md-12"> <mat-form-field class="col-md-12">

View File

@ -35,6 +35,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
@Input() propertiesFormGroup: UntypedFormGroup; @Input() propertiesFormGroup: UntypedFormGroup;
@Input() visibilityRulesService: VisibilityRulesService; @Input() visibilityRulesService: VisibilityRulesService;
isRequired: boolean = false; isRequired: boolean = false;
referenceTypeEnum = ReferenceType;
// @Input() field: Field; // @Input() field: Field;

View File

@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
import { FormattingModule } from "@app/core/formatting.module"; import { FormattingModule } from "@app/core/formatting.module";
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module"; import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module";
import { ReferenceFieldModule } from '@app/ui/reference/reference-field/reference-field.module';
import { CommonFormsModule } from '@common/forms/common-forms.module'; import { CommonFormsModule } from '@common/forms/common-forms.module';
import { CommonUiModule } from '@common/ui/common-ui.module'; import { CommonUiModule } from '@common/ui/common-ui.module';
import { NgxDropzoneModule } from "ngx-dropzone"; import { NgxDropzoneModule } from "ngx-dropzone";
@ -20,7 +21,8 @@ import { DescriptionFormComponent } from './description-form.component';
AutoCompleteModule, AutoCompleteModule,
RichTextEditorModule, RichTextEditorModule,
NgxDropzoneModule, NgxDropzoneModule,
FormattingModule FormattingModule,
ReferenceFieldModule
], ],
declarations: [ declarations: [
DescriptionFormComponent, DescriptionFormComponent,

View File

@ -1,9 +1,10 @@
<mat-form-field class="w-100" *ngIf="multipleAutoCompleteSearchConfiguration"> <mat-form-field class="w-100" *ngIf="multipleAutoCompleteSearchConfiguration">
<mat-label>{{label ?? enumUtils.toReferenceTypeString(referenceType)}}</mat-label> <mat-label>{{label ?? enumUtils.toReferenceTypeString(referenceType)}}</mat-label>
<app-multiple-auto-complete placeholder = "{{ placeholder ?? enumUtils.toReferenceTypeString(referenceType)}}" [formControl]="form" [configuration]="multipleAutoCompleteSearchConfiguration"> <app-multiple-auto-complete placeholder="{{ placeholder ?? enumUtils.toReferenceTypeString(referenceType)}}" [formControl]="form" [configuration]="multipleAutoCompleteSearchConfiguration" [required]="required">
</app-multiple-auto-complete> </app-multiple-auto-complete>
<mat-error *ngIf="form.hasError('backendError')">{{form.getError('backendError').message}}</mat-error> <mat-error *ngIf="form.hasError('backendError')">{{form.getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-hint *ngIf="hint">{{hint}}</mat-hint>
</mat-form-field> </mat-form-field>
<div class="mb-4"> <div class="mb-4">
<span *ngIf="!form.disabled" class="not-found">{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}}</span> <span *ngIf="!form.disabled" class="not-found">{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}}</span>

View File

@ -17,6 +17,9 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit {
@Input() form: UntypedFormGroup = null; @Input() form: UntypedFormGroup = null;
@Input() label: string = null; @Input() label: string = null;
@Input() placeholder: string = "Enter text"; @Input() placeholder: string = "Enter text";
@Input() required: boolean = false;
@Input() multiple: boolean = true;
@Input() hint: string;
multipleAutoCompleteSearchConfiguration: MultipleAutoCompleteConfiguration; multipleAutoCompleteSearchConfiguration: MultipleAutoCompleteConfiguration;