This commit is contained in:
Diamantis Tziotzios 2024-02-01 11:36:55 +02:00
parent 5373e2d867
commit 30902bbab8
3 changed files with 27 additions and 29 deletions

View File

@ -340,7 +340,7 @@ export class DescriptionTemplatePageEditorModel implements DescriptionTemplatePa
rootPath: string
}): void {
const { validationErrorModel, rootPath, formArray } = params;
}
static reapplyValidators(params: {
@ -1019,7 +1019,7 @@ export class DescriptionTemplateLabelDataEditorModel implements DescriptionTempl
}
export class DescriptionTemplateLabelAndMultiplicityDataEditorModel extends DescriptionTemplateLabelDataEditorModel implements DescriptionTemplateLabelAndMultiplicityDataPersist {
multipleSelect: boolean;
multipleSelect: boolean = false;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
@ -1029,7 +1029,7 @@ export class DescriptionTemplateLabelAndMultiplicityDataEditorModel extends Desc
fromModel(item: DescriptionTemplateLabelAndMultiplicityDataPersist): DescriptionTemplateLabelAndMultiplicityDataEditorModel {
if (item) {
super.fromModel(item);
this.multipleSelect = item.multipleSelect;
this.multipleSelect = item.multipleSelect ?? false;
}
return this;
}
@ -1158,7 +1158,7 @@ export class DescriptionTemplateExternalDatasetDataEditorModel extends Descripti
//
//
export class DescriptionTemplateExternalSelectDataEditorModel extends DescriptionTemplateLabelDataEditorModel implements DescriptionTemplateExternalSelectDataPersist {
multipleSelect: boolean;
multipleSelect: boolean = false;
sources: DescriptionTemplateExternalSelectSourceEditorModel[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -1169,7 +1169,7 @@ export class DescriptionTemplateExternalSelectDataEditorModel extends Descriptio
fromModel(item: DescriptionTemplateExternalSelectDataPersist): DescriptionTemplateExternalSelectDataEditorModel {
if (item) {
super.fromModel(item);
this.multipleSelect = item.multipleSelect;
this.multipleSelect = item.multipleSelect ?? false;
if (item.sources) { item.sources.map(x => this.sources.push(new DescriptionTemplateExternalSelectSourceEditorModel(this.validationErrorModel).fromModel(x))); }
}
return this;
@ -1655,7 +1655,7 @@ export class DescriptionTemplateRadioBoxOptionEditorModel implements Description
//
export class DescriptionTemplateSelectDataEditorModel extends DescriptionTemplateLabelDataEditorModel implements DescriptionTemplateSelectDataPersist {
options: DescriptionTemplateSelectOptionEditorModel[] = [];
multipleSelect: boolean;
multipleSelect: boolean = false;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
@ -1665,7 +1665,7 @@ export class DescriptionTemplateSelectDataEditorModel extends DescriptionTemplat
fromModel(item: DescriptionTemplateSelectDataPersist): DescriptionTemplateSelectDataEditorModel {
if (item) {
super.fromModel(item);
this.multipleSelect = item.multipleSelect;
this.multipleSelect = item.multipleSelect ?? false;
if (item.options) { item.options.map(x => this.options.push(new DescriptionTemplateSelectOptionEditorModel(this.validationErrorModel).fromModel(x))); }
}
return this;
@ -1950,4 +1950,4 @@ export class DescriptionTemplateUploadOptionEditorModel implements DescriptionTe
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
}

View File

@ -139,7 +139,7 @@
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.SYSTEM">
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.TEXT">
<mat-form-field class="w-100">
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.TITLE' | translate}}" type="text" name="label" [formControl]="formGroup.get('label')" required>
<input matInput placeholder="{{field.placeholder ?? 'DMP-EDITOR.FIELDS.TITLE' | translate}}" type="text" name="label" [formControl]="formGroup.get('label')" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
{{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')">
@ -295,22 +295,22 @@
</div>
</div>
</div>
<div class="col-12 card" *ngIf="section.hasTemplates">
{{formGroup.get('descriptionTemplates').get(section.id).value | json}}
<div class="row">
<div class="col-12">
<div class="input-form">
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionRemoved)="onRemoveDescriptionTemplate($event, i)" (optionActionClicked)="onPreviewDescriptionTemplate($event, i)" (optionSelected)="onDescriptionTemplateSelected($event, i)">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col pl-0 pt-0 pb-0 d-flex">
<span class="not-found-template">{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}}</span>
</div>
</div>
<div class="col-12 card" *ngIf="section.hasTemplates">
{{formGroup.get('descriptionTemplates').get(section.id).value | json}}
<div class="row">
<div class="col-12">
<div class="input-form">
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionRemoved)="onRemoveDescriptionTemplate($event, i)" (optionActionClicked)="onPreviewDescriptionTemplate($event, i)" (optionSelected)="onDescriptionTemplateSelected($event, i)">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col pl-0 pt-0 pb-0 d-flex">
<span class="not-found-template">{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}}</span>
</div>
</div>
</div>

View File

@ -193,9 +193,7 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
const formGroup = this.formBuilder.group({
contacts: this.formBuilder.array(
(this.contacts ?? []).map(
(item, index) => new DmpContactEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
(item, index) => item.buildForm({
rootPath: `${rootPath}contacts[${index}].`
})
), context.getValidation('contacts').validators
@ -350,7 +348,7 @@ export class DmpContactEditorModel implements DmpContactPersist {
this.firstName = item.firstName;
this.lastName = item.lastName;
this.email = item.email;
this.contactType = item == null ? DmpContactType.Internal : (this.userId != null ? DmpContactType.Internal : DmpContactType.External);
this.contactType = (item == null || this.userId != null) ? DmpContactType.Internal : DmpContactType.External;
return this;
}