From 313f5e3b3c2098a6a98395e6c1ba89149a2a942d Mon Sep 17 00:00:00 2001 From: amentis Date: Thu, 8 Feb 2024 18:47:19 +0200 Subject: [PATCH] description template validation changes --- ...-template-editor-external-select-field.component.ts | 6 +++--- ...iption-template-editor-radio-box-field.component.ts | 6 +++--- ...scription-template-editor-select-field.component.ts | 6 +++--- ...scription-template-editor-upload-field.component.ts | 6 +++--- .../description-template-editor-field.component.html | 10 +++++----- ...ption-template-editor-section-fieldset.component.ts | 8 ++++---- ...iption-template-editor-visibility-rule.component.ts | 4 ++-- .../editor/description-template-editor.component.ts | 9 +-------- 8 files changed, 24 insertions(+), 31 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-select/description-template-editor-external-select-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-select/description-template-editor-external-select-field.component.ts index c1d412f01..506183048 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-select/description-template-editor-external-select-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/external-select/description-template-editor-external-select-field.component.ts @@ -15,7 +15,7 @@ export class DescriptionTemplateEditorExternalSelectFieldComponent implements On @Input() form: UntypedFormGroup; @Input() validationErrorModel: ValidationErrorModel; - @Input() rootPath: string; + @Input() validationRootPath: string; methodTypeValues = this.enumUtils.getEnumValues(DescriptionTemplateExternalSelectHttpMethodType); authTypeValues = this.enumUtils.getEnumValues(DescriptionTemplateExternalSelectAuthType); @@ -30,14 +30,14 @@ export class DescriptionTemplateEditorExternalSelectFieldComponent implements On addSource() { 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 + '].'})); + externalSelectArray.push(externalDataset.buildForm({rootPath: this.validationRootPath + 'data.sources[' + externalSelectArray.length + '].'})); } removeSource(index: number) { (this.form.get('data').get('sources')).removeAt(index); DescriptionTemplateExternalSelectDataEditorModel.reapplyValidators({ formGroup: this.form?.get('data') as UntypedFormGroup, - rootPath: `${this.rootPath}data.`, + rootPath: `${this.validationRootPath}data.`, validationErrorModel: this.validationErrorModel }); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.ts index ac0984fc7..1af01042f 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.ts @@ -12,7 +12,7 @@ export class DescriptionTemplateEditorRadioBoxFieldComponent implements OnInit { @Input() form: UntypedFormGroup; @Input() validationErrorModel: ValidationErrorModel; - @Input() rootPath: string; + @Input() validationRootPath: string; ngOnInit() { } @@ -22,7 +22,7 @@ export class DescriptionTemplateEditorRadioBoxFieldComponent implements OnInit { const selectOptionsArray = this.form.get('data').get('options') as UntypedFormArray; if (!selectOptionsArray) { (this.form.get('data')).addControl('options', new UntypedFormBuilder().array([])); } - selectOptionsArray.push(radioListOptions.buildForm({rootPath: this.rootPath + 'data.options[' + selectOptionsArray.length + '].'})); + selectOptionsArray.push(radioListOptions.buildForm({rootPath: this.validationRootPath + 'data.options[' + selectOptionsArray.length + '].'})); } deleteRow(intex: number) { @@ -31,7 +31,7 @@ export class DescriptionTemplateEditorRadioBoxFieldComponent implements OnInit { DescriptionTemplateRadioBoxDataEditorModel.reapplyRadioBoxValidators({ formGroup: this.form.get('data') as UntypedFormGroup, - rootPath: `${this.rootPath}data.`, + rootPath: `${this.validationRootPath}data.`, validationErrorModel: this.validationErrorModel }); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/select/description-template-editor-select-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/select/description-template-editor-select-field.component.ts index a3e64aa28..538a8a7c5 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/select/description-template-editor-select-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/select/description-template-editor-select-field.component.ts @@ -12,7 +12,7 @@ export class DescriptionTemplateEditorSelectFieldComponent implements OnInit { @Input() form: UntypedFormGroup; @Input() validationErrorModel: ValidationErrorModel; - @Input() rootPath: string; + @Input() validationRootPath: string; ngOnInit() { } @@ -20,7 +20,7 @@ export class DescriptionTemplateEditorSelectFieldComponent implements OnInit { addNewRow() { const selectOptions: DescriptionTemplateSelectOptionEditorModel = new DescriptionTemplateSelectOptionEditorModel(this.validationErrorModel); const selectOptionsArray = this.form.get('data').get('options') as UntypedFormArray; - selectOptionsArray.push(selectOptions.buildForm({rootPath: this.rootPath + 'data.options[' + selectOptionsArray.length + '].'})); + selectOptionsArray.push(selectOptions.buildForm({rootPath: this.validationRootPath + 'data.options[' + selectOptionsArray.length + '].'})); } deleteRow(intex: number) { @@ -29,7 +29,7 @@ export class DescriptionTemplateEditorSelectFieldComponent implements OnInit { DescriptionTemplateSelectDataEditorModel.reapplySelectValidators({ formGroup: this.form?.get('data') as UntypedFormGroup, - rootPath: `${this.rootPath}data.`, + rootPath: `${this.validationRootPath}data.`, validationErrorModel: this.validationErrorModel }); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.ts index ae5af1f21..6337e1368 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.ts @@ -47,7 +47,7 @@ export class DescriptionTemplateEditorUploadFieldComponent implements OnInit { @Input() form: UntypedFormGroup; @Input() validationErrorModel: ValidationErrorModel; - @Input() rootPath: string; + @Input() validationRootPath: string; constructor(private configurationService: ConfigurationService) { } @@ -88,7 +88,7 @@ export class DescriptionTemplateEditorUploadFieldComponent implements OnInit { typeListOptions.fromModel(type); } (this.form.get('data')).addControl('types', new UntypedFormBuilder().array([])); - typesArray.push(typeListOptions.buildForm({rootPath: this.rootPath + 'data.types[' + typesArray.length + '].'})); + typesArray.push(typeListOptions.buildForm({rootPath: this.validationRootPath + 'data.types[' + typesArray.length + '].'})); } deleteRow(index: number) { @@ -98,7 +98,7 @@ export class DescriptionTemplateEditorUploadFieldComponent implements OnInit { { formGroup: this.form.get('data') as UntypedFormGroup, validationErrorModel: this.validationErrorModel, - rootPath: `${this.rootPath}data.`, + rootPath: `${this.validationRootPath}data.`, } ); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html index 00e7960ab..41198e6fd 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html @@ -202,7 +202,7 @@

{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.RULES-TITLE' | translate}}

- + @@ -210,10 +210,10 @@
- - - - + + + + diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts index f7a1406c5..f00c1c8e6 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.ts @@ -195,13 +195,13 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit } addFieldSetAfter(afterOrdinal: number, afterIndex: number): void { - const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(); + const field: DescriptionTemplateFieldEditorModel = new DescriptionTemplateFieldEditorModel(this.validationErrorModel); field.id = Guid.create().toString(); field.ordinal = 0;//first filed in the fields list - const fieldForm = field.buildForm(); + const fieldForm = field.buildForm({rootPath: this.validationRootPath + '.fieldSets[' + this.form.length + ']' + '.fields[' + 0 + '].'}); //give fieldset id and ordinal - const fieldSet: DescriptionTemplateFieldSetEditorModel = new DescriptionTemplateFieldSetEditorModel(); + const fieldSet: DescriptionTemplateFieldSetEditorModel = new DescriptionTemplateFieldSetEditorModel(this.validationErrorModel); const fieldSetId = Guid.create().toString(); fieldSet.id = fieldSetId; fieldSet.ordinal = afterOrdinal < 0 ? 0 : afterOrdinal; @@ -215,7 +215,7 @@ export class DescriptionTemplateEditorSectionFieldSetComponent implements OnInit ordinalControl.setValue(ordinalValue + 1); } }); - const fieldsetForm = fieldSet.buildForm(); + const fieldsetForm = fieldSet.buildForm({rootPath: this.validationRootPath + '.fieldSets[' + this.form.length + '].'}); (fieldsetForm.get('fields') as UntypedFormArray).push(fieldForm); const index = afterOrdinal < 0 ? 0 : afterIndex + 1; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.ts index d10646d34..4246446c5 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.ts @@ -22,7 +22,7 @@ export class DescriptionTemplateEditorRuleComponent implements OnInit { @Input() formArrayOptionsForCheck: UntypedFormArray; @Input() viewOnly: boolean; @Input() validationErrorModel: ValidationErrorModel; - @Input() rootPath: string; + @Input() validationRootPath: string; options: OptionItem[]; @@ -48,7 +48,7 @@ export class DescriptionTemplateEditorRuleComponent implements OnInit { this.form.controls?.forEach( (control, index) => DescriptionTemplateRuleEditorModel.reapplyValidators({ formGroup: control as UntypedFormGroup, - rootPath: `${this.rootPath}visibilityRules[${index}].`, + rootPath: `${this.validationRootPath}visibilityRules[${index}].`, validationErrorModel: this.validationErrorModel }) ); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index 2ccb3b3e6..ec7755438 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts @@ -70,7 +70,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor = new Map(); userFormControl = new FormControl(); - rootPath: string = null; // selectedSystemFields: Array = []; @@ -632,9 +631,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor