description templates validation fixes (in progress)

This commit is contained in:
amentis 2024-02-05 17:59:11 +02:00
parent 8bf1e0c4d6
commit fc756a1780
26 changed files with 295 additions and 139 deletions

View File

@ -4,18 +4,23 @@ import eu.eudat.commons.validation.BaseValidator;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class MultiplicityPersist { public class MultiplicityPersist {
private Integer min = null; private Integer min = null;
public static final String _min = "min";
private Integer max = null; private Integer max = null;
public static final String _max = "max";
private String placeholder = null; private String placeholder = null;
@ -59,8 +64,11 @@ public class MultiplicityPersist {
public static final String ValidatorName = "DescriptionTemplate.MultiplicityValidator"; public static final String ValidatorName = "DescriptionTemplate.MultiplicityValidator";
protected MultiplicityValidator(ConventionService conventionService, ErrorThesaurusProperties errors) { private final MessageSource messageSource;
protected MultiplicityValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors); super(conventionService, errors);
this.messageSource = messageSource;
} }
@Override @Override
@ -70,7 +78,20 @@ public class MultiplicityPersist {
@Override @Override
protected List<Specification> specifications(MultiplicityPersist item) { protected List<Specification> specifications(MultiplicityPersist item) {
return Lists.newArrayList(); return Arrays.asList(
this.spec()
.iff(() -> !this.isNull(item.getMin()))
.must(() -> item.getMin() >= 0)
.failOn(MultiplicityPersist._min).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{MultiplicityPersist._min}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isNull(item.getMax()))
.must(() -> item.getMax() >= 0)
.failOn(MultiplicityPersist._max).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{MultiplicityPersist._max}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isNull(item.getMax()))
.must(() -> !this.isNull(item.getMin()) && (item.getMax() >= item.getMin()))
.failOn(MultiplicityPersist._max).failWith(messageSource.getMessage("Validation.LowerThanMin", new Object[]{MultiplicityPersist._min}, LocaleContextHolder.getLocale()))
);
} }
} }

View File

@ -161,7 +161,10 @@ public class ExternalSelectDataPersist extends BaseFieldDataPersist {
protected List<Specification> specifications(ExternalSelectSourcePersist item) { protected List<Specification> specifications(ExternalSelectSourcePersist item) {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isNull(item.getUrl())) .must(() -> !this.isEmpty(item.getMethod()))
.failOn(ExternalSelectSourcePersist._method).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalSelectSourcePersist._method}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getUrl()))
.failOn(ExternalSelectSourcePersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalSelectSourcePersist._url}, LocaleContextHolder.getLocale())), .failOn(ExternalSelectSourcePersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalSelectSourcePersist._url}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.iff(() -> !this.isNull(item.getHasAuth()) && item.getHasAuth()) .iff(() -> !this.isNull(item.getHasAuth()) && item.getHasAuth())
@ -314,8 +317,14 @@ public class ExternalSelectDataPersist extends BaseFieldDataPersist {
protected List<Specification> specifications(ExternalSelectAuthDataPersist item) { protected List<Specification> specifications(ExternalSelectAuthDataPersist item) {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isNull(item.getUrl())) .must(() -> !this.isEmpty(item.getUrl()))
.failOn(ExternalSelectAuthDataPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalSelectAuthDataPersist._url}, LocaleContextHolder.getLocale())) .failOn(ExternalSelectAuthDataPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalSelectAuthDataPersist._url}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getMethod()))
.failOn(ExternalSelectAuthDataPersist._method).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalSelectAuthDataPersist._method}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getType()))
.failOn(ExternalSelectAuthDataPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalSelectAuthDataPersist._type}, LocaleContextHolder.getLocale()))
); );
} }
} }

View File

@ -63,8 +63,15 @@ public class UploadDataPersist extends BaseFieldDataPersist {
List<Specification> specifications = getBaseSpecifications(item); List<Specification> specifications = getBaseSpecifications(item);
specifications.addAll(Arrays.asList( specifications.addAll(Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isNull(item.getTypes())) .must(() -> !this.isListNullOrEmpty(item.getTypes()))
.failOn(UploadDataPersist._types).failWith(messageSource.getMessage("Validation_Required", new Object[]{UploadDataPersist._types}, LocaleContextHolder.getLocale())), .failOn(UploadDataPersist._types).failWith(messageSource.getMessage("Validation_Required", new Object[]{UploadDataPersist._types}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getMaxFileSizeInMB()))
.failOn(UploadDataPersist._maxFileSizeInMB).failWith(messageSource.getMessage("Validation_Required", new Object[]{UploadDataPersist._maxFileSizeInMB}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isNull(item.getMaxFileSizeInMB()))
.must(() -> item.getMaxFileSizeInMB() > 0 && item.getMaxFileSizeInMB() <= 10)
.failOn(UploadDataPersist._maxFileSizeInMB).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{UploadDataPersist._maxFileSizeInMB}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getTypes())) .iff(() -> !this.isNull(item.getTypes()))
.on(UploadDataPersist._types) .on(UploadDataPersist._types)

View File

@ -34,12 +34,12 @@
<div class="row"> <div class="row">
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field"> <mat-form-field *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field">
<input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MIN' | translate}}" type="number" [formControl]="form.get('multiplicity').get('min')" required> <input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MIN' | translate}}" type="number" [formControl]="form.get('multiplicity').get('min')">
<mat-error *ngIf="form.get('multiplicity').get('min').hasError('backendError')">{{form.get('multiplicity').get('min').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('min').hasError('backendError')">{{form.get('multiplicity').get('min').getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.get('multiplicity').get('min').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('min').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pr-0 underline-line-field"> <mat-form-field *ngIf="isMultiplicityEnabled" class="col pr-0 underline-line-field">
<input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MAX' | translate}}" type="number" [formControl]="this.form.get('multiplicity').get('max')" required> <input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MAX' | translate}}" type="number" [formControl]="this.form.get('multiplicity').get('max')">
<mat-error *ngIf="form.get('multiplicity').get('max').hasError('backendError')">{{form.get('multiplicity').get('max').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('max').hasError('backendError')">{{form.get('multiplicity').get('max').getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.get('multiplicity').get('max').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('max').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
@ -65,7 +65,8 @@
<!-- FIELDS --> <!-- FIELDS -->
<div #inputs transition-group class="col-12" *ngIf="hasFocus" [@fade-in]> <div #inputs transition-group class="col-12" *ngIf="hasFocus" [@fade-in]>
<div *ngFor="let field of fieldsArray.controls; let i=index;" class="row bg-white field-input mt-3" (click)="setTargetField(field)" transition-group-item> <div *ngFor="let field of fieldsArray.controls; let i=index;" class="row bg-white field-input mt-3" (click)="setTargetField(field)" transition-group-item>
<app-description-template-editor-field-component class="col-12" [form]="field" [showOrdinal]="false" [indexPath]="indexPath + 'f' + i" [viewOnly]="viewOnly" [expandView]="hasFocus" [canBeDeleted]="fieldsArray.length !=1" (delete)="deleteField(i)"> <app-description-template-editor-field-component class="col-12" [form]="field" [showOrdinal]="false" [indexPath]="indexPath + 'f' + i" [viewOnly]="viewOnly" [expandView]="hasFocus" [canBeDeleted]="fieldsArray.length !=1"
[validationErrorModel]="validationErrorModel" [rootPath]="rootPath" (delete)="deleteField(i)">
<div class="arrows mt-2"> <div class="arrows mt-2">
<ul class="list-unstyled list-inline d-flex align-items-center"> <ul class="list-unstyled list-inline d-flex align-items-center">
<li *ngIf="canGoUp(i)" class="text-muted"> <li *ngIf="canGoUp(i)" class="text-muted">

View File

@ -28,6 +28,7 @@ import { debounceTime, delay, map, takeUntil, tap } from 'rxjs/operators';
import { GENERAL_ANIMATIONS } from '../../animations/animations'; import { GENERAL_ANIMATIONS } from '../../animations/animations';
import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators'; import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators';
import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel, DescriptionTemplateSectionEditorModel } from '../../description-template-editor.model'; import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel, DescriptionTemplateSectionEditorModel } from '../../description-template-editor.model';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-description-template-editor-composite-field-component', selector: 'app-description-template-editor-composite-field-component',
@ -46,6 +47,8 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
@Input() numbering: string; @Input() numbering: string;
@Input() hasFocus: boolean = false; @Input() hasFocus: boolean = false;
@ViewChild("inputs") inputs: TransitionGroupComponent; @ViewChild("inputs") inputs: TransitionGroupComponent;
@Input() validationErrorModel: ValidationErrorModel;
@Input() rootPath: string;
showPreview: boolean = true; showPreview: boolean = true;
previewDirty: boolean = false; previewDirty: boolean = false;

View File

@ -12,6 +12,7 @@
| |
translate}}</mat-option> translate}}</mat-option>
</mat-select> </mat-select>
<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-form-field> </mat-form-field>
@ -22,6 +23,7 @@
<mat-option [value]="'true'">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.CHECKED' | translate}}</mat-option> <mat-option [value]="'true'">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.CHECKED' | translate}}</mat-option>
<mat-option [value]="'false'">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.UNCHECKED' | translate}}</mat-option> <mat-option [value]="'false'">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.CHECK-BOX.UNCHECKED' | translate}}</mat-option>
</mat-select> </mat-select>
<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-form-field> </mat-form-field>
@ -32,6 +34,7 @@
<mat-option [value]="null">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate }}</mat-option> <mat-option [value]="null">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate }}</mat-option>
<mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option> <mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option>
</mat-select> </mat-select>
<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-form-field> </mat-form-field>
@ -39,6 +42,7 @@
<mat-form-field class="col-md-12" *ngIf="fieldType === descriptionTemplateFieldTypeEnum.FREE_TEXT"> <mat-form-field class="col-md-12" *ngIf="fieldType === descriptionTemplateFieldTypeEnum.FREE_TEXT">
<mat-label>{{placeHolder}}</mat-label> <mat-label>{{placeHolder}}</mat-label>
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form">
<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-form-field> </mat-form-field>
@ -49,6 +53,7 @@
<mat-option [value]="null">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate}}</mat-option> <mat-option [value]="null">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.NONE' | translate}}</mat-option>
<mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option> <mat-option *ngFor="let opt of formArrayOptions['controls']" [value]="opt.get('value').value">{{opt.get('label').value}}</mat-option>
</mat-select> </mat-select>
<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-form-field> </mat-form-field>
@ -56,6 +61,7 @@
<mat-form-field class="col-md-12" *ngIf="fieldType === descriptionTemplateFieldTypeEnum.TEXT_AREA"> <mat-form-field class="col-md-12" *ngIf="fieldType === descriptionTemplateFieldTypeEnum.TEXT_AREA">
<mat-label>{{placeHolder}}</mat-label> <mat-label>{{placeHolder}}</mat-label>
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form">
<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-form-field> </mat-form-field>
@ -63,6 +69,7 @@
<mat-form-field class="col-md-12" *ngIf="fieldType === descriptionTemplateFieldTypeEnum.RICH_TEXT_AREA"> <mat-form-field class="col-md-12" *ngIf="fieldType === descriptionTemplateFieldTypeEnum.RICH_TEXT_AREA">
<mat-label>{{placeHolder}}</mat-label> <mat-label>{{placeHolder}}</mat-label>
<input matInput type="text" [placeholder]="placeHolder" [formControl]="form"> <input matInput type="text" [placeholder]="placeHolder" [formControl]="form">
<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-form-field> </mat-form-field>
@ -73,6 +80,7 @@
<input matInput [placeholder]="placeHolder" class="table-input" [matDatepicker]="date" [formControl]="form"> <input matInput [placeholder]="placeHolder" class="table-input" [matDatepicker]="date" [formControl]="form">
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle> <mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
<mat-datepicker #date></mat-datepicker> <mat-datepicker #date></mat-datepicker>
<mat-error *ngIf="form.hasError('backendError')">{{form.getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}} <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>

View File

@ -77,7 +77,7 @@
<mat-form-field class="col-md-6"> <mat-form-field class="col-md-6">
<mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}}</mat-label> <mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-AUTOCOMPLETE-URL' | translate}}</mat-label>
<input matInput [formControl]="singleForm.get('auth').get('url')"> <input matInput [formControl]="singleForm.get('auth').get('url')">
<mat-error *ngIf="singleForm.get('auth').get('method').hasError('backendError')">{{singleForm.get('auth').get('method').getError('backendError').message}}</mat-error> <mat-error *ngIf="singleForm.get('auth').get('url').hasError('backendError')">{{singleForm.get('auth').get('url').getError('backendError').message}}</mat-error>
<mat-error *ngIf="singleForm.get('auth').get('url').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="singleForm.get('auth').get('url').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field class="col-md-6"> <mat-form-field class="col-md-6">

View File

@ -4,6 +4,7 @@ import { DescriptionTemplateExternalSelectSourceEditorModel } from '../../../des
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { DescriptionTemplateExternalSelectHttpMethodType } from '@app/core/common/enum/description-template-external-select-http-method-type'; import { DescriptionTemplateExternalSelectHttpMethodType } from '@app/core/common/enum/description-template-external-select-http-method-type';
import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum/description-template-external-select-auth-type'; import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum/description-template-external-select-auth-type';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-description-template-editor-external-select-field-component', selector: 'app-description-template-editor-external-select-field-component',
@ -13,6 +14,9 @@ import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum
export class DescriptionTemplateEditorExternalSelectFieldComponent implements OnInit { export class DescriptionTemplateEditorExternalSelectFieldComponent implements OnInit {
@Input() form: UntypedFormGroup; @Input() form: UntypedFormGroup;
@Input() validationErrorModel: ValidationErrorModel;
@Input() rootPath: string;
methodTypeValues = this.enumUtils.getEnumValues<DescriptionTemplateExternalSelectHttpMethodType>(DescriptionTemplateExternalSelectHttpMethodType); methodTypeValues = this.enumUtils.getEnumValues<DescriptionTemplateExternalSelectHttpMethodType>(DescriptionTemplateExternalSelectHttpMethodType);
authTypeValues = this.enumUtils.getEnumValues<DescriptionTemplateExternalSelectAuthType>(DescriptionTemplateExternalSelectAuthType); authTypeValues = this.enumUtils.getEnumValues<DescriptionTemplateExternalSelectAuthType>(DescriptionTemplateExternalSelectAuthType);
@ -24,7 +28,9 @@ export class DescriptionTemplateEditorExternalSelectFieldComponent implements On
} }
addSource() { addSource() {
(<UntypedFormArray>this.form.get('data').get('sources')).push(new DescriptionTemplateExternalSelectSourceEditorModel().buildForm()); const externalDataset = new DescriptionTemplateExternalSelectSourceEditorModel(this.validationErrorModel);
const externalSelectArray = this.form.get('data').get('sources') as UntypedFormArray;
externalSelectArray.push(externalDataset.buildForm({rootPath: this.rootPath + 'data.sources[' + externalSelectArray.length + '].'}));
} }
removeSource(index: number) { removeSource(index: number) {

View File

@ -18,13 +18,13 @@
<div *ngFor="let option of form.get('data').get('options')['controls'] index as i" class="row"> <div *ngFor="let option of form.get('data').get('options')['controls'] index as i" class="row">
<mat-form-field class="col"> <mat-form-field class="col">
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}}</mat-label> <mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}}</mat-label>
<input matInput type="string" [formControl]="this.form.get('data').get('options').get(''+i).get('label')"> <input matInput type="string" [formControl]="option.get('label')">
<mat-error *ngIf="form.get('data').get('options').get(''+i).get('label').hasError('backendError')">{{form.get('data').get('options').get(''+i).get('label').getError('backendError').message}}</mat-error> <mat-error *ngIf="option.get('label').hasError('backendError')">{{option.get('label').getError('backendError').message}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field class="col"> <mat-form-field class="col">
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}}</mat-label> <mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}}</mat-label>
<input matInput type="string" [formControl]="this.form.get('data').get('options').get(''+i).get('value')"> <input matInput type="string" [formControl]="option.get('value')">
<mat-error *ngIf="form.get('data').get('options').get(''+i).get('value').hasError('backendError')">{{form.get('data').get('options').get(''+i).get('value').getError('backendError').message}}</mat-error> <mat-error *ngIf="option.get('value').hasError('backendError')">{{option.get('value').getError('backendError').message}}</mat-error>
</mat-form-field> </mat-form-field>
<button mat-icon-button class="col-auto" (click)="deleteRow(i)" type="button" <button mat-icon-button class="col-auto" (click)="deleteRow(i)" type="button"
[disabled]="this.form.disabled"> [disabled]="this.form.disabled">

View File

@ -1,6 +1,7 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { DescriptionTemplateRadioBoxOptionEditorModel } from '../../../description-template-editor.model'; import { DescriptionTemplateRadioBoxOptionEditorModel } from '../../../description-template-editor.model';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-description-template-editor-radio-box-field-component', selector: 'app-description-template-editor-radio-box-field-component',
@ -10,14 +11,18 @@ import { DescriptionTemplateRadioBoxOptionEditorModel } from '../../../descripti
export class DescriptionTemplateEditorRadioBoxFieldComponent implements OnInit { export class DescriptionTemplateEditorRadioBoxFieldComponent implements OnInit {
@Input() form: UntypedFormGroup; @Input() form: UntypedFormGroup;
@Input() validationErrorModel: ValidationErrorModel;
@Input() rootPath: string;
ngOnInit() { ngOnInit() {
} }
addNewRow() { addNewRow() {
const radioListOptions: DescriptionTemplateRadioBoxOptionEditorModel = new DescriptionTemplateRadioBoxOptionEditorModel(); const radioListOptions: DescriptionTemplateRadioBoxOptionEditorModel = new DescriptionTemplateRadioBoxOptionEditorModel(this.validationErrorModel);
if (!this.form.get('data').get('options')) { (<UntypedFormGroup>this.form.get('data')).addControl('options', new UntypedFormBuilder().array([])); } const selectOptionsArray = this.form.get('data').get('options') as UntypedFormArray;
(<UntypedFormArray>this.form.get('data').get('options')).push(radioListOptions.buildForm());
if (!selectOptionsArray) { (<UntypedFormGroup>this.form.get('data')).addControl('options', new UntypedFormBuilder().array([])); }
selectOptionsArray.push(radioListOptions.buildForm({rootPath: this.rootPath + 'data.options[' + selectOptionsArray.length + '].'}));
} }
deleteRow(intex: number) { deleteRow(intex: number) {

View File

@ -1,6 +1,7 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; import { UntypedFormArray, UntypedFormGroup } from '@angular/forms';
import { DescriptionTemplateSelectOptionEditorModel } from '../../../description-template-editor.model'; import { DescriptionTemplateSelectOptionEditorModel } from '../../../description-template-editor.model';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-description-template-editor-select-field-component', selector: 'app-description-template-editor-select-field-component',
@ -10,13 +11,16 @@ import { DescriptionTemplateSelectOptionEditorModel } from '../../../description
export class DescriptionTemplateEditorSelectFieldComponent implements OnInit { export class DescriptionTemplateEditorSelectFieldComponent implements OnInit {
@Input() form: UntypedFormGroup; @Input() form: UntypedFormGroup;
@Input() validationErrorModel: ValidationErrorModel;
@Input() rootPath: string;
ngOnInit() { ngOnInit() {
} }
addNewRow() { addNewRow() {
const selectOptions: DescriptionTemplateSelectOptionEditorModel = new DescriptionTemplateSelectOptionEditorModel(); const selectOptions: DescriptionTemplateSelectOptionEditorModel = new DescriptionTemplateSelectOptionEditorModel(this.validationErrorModel);
(<UntypedFormArray>this.form.get('data').get('options')).push(selectOptions.buildForm()); const selectOptionsArray = this.form.get('data').get('options') as UntypedFormArray;
selectOptionsArray.push(selectOptions.buildForm({rootPath: this.rootPath + 'data.options[' + selectOptionsArray.length + '].'}));
} }
deleteRow(intex: number) { deleteRow(intex: number) {

View File

@ -29,6 +29,8 @@
{{type.label}} {{type.label}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="form.get('data').get('types').dirty && form.get('data').get('types').hasError('required')">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.TYPES-REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('data').get('types').hasError('backendError')">{{form.get('data').get('types').getError('backendError').message}}</mat-error>
</mat-form-field> </mat-form-field>
<div class="col-12"> <div class="col-12">
@ -37,13 +39,13 @@
<div *ngIf="isCustomType(type.value.value)" class="row"> <div *ngIf="isCustomType(type.value.value)" class="row">
<mat-form-field class="col"> <mat-form-field class="col">
<mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-LABEL' | translate}}</mat-label> <mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-LABEL' | translate}}</mat-label>
<input matInput type="string" [formControl]="this.form.get('data').get('types').get(''+i).get('label')"> <input matInput type="string" [formControl]="type.get('label')">
<mat-error *ngIf="form.get('data').get('types').get(''+i).get('label').hasError('backendError')">{{form.get('data').get('types').get(''+i).get('label').getError('backendError').message}}</mat-error> <mat-error *ngIf="type.get('label').hasError('backendError')">{{type.get('label').getError('backendError').message}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field class="col"> <mat-form-field class="col">
<mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-VALUE' | translate}}</mat-label> <mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-UPLOAD-VALUE' | translate}}</mat-label>
<input matInput type="string" [formControl]="this.form.get('data').get('types').get(''+i).get('value')"> <input matInput type="string" [formControl]="type.get('value')">
<mat-error *ngIf="form.get('data').get('types').get(''+i).get('value').hasError('backendError')">{{form.get('data').get('types').get(''+i).get('value').getError('backendError').message}}</mat-error> <mat-error *ngIf="type.get('value').hasError('backendError')">{{type.get('value').getError('backendError').message}}</mat-error>
</mat-form-field> </mat-form-field>
<button mat-icon-button class="col-auto" (click)="deleteRow(i)" type="button" [disabled]="form.get('data').get('types').disabled"> <button mat-icon-button class="col-auto" (click)="deleteRow(i)" type="button" [disabled]="form.get('data').get('types').disabled">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>

View File

@ -3,6 +3,7 @@ import { UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGr
import { DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template'; import { DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template';
import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; import { ConfigurationService } from "@app/core/services/configuration/configuration.service";
import { DescriptionTemplateUploadOptionEditorModel } from '../../../description-template-editor.model'; import { DescriptionTemplateUploadOptionEditorModel } from '../../../description-template-editor.model';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-description-template-editor-upload-field-component', selector: 'app-description-template-editor-upload-field-component',
@ -45,6 +46,8 @@ export class DescriptionTemplateEditorUploadFieldComponent implements OnInit {
public typesFormControl = new UntypedFormControl(); public typesFormControl = new UntypedFormControl();
@Input() form: UntypedFormGroup; @Input() form: UntypedFormGroup;
@Input() validationErrorModel: ValidationErrorModel;
@Input() rootPath: string;
constructor(private configurationService: ConfigurationService) { } constructor(private configurationService: ConfigurationService) { }
@ -79,12 +82,13 @@ export class DescriptionTemplateEditorUploadFieldComponent implements OnInit {
} }
addNewRow(type: DescriptionTemplateUploadOption = null) { addNewRow(type: DescriptionTemplateUploadOption = null) {
const typeListOptions: DescriptionTemplateUploadOptionEditorModel = new DescriptionTemplateUploadOptionEditorModel(); const typesArray = this.form.get('data').get('types') as UntypedFormArray;
const typeListOptions: DescriptionTemplateUploadOptionEditorModel = new DescriptionTemplateUploadOptionEditorModel(this.validationErrorModel);
if (type != null) { if (type != null) {
typeListOptions.fromModel(type); typeListOptions.fromModel(type);
} }
(<UntypedFormGroup>this.form.get('data')).addControl('types', new UntypedFormBuilder().array([])); (<UntypedFormGroup>this.form.get('data')).addControl('types', new UntypedFormBuilder().array([]));
(<UntypedFormArray>this.form.get('data').get('types')).push(typeListOptions.buildForm()); typesArray.push(typeListOptions.buildForm({rootPath: this.rootPath + 'data.types[' + typesArray.length + '].'}));
} }
deleteRow(index: number) { deleteRow(index: number) {

View File

@ -184,7 +184,8 @@
</mat-checkbox> </mat-checkbox>
<!-- Default Value --> <!-- Default Value -->
<app-description-template-editor-default-value-component *ngIf="form.get('data')?.get('fieldType')?.value" class="col-6" [fieldType]="form.get('data').get('fieldType').value" [form]="this.form.get('defaultValue')" [formArrayOptions]="form.get('data')?.get('options')" [comboBoxType]="this.form.get('data')?.get('type')?.value" [internalDmpEntitiesType]="this.form.get('data')?.get('type')?.value" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}"> <app-description-template-editor-default-value-component *ngIf="form.get('data')?.get('fieldType')?.value" class="col-6" [fieldType]="form.get('data').get('fieldType').value" [form]="this.form.get('defaultValue')" [formArrayOptions]="form.get('data')?.get('options')" [comboBoxType]="this.form.get('data')?.get('type')?.value" [internalDmpEntitiesType]="this.form.get('data')?.get('type')?.value"
[validationErrorModel]= "validationErrorModel" placeHolder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.DEFAULT-VALUE' | translate}}">
</app-description-template-editor-default-value-component> </app-description-template-editor-default-value-component>
<div class="col-12"></div> <div class="col-12"></div>
<div class="col-auto mb-4 mt-2"> <div class="col-auto mb-4 mt-2">
@ -207,10 +208,10 @@
</div> </div>
<div class="row" [ngSwitch]="form.get('data')?.get('fieldType')?.value " *ngIf="expandView"> <div class="row" [ngSwitch]="form.get('data')?.get('fieldType')?.value " *ngIf="expandView">
<app-description-template-editor-external-select-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.EXTERNAL_SELECT" class="col-12" [form]="form"></app-description-template-editor-external-select-field-component> <app-description-template-editor-external-select-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.EXTERNAL_SELECT" class="col-12" [form]="form" [validationErrorModel]= "validationErrorModel" [rootPath]="rootPath"></app-description-template-editor-external-select-field-component>
<app-description-template-editor-select-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.SELECT" class="col-12" [form]="form"></app-description-template-editor-select-field-component> <app-description-template-editor-select-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.SELECT" class="col-12" [form]="form" [validationErrorModel]= "validationErrorModel" [rootPath]="rootPath"></app-description-template-editor-select-field-component>
<app-description-template-editor-radio-box-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.RADIO_BOX" class="col-12" [form]="form"></app-description-template-editor-radio-box-field-component> <app-description-template-editor-radio-box-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.RADIO_BOX" class="col-12" [form]="form" [validationErrorModel]= "validationErrorModel" [rootPath]="rootPath"></app-description-template-editor-radio-box-field-component>
<app-description-template-editor-upload-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.UPLOAD" class="col-12" [form]="form"></app-description-template-editor-upload-field-component> <app-description-template-editor-upload-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.UPLOAD" class="col-12" [form]="form" [validationErrorModel]= "validationErrorModel" [rootPath]="rootPath"></app-description-template-editor-upload-field-component>
<app-description-template-editor-label-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.BOOLEAN_DECISION" class="col-12" [form]="form"></app-description-template-editor-label-field-component> <app-description-template-editor-label-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.BOOLEAN_DECISION" class="col-12" [form]="form"></app-description-template-editor-label-field-component>
<app-description-template-editor-label-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.CHECK_BOX" class="col-12" [form]="form"></app-description-template-editor-label-field-component> <app-description-template-editor-label-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.CHECK_BOX" class="col-12" [form]="form"></app-description-template-editor-label-field-component>

View File

@ -25,6 +25,7 @@ import { BaseComponent } from '@common/base/base.component';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel } from '../../description-template-editor.model'; import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel } from '../../description-template-editor.model';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-description-template-editor-field-component', selector: 'app-description-template-editor-field-component',
@ -46,6 +47,8 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
@Input() canBeDeleted: boolean = true; @Input() canBeDeleted: boolean = true;
@Output() delete = new EventEmitter<void>(); @Output() delete = new EventEmitter<void>();
@Input() validationErrorModel: ValidationErrorModel;
@Input() rootPath: string;
readonly separatorKeysCodes: number[] = [ENTER, COMMA]; readonly separatorKeysCodes: number[] = [ENTER, COMMA];
@ -91,8 +94,9 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
} }
addNewRule() { addNewRule() {
const rule: DescriptionTemplateRuleEditorModel = new DescriptionTemplateRuleEditorModel(); const rule: DescriptionTemplateRuleEditorModel = new DescriptionTemplateRuleEditorModel(this.validationErrorModel);
(<UntypedFormArray>this.form.get('visibilityRules')).push(rule.buildForm()); const ruleArray = this.form.get('visibilityRules') as UntypedFormArray;
(<UntypedFormArray>this.form.get('visibilityRules')).push(rule.buildForm({rootPath: this.rootPath + 'visibilityRules[' + ruleArray.length +'].'}));
} }
get canApplyVisibility(): boolean { get canApplyVisibility(): boolean {
@ -214,7 +218,8 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
} }
} }
const form = (new DescriptionTemplateFieldEditorModel).fromModel(field).buildForm(); const form = (new DescriptionTemplateFieldEditorModel(this.validationErrorModel)).fromModel(field)
.buildForm({rootPath: this.rootPath});
const fields = this.form.parent as UntypedFormArray; const fields = this.form.parent as UntypedFormArray;

View File

@ -63,7 +63,9 @@
<app-description-template-editor-composite-field-component [form]="fieldset" <app-description-template-editor-composite-field-component [form]="fieldset"
[viewOnly]="viewOnly" [numbering]="numbering + '.'+ (i+1)" [viewOnly]="viewOnly" [numbering]="numbering + '.'+ (i+1)"
[hasFocus]="fieldset.get('id').value === selectedFieldSetId" [hasFocus]="fieldset.get('id').value === selectedFieldSetId"
[datasetProfileId]="datasetProfileId"> [datasetProfileId]="datasetProfileId"
[validationErrorModel]="validationErrorModel"
[rootPath]="rootPath">
</app-description-template-editor-composite-field-component> </app-description-template-editor-composite-field-component>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>

View File

@ -8,6 +8,7 @@ import { debounceTime } from 'rxjs/operators';
import { GENERAL_ANIMATIONS } from '../../animations/animations'; import { GENERAL_ANIMATIONS } from '../../animations/animations';
import { DescriptionTemplateFieldEditorModel, DescriptionTemplateFieldSetEditorModel } from '../../description-template-editor.model'; import { DescriptionTemplateFieldEditorModel, DescriptionTemplateFieldSetEditorModel } from '../../description-template-editor.model';
import { ToCEntry, ToCEntryType } from '../../table-of-contents/description-template-table-of-contents-entry'; import { ToCEntry, ToCEntryType } from '../../table-of-contents/description-template-table-of-contents-entry';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-description-template-editor-section-fieldset-component', selector: 'app-description-template-editor-section-fieldset-component',
@ -27,6 +28,8 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit
@Output() removeFieldSet = new EventEmitter<string>(); @Output() removeFieldSet = new EventEmitter<string>();
@Output() addNewFieldSet = new EventEmitter<UntypedFormGroup>(); @Output() addNewFieldSet = new EventEmitter<UntypedFormGroup>();
@Output() cloneFieldSet = new EventEmitter<UntypedFormGroup>(); @Output() cloneFieldSet = new EventEmitter<UntypedFormGroup>();
@Input() validationErrorModel: ValidationErrorModel;
@Input() rootPath: string;
idprefix = "id"; idprefix = "id";

View File

@ -5,7 +5,7 @@
<mat-form-field class="col-12"> <mat-form-field class="col-12">
<input matInput type="text" [placeholder]="('DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate)+ ' '+ ('DESCRIPTION-TEMPLATE-EDITOR.STEPS.SECTION-INFO.SECTION' | translate)"formControlName="title"> <input matInput type="text" [placeholder]="('DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate)+ ' '+ ('DESCRIPTION-TEMPLATE-EDITOR.STEPS.SECTION-INFO.SECTION' | translate)"formControlName="title">
<mat-error *ngIf="form.get('title').hasError('backendError')">{{form.get('title').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('title').hasError('backendError')">{{form.get('title').getError('backendError').message}}</mat-error>
<mat-error >{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.get('title').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<div class="heading col-12">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.SECTION-INFO.SECTION-DESCRIPTION' | translate}} </div> <div class="heading col-12">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.SECTION-INFO.SECTION-DESCRIPTION' | translate}} </div>
<div class="hint col-12">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.SECTION-INFO.SECTION-DESCRIPTION-HINT' | translate}}</div> <div class="hint col-12">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.SECTION-INFO.SECTION-DESCRIPTION-HINT' | translate}}</div>

View File

@ -30,7 +30,8 @@
</mat-select> </mat-select>
<mat-error>{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="ruleFormGroup.get('target').hasError('backendError')">{{ruleFormGroup.get('target').getError('backendError').message}}</mat-error>
<mat-error *ngIf="ruleFormGroup.get('target').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<div class="col-auto align-self-center"><button mat-icon-button type="button" (click)="deleteRule(i);" [disabled]="viewOnly"> <div class="col-auto align-self-center"><button mat-icon-button type="button" (click)="deleteRule(i);" [disabled]="viewOnly">

View File

@ -1,9 +1,11 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { AbstractControl, FormArray, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type'; import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type';
import { DescriptionTemplateRule } from '@app/core/model/description-template/description-template'; import { DescriptionTemplateRule } from '@app/core/model/description-template/description-template';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ToCEntryType } from '../../table-of-contents/description-template-table-of-contents-entry'; import { ToCEntryType } from '../../table-of-contents/description-template-table-of-contents-entry';
import { DescriptionTemplateRuleEditorModel } from '../../description-template-editor.model';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-description-template-editor-visibility-rule-component', selector: 'app-description-template-editor-visibility-rule-component',
@ -19,6 +21,7 @@ export class DescriptionTemplateEditorRuleComponent implements OnInit {
@Input() fieldTypeForCheck: DescriptionTemplateFieldType; @Input() fieldTypeForCheck: DescriptionTemplateFieldType;
@Input() formArrayOptionsForCheck: UntypedFormArray; @Input() formArrayOptionsForCheck: UntypedFormArray;
@Input() viewOnly: boolean; @Input() viewOnly: boolean;
@Input() validationErrorModel: ValidationErrorModel;
options: OptionItem[]; options: OptionItem[];
@ -41,6 +44,7 @@ export class DescriptionTemplateEditorRuleComponent implements OnInit {
deleteRule(index) { deleteRule(index) {
this.form.removeAt(index); this.form.removeAt(index);
// TODO akis reply validators fix
this.form.markAsDirty();//deactivate guard this.form.markAsDirty();//deactivate guard
} }

View File

@ -200,7 +200,8 @@
<div class="hint">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.PAGE-INFO.PAGE-NAME-HINT' | translate}}</div> <div class="hint">{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.PAGE-INFO.PAGE-NAME-HINT' | translate}}</div>
<mat-form-field> <mat-form-field>
<input type="text" matInput formControlName="title" [placeholder]="('DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) +' '+ ('DESCRIPTION-TEMPLATE-EDITOR.STEPS.PAGE-INFO.PAGE' |translate)"> <input type="text" matInput formControlName="title" [placeholder]="('DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) +' '+ ('DESCRIPTION-TEMPLATE-EDITOR.STEPS.PAGE-INFO.PAGE' |translate)">
<mat-error>{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="selectedTocEntry.form.get('title').hasError('backendError')">{{selectedTocEntry.form.get('title').getError('backendError').message}}</mat-error>
<mat-error *ngIf="selectedTocEntry.form.get('title').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
@ -212,7 +213,8 @@
</div> </div>
<div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)"> <div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)">
<app-description-template-editor-section-fieldset-component [tocentry]="selectedTocEntry" [viewOnly]="viewOnly" [datasetProfileId]="datasetProfileId" (addNewFieldSet)="addNewEntry({childType: tocEntryEnumValues.FieldSet,parent: {formGroup: $event}})" (removeFieldSet)="onRemoveEntry(_findTocEntryById($event, toCEntries))" (cloneFieldSet)="cloneFieldSet($event)" (selectedEntryId)="displayItem(_findTocEntryById($event, toCEntries))" (dataNeedsRefresh)="onDataNeedsRefresh()"> <app-description-template-editor-section-fieldset-component [tocentry]="selectedTocEntry" [viewOnly]="viewOnly" [datasetProfileId]="datasetProfileId" [validationErrorModel]="editorModel.validationErrorModel" [rootPath]="rootPath"
(addNewFieldSet)="addNewEntry({childType: tocEntryEnumValues.FieldSet,parent: {formGroup: $event}})" (removeFieldSet)="onRemoveEntry(_findTocEntryById($event, toCEntries))" (cloneFieldSet)="cloneFieldSet($event)" (selectedEntryId)="displayItem(_findTocEntryById($event, toCEntries))" (dataNeedsRefresh)="onDataNeedsRefresh()">
</app-description-template-editor-section-fieldset-component> </app-description-template-editor-section-fieldset-component>
</div> </div>
@ -225,6 +227,8 @@
<div class="row w-100 justify-content-center"> <div class="row w-100 justify-content-center">
<div class="col-auto"> <div class="col-auto">
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.PAGE-INFO.ACTIONS.NOTHING-HERE-HINT'| translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.PAGE-INFO.ACTIONS.NOTHING-HERE-HINT'| translate}}
<p *ngIf="formGroup.get('definition').get('pages').dirty && formGroup.get('definition').get('pages').hasError('required')">{{'DMP-BLUEPRINT-EDITOR.FIELDS-REQUIRED' | translate}}</p>
<p *ngIf="formGroup.get('definition').get('pages').hasError('backendError')">{{formGroup.get('definition').get('pages').getError('backendError').message}}</p>
</div> </div>
</div> </div>
<div class="row justify-content-center"> <div class="row justify-content-center">

View File

@ -70,6 +70,7 @@ 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();
rootPath: string = null;
// selectedSystemFields: Array<DescriptionTemplateSystemFieldType> = []; // selectedSystemFields: Array<DescriptionTemplateSystemFieldType> = [];
@ -571,18 +572,19 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
addNewEntry(tce: NewEntryType) { addNewEntry(tce: NewEntryType) {
const parent = tce.parent; const parent = tce.parent;
const pages = this.formGroup.get('definition').get('pages') as FormArray;
let pageIndex = -1;
// define entry type // define entry type
switch (tce.childType) { switch (tce.childType) {
case ToCEntryType.Page: case ToCEntryType.Page:
const pagesArray = (this.formGroup.get('definition').get('pages') as UntypedFormArray);
const page: DescriptionTemplatePageEditorModel = new DescriptionTemplatePageEditorModel(this.editorModel.validationErrorModel); const page: DescriptionTemplatePageEditorModel = new DescriptionTemplatePageEditorModel(this.editorModel.validationErrorModel);
page.id = Guid.create().toString(); page.id = Guid.create().toString();
if (isNaN(pagesArray.length)) { page.ordinal = 0; } else { page.ordinal = pagesArray.length; } if (isNaN(pages.length)) { page.ordinal = 0; } else { page.ordinal = pages.length; }
const pageForm = page.buildForm({ rootPath: 'definition.pages[' + pagesArray.length + '].' }); const pageForm = page.buildForm({ rootPath: 'definition.pages[' + pages.length + '].' });
// this.dataModel.pages.push(page); // this.dataModel.pages.push(page);
pagesArray.push(pageForm); pages.push(pageForm);
// this.form.updateValueAndValidity(); // this.form.updateValueAndValidity();
this.refreshToCEntries(); this.refreshToCEntries();
this.selectedTocEntry = this._findTocEntryById(pageForm.get('id').value, this.toCEntries); this.selectedTocEntry = this._findTocEntryById(pageForm.get('id').value, this.toCEntries);
@ -595,7 +597,16 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
let sectionsArray: UntypedFormArray; let sectionsArray: UntypedFormArray;
if (parent.type === ToCEntryType.Page) {//FIRST LEVEL SECTION if (parent.type === ToCEntryType.Page) {//FIRST LEVEL SECTION
sectionsArray = (this.formGroup.get('definition').get('pages') as FormArray).controls.find(x => x.get('id')?.value === parent.id).get('sections') as UntypedFormArray; for (let i = 0; i < pages?.length; i++) {
let page = pages.at(i);
let pageId = page.get('id').value;
if (pageId == parent.id) {
pageIndex = i;
break;
}
}
sectionsArray = pages.controls.find(x => x.get('id')?.value === parent.id).get('sections') as UntypedFormArray;
try { try {
const max = sectionsArray.controls.map(control => control.get('ordinal').value) const max = sectionsArray.controls.map(control => control.get('ordinal').value)
.reduce((a, b) => Math.max(a, b)); .reduce((a, b) => Math.max(a, b));
@ -605,10 +616,26 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
section.ordinal = sectionsArray.length; section.ordinal = sectionsArray.length;
} }
sectionsArray.push(section.buildForm({ rootPath: 'definition.sections[' + sectionsArray.length + '].' })); sectionsArray.push(section.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].sections[' + sectionsArray.length + '].' }));
// this.form.updateValueAndValidity(); // this.form.updateValueAndValidity();
} else if (parent.type == ToCEntryType.Section) { //SUBSECTION OF SECTION } else if (parent.type == ToCEntryType.Section) { //SUBSECTION OF SECTION
let sectionIndexes: number[] = [];
for (let j = 0; j < pages.length; j++) {
const parentSections = pages.at(j).get('sections') as UntypedFormArray;
sectionIndexes = this.findSectionIndex(parentSections, parent.id);
if (sectionIndexes && sectionIndexes.length > 0){
pageIndex = j;
break;
}
}
let parentSectionRootPath = '';
if(sectionIndexes.length > 0){
sectionIndexes.forEach(index => {
parentSectionRootPath = parentSectionRootPath + 'sections[' + index +'].'
});
}
sectionsArray = parent.form.get('sections') as UntypedFormArray; sectionsArray = parent.form.get('sections') as UntypedFormArray;
//adding page parent MAYBE NOT NEEDED //adding page parent MAYBE NOT NEEDED
@ -619,7 +646,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
section.ordinal = sectionsArray.length; section.ordinal = sectionsArray.length;
} }
sectionsArray.push(section.buildForm({ rootPath: 'definition.sections[' + sectionsArray.length + '].' })); sectionsArray.push(section.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].' + parentSectionRootPath + 'sections[' + sectionsArray.length + '].' }));
// (child.form.parent as FormArray).push(section.buildForm()); // (child.form.parent as FormArray).push(section.buildForm());
} else { } else {
@ -638,36 +665,31 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
break; break;
case ToCEntryType.FieldSet: case ToCEntryType.FieldSet:
let sectionIndex = -1; let sectionIndexes: number[] = [];
const pages = (this.formGroup.get('definition').get('pages') as UntypedFormArray);
for (let j = 0; j < pages.length; j++) { for (let j = 0; j < pages.length; j++) {
const sections = (this.formGroup.get('definition').get('pages') as UntypedFormArray).at(j).get('sections') as UntypedFormArray; const parentSections = pages.at(j).get('sections') as UntypedFormArray;
for (let i = 0; i < sections?.length; i++) { sectionIndexes = this.findSectionIndex(parentSections, parent.id);
if (sectionIndexes && sectionIndexes.length > 0){
let section = sections.at(i); pageIndex = j;
let sectionId = section.get('id').value;
if (sectionId == parent.id) {
sectionIndex = i;
break; break;
} }
} }
let parentSectionRootPath = '';
if(sectionIndexes.length > 0){
sectionIndexes.forEach(index => {
parentSectionRootPath = parentSectionRootPath + 'sections[' + index +'].'
});
} }
if (sectionIndex > -1) { if (sectionIndexes.length > 0) {
//create one field form fieldset //create one field form fieldset
const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(this.editorModel.validationErrorModel); const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(this.editorModel.validationErrorModel);
field.id = Guid.create().toString(); field.id = Guid.create().toString();
field.ordinal = 0;//first filed in the fields list field.ordinal = 0;//first filed in the fields list
// const fieldForm = field.buildForm();
// fieldForm.setValidators(this.customFieldValidator());
// fieldForm.get('viewStyle').get('renderStyle').setValidators(Validators.required);
// fieldSet.fields.push(field);
// field.ordinal = fieldSet.fields.length-1;
const fieldSetsArray = parent.form.get('fieldSets') as UntypedFormArray const fieldSetsArray = parent.form.get('fieldSets') as UntypedFormArray
const fieldForm = field.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fieldSets[' + fieldSetsArray.length + '].fields[' + 0 + '].' }); //store rootPath for next levels/components
this.rootPath = 'definition.pages['+ pageIndex +'].'+ parentSectionRootPath+ 'fieldSets[' + fieldSetsArray.length + '].fields[' + 0 + '].';
const fieldForm = field.buildForm({ rootPath: this.rootPath});
//give fieldset id and ordinal //give fieldset id and ordinal
const fieldSet: DescriptionTemplateFieldSetEditorModel = new DescriptionTemplateFieldSetEditorModel(this.editorModel.validationErrorModel); const fieldSet: DescriptionTemplateFieldSetEditorModel = new DescriptionTemplateFieldSetEditorModel(this.editorModel.validationErrorModel);
@ -680,7 +702,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
} catch { } catch {
fieldSet.ordinal = fieldSetsArray.length; fieldSet.ordinal = fieldSetsArray.length;
} }
const fieldsetForm = fieldSet.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].fieldSets[' + fieldSetsArray.length + '].' }); const fieldsetForm = fieldSet.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].' + parentSectionRootPath + 'fieldSets[' + fieldSetsArray.length + '].' });
(fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm); (fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm);
fieldSetsArray.push(fieldsetForm); fieldSetsArray.push(fieldsetForm);
@ -699,6 +721,26 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
this.formGroup.updateValueAndValidity(); this.formGroup.updateValueAndValidity();
} }
private findSectionIndex(sectionFormArray: UntypedFormArray, parentId: string) : number[]{
for (let i = 0; i < sectionFormArray?.length; i++) {
let sectionFormGroup = sectionFormArray.at(i);
let sectionId = sectionFormGroup.get('id').value;
const parentSections = sectionFormGroup.get('sections') as UntypedFormArray;
if (sectionId == parentId) {
return [i];
} else if (parentSections && parentSections.length > 0){
const indexes: number[]= this.findSectionIndex(parentSections, parentId);
if (indexes && indexes.length > 0){
indexes.unshift(i);
return indexes;
}
}
}
return null;
}
onRemoveEntry(tce: ToCEntry) { onRemoveEntry(tce: ToCEntry) {
@ -719,12 +761,12 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
} }
private _deleteEntry(tce: ToCEntry) { private _deleteEntry(tce: ToCEntry) {
const pages = this.formGroup.get('definition').get('pages') as UntypedFormArray;
let pageIndex = -1;
//define entry type //define entry type
switch (tce.type) { switch (tce.type) {
case ToCEntryType.Page: case ToCEntryType.Page:
const pages = this.formGroup.get('definition').get('pages') as UntypedFormArray;
let pageIndex = -1;
//get the index //get the index
for (let i = 0; i < pages.length; i++) { for (let i = 0; i < pages.length; i++) {
let page = pages.at(i) as UntypedFormGroup; let page = pages.at(i) as UntypedFormGroup;
@ -739,23 +781,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
//remove page //remove page
this._updateSelectedItem(tce); this._updateSelectedItem(tce);
pages.removeAt(pageIndex); pages.removeAt(pageIndex);
//clean up sections of removed page
const sections = (this.formGroup.get('definition').get('sections') as UntypedFormArray);
const sectionsIndexToBeRemoved = [];
sections.controls.forEach((section, idx) => {
if (section.get('page').value === tce.id) {
sectionsIndexToBeRemoved.push(idx);
}
});
if (sectionsIndexToBeRemoved.length) {
sectionsIndexToBeRemoved.reverse().forEach(index => {
sections.removeAt(index);
});
}
//update page ordinals //update page ordinals
for (let i = 0; i < pages.length; i++) { for (let i = 0; i < pages.length; i++) {
@ -772,30 +797,29 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
case ToCEntryType.Section: case ToCEntryType.Section:
//FIRST LEVEL SECTION CASE //FIRST LEVEL SECTION CASE
let index = -1; let sectionIndex = -1;
for (let j = 0; j < pages.length; j++) {
const sections = pages.at(j).get('sections') as UntypedFormArray;
const sections = (this.formGroup.get('definition').get('sections') as UntypedFormArray); for (let i = 0; i < sections?.length; i++) {
for (let i = 0; i < sections.length; i++) {
let section = sections.at(i); let section = sections.at(i);
let sectionId = section.get('id').value; let sectionId = section.get('id').value;
if (sectionId == tce.id) { if (sectionId == tce.id) {
index = i; sectionIndex = i;
pageIndex = j;
break; break;
} }
} }
}
if (index >= 0) { //section found if (sectionIndex >= 0) { //section found
const sections = (this.formGroup.get('definition').get('sections') as UntypedFormArray); const sections = pages.at(pageIndex).get('sections') as UntypedFormArray;
//remove section //remove section
this._updateSelectedItem(tce); this._updateSelectedItem(tce);
sections.removeAt(index); sections.removeAt(sectionIndex);
//update ordinal //update ordinal
for (let i = 0; i < sections.length; i++) { for (let i = 0; i < sections.length; i++) {
@ -804,19 +828,42 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
} else {//NOT FOUND IN FIRST LEVEL CASE } else {//NOT FOUND IN FIRST LEVEL CASE
//LOOK FOR SUBSECTION CASE //LOOK FOR SUBSECTION CASE
let parentFormArray = tce.form.parent as UntypedFormArray; let parentSectionIndex = -1;
let sectionIndex = -1;
for (let j = 0; j < pages.length; j++) {
const parentSections = pages.at(j).get('sections') as UntypedFormArray;
for (let i = 0; i < parentFormArray.length; i++) { for (let i = 0; i < parentSections?.length; i++) {
let section = parentFormArray.at(i); const sections = (pages.at(j).get('sections') as UntypedFormArray).at(i).get('sections') as UntypedFormArray;
if (section.get('id').value == tce.id) { for (let k = 0; i < sections?.length; i++) {
index = i; let section = sections.at(i);
let sectionId = section.get('id').value;
if (sectionId == tce.id) {
sectionIndex = k;
parentSectionIndex = i;
pageIndex = j;
break; break;
} }
} }
if (index >= 0) { }
}
// let parentFormArray = tce.form.parent as UntypedFormArray;
// for (let i = 0; i < parentFormArray.length; i++) {
// let section = parentFormArray.at(i);
// if (section.get('id').value == tce.id) {
// index = i;
// break;
// }
// }
if (sectionIndex >= 0) {
this._updateSelectedItem(tce); this._updateSelectedItem(tce);
parentFormArray.removeAt(index); const parentFormArray = (pages.at(pageIndex).get('sections') as UntypedFormArray).at(parentSectionIndex).get('sections') as UntypedFormArray;
parentFormArray.removeAt(sectionIndex);
//update odrinal //update odrinal
@ -877,14 +924,30 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
this.selectedTocEntry = null; this.selectedTocEntry = null;
} else { } else {
const pages = this.formGroup.get('definition').get('pages') as UntypedFormArray;
//if first level section //if first level section
const firstLevelSections = (this.formGroup.get('definition').get('sections') as UntypedFormArray); // const firstLevelSections = (this.formGroup.get('definition').get('sections') as UntypedFormArray);
// let isFirstLevel: boolean = false;
// firstLevelSections.controls.forEach(section => {
// if (section.get('id').value === tce.id) {
// isFirstLevel = true;
// }
// });
let isFirstLevel: boolean = false; let isFirstLevel: boolean = false;
firstLevelSections.controls.forEach(section => { for (let j = 0; j < pages.length; j++) {
if (section.get('id').value === tce.id) { const sections = pages.at(j).get('sections') as UntypedFormArray;
for (let i = 0; i < sections?.length; i++) {
let section = sections.at(i);
let sectionId = section.get('id').value;
if (sectionId == tce.id) {
isFirstLevel = true; isFirstLevel = true;
break;
} }
}); }
}
let parentId = null; let parentId = null;
if (isFirstLevel) { if (isFirstLevel) {

View File

@ -18,7 +18,7 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D
language: string; language: string;
type: Guid; type: Guid;
status: DescriptionTemplateStatus = DescriptionTemplateStatus.Draft; status: DescriptionTemplateStatus = DescriptionTemplateStatus.Draft;
definition: DescriptionTemplateDefinitionEditorModel = new DescriptionTemplateDefinitionEditorModel(); definition: DescriptionTemplateDefinitionEditorModel = new DescriptionTemplateDefinitionEditorModel(this.validationErrorModel);
users: UserDescriptionTemplateEditorModel[] = []; users: UserDescriptionTemplateEditorModel[] = [];
permissions: string[]; permissions: string[];
@ -229,8 +229,8 @@ export class DescriptionTemplateDefinitionEditorModel implements DescriptionTemp
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}pages[${index}].` rootPath: `${rootPath}pages[${index}].`
}), context.getValidation('pages') })
) ), context.getValidation('pages').validators
), ),
}); });
} }
@ -311,8 +311,8 @@ export class DescriptionTemplatePageEditorModel implements DescriptionTemplatePa
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}sections[${index}].` rootPath: `${rootPath}sections[${index}].`
}), context.getValidation('sections') })
) ), context.getValidation('sections').validators
), ),
}); });
} }
@ -428,8 +428,8 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}sections[${index}].` rootPath: `${rootPath}sections[${index}].`
}), context.getValidation('sections') })
) ), context.getValidation('sections').validators
), ),
fieldSets: this.formBuilder.array( fieldSets: this.formBuilder.array(
(this.fieldSets ?? []).map( (this.fieldSets ?? []).map(
@ -437,8 +437,8 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}fieldSets[${index}].` rootPath: `${rootPath}fieldSets[${index}].`
}), context.getValidation('fieldSets') })
) ), context.getValidation('fieldSets').validators
) )
}); });
} }
@ -509,7 +509,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
description: string; description: string;
extendedDescription: string; extendedDescription: string;
additionalInformation: string; additionalInformation: string;
multiplicity: DescriptionTemplateMultiplicityEditorModel = new DescriptionTemplateMultiplicityEditorModel(); multiplicity: DescriptionTemplateMultiplicityEditorModel = new DescriptionTemplateMultiplicityEditorModel(this.validationErrorModel);
hasCommentField: boolean = false; hasCommentField: boolean = false;
fields: DescriptionTemplateFieldEditorModel[] = []; fields: DescriptionTemplateFieldEditorModel[] = [];
@ -567,8 +567,8 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}fields[${index}].` rootPath: `${rootPath}fields[${index}].`
}), context.getValidation('fields') })
) ), context.getValidation('fields').validators
) )
}); });
} }
@ -722,7 +722,7 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF
visibilityRules: DescriptionTemplateRuleEditorModel[] = []; visibilityRules: DescriptionTemplateRuleEditorModel[] = [];
validations: DescriptionTemplateFieldValidationType[] = []; validations: DescriptionTemplateFieldValidationType[] = [];
includeInExport: boolean = false; includeInExport: boolean = false;
data: DescriptionTemplateLabelDataEditorModel = new DescriptionTemplateLabelDataEditorModel(); data: DescriptionTemplateLabelDataEditorModel = new DescriptionTemplateLabelDataEditorModel(this.validationErrorModel);
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -1242,9 +1242,9 @@ export class DescriptionTemplateExternalSelectSourceEditorModel implements Descr
url: string; url: string;
method: string; method: string;
optionsRoot: string; optionsRoot: string;
sourceBinding: DescriptionTemplateExternalSelectSourceBindingEditorModel = new DescriptionTemplateExternalSelectSourceBindingEditorModel(); sourceBinding: DescriptionTemplateExternalSelectSourceBindingEditorModel = new DescriptionTemplateExternalSelectSourceBindingEditorModel(this.validationErrorModel);
hasAuth: boolean; hasAuth: boolean;
auth: DescriptionTemplateExternalSelectAuthDataEditorModel = new DescriptionTemplateExternalSelectAuthDataEditorModel(); auth: DescriptionTemplateExternalSelectAuthDataEditorModel = new DescriptionTemplateExternalSelectAuthDataEditorModel(this.validationErrorModel);
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor( constructor(
@ -1849,8 +1849,9 @@ export class DescriptionTemplateUploadDataEditorModel extends DescriptionTemplat
this.validationErrorModel this.validationErrorModel
).fromModel(item).buildForm({ ).fromModel(item).buildForm({
rootPath: `${rootPath}types[${index}].` rootPath: `${rootPath}types[${index}].`
}), context.getValidation('types') })
))); ), context.getValidation('types').validators
));
return formGroup; return formGroup;
} }

View File

@ -139,7 +139,7 @@
<div class="col-6"> <div class="col-6">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'REFERENCE-EDITOR.FIELDS.VALUE' | translate}}</mat-label> <mat-label>{{'REFERENCE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput type="text" name="value" [formControl]="field.get('value')" required> <input matInput type="text" name="value" [formControl]="field.get('value')">
<mat-error *ngIf="field.get('value').hasError('backendError')">{{field.get('value').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('value').hasError('backendError')">{{field.get('value').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>

View File

@ -220,7 +220,7 @@ export class FieldEditorModel implements FieldPersist {
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] }); baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
baseValidationArray.push({ key: 'dataType', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] }); baseValidationArray.push({ key: 'dataType', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] }); baseValidationArray.push({ key: 'value', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
baseContext.validation = baseValidationArray; baseContext.validation = baseValidationArray;
return baseContext; return baseContext;

View File

@ -574,7 +574,9 @@
"PRODUCED": "Produced dataset", "PRODUCED": "Produced dataset",
"REUSED": "Reused dataset", "REUSED": "Reused dataset",
"OTHER": "Other" "OTHER": "Other"
} },
"FIELD-LABEL": "Label",
"FIELD-MULTIPLE-SELECT": "Multiple Select"
}, },
"ERROR-MESSAGES": { "ERROR-MESSAGES": {
"FIELD-OTHER-SOURCES-REQUIRED": "At least one source must be provided.", "FIELD-OTHER-SOURCES-REQUIRED": "At least one source must be provided.",