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

View File

@ -139,7 +139,7 @@
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.SYSTEM"> <div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.SYSTEM">
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.TEXT"> <div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.TEXT">
<mat-form-field class="w-100"> <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')"> <mat-error *ngIf="formGroup.get('label').hasError('backendError')">
{{formGroup.get('label').getError('backendError').message}}</mat-error> {{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')"> <mat-error *ngIf="formGroup.get('label').hasError('required')">
@ -295,22 +295,22 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 card" *ngIf="section.hasTemplates"> </div>
{{formGroup.get('descriptionTemplates').get(section.id).value | json}} <div class="col-12 card" *ngIf="section.hasTemplates">
<div class="row"> {{formGroup.get('descriptionTemplates').get(section.id).value | json}}
<div class="col-12"> <div class="row">
<div class="input-form"> <div class="col-12">
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div> <div class="input-form">
<mat-form-field class="w-100"> <div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label> <mat-form-field class="w-100">
<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)"> <mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
</app-multiple-auto-complete> <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)">
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error> </app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
</mat-form-field> <mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<div class="col pl-0 pt-0 pb-0 d-flex"> </mat-form-field>
<span class="not-found-template">{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}}</span> <div class="col pl-0 pt-0 pb-0 d-flex">
</div> <span class="not-found-template">{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}}</span>
</div> </div>
</div> </div>
</div> </div>

View File

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