From d87c46445c408047892819f3391eb094ce92eda6 Mon Sep 17 00:00:00 2001 From: mchouliara Date: Fri, 6 Sep 2024 13:13:49 +0300 Subject: [PATCH] fix validation error visibility --- ...ription-template-editor-radio-box-field.component.html | 2 +- ...escription-template-editor-select-field.component.html | 2 +- ...escription-template-editor-upload-field.component.html | 2 +- .../description-template-editor-upload-field.component.ts | 4 ++-- .../field/description-template-editor-field.component.ts | 8 +++++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.html b/frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.html index 93deb4a65..88d6b7fff 100644 --- a/frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.html +++ b/frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.html @@ -2,7 +2,7 @@
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-TITLE' | translate}}
- + warning_amber {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED'| translate}} diff --git a/frontend/src/app/ui/admin/description-template/editor/components/field-type/select/description-template-editor-select-field.component.html b/frontend/src/app/ui/admin/description-template/editor/components/field-type/select/description-template-editor-select-field.component.html index d54eea9b9..8078c7ae8 100644 --- a/frontend/src/app/ui/admin/description-template/editor/components/field-type/select/description-template-editor-select-field.component.html +++ b/frontend/src/app/ui/admin/description-template/editor/components/field-type/select/description-template-editor-select-field.component.html @@ -3,7 +3,7 @@
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-SELECT-TITLE' | translate}}
- + warning_amber {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-SELECT-AT-LEAST-ONE-REQUIRED' | translate}} diff --git a/frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.html b/frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.html index fab81c081..001cd7ac7 100644 --- a/frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.html +++ b/frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.html @@ -28,8 +28,8 @@ {{type.label}} - {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.TYPES-REQUIRED' | translate}} {{form.get('data').get('types').getError('backendError').message}} + {{'COMMONS.VALIDATION.REQUIRED' | translate}}
diff --git a/frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.ts b/frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.ts index 6337e1368..518530845 100644 --- a/frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.ts +++ b/frontend/src/app/ui/admin/description-template/editor/components/field-type/upload/description-template-editor-upload-field.component.ts @@ -1,5 +1,5 @@ import { Component, Input, OnInit } from '@angular/core'; -import { UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; +import { FormControl, UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; import { DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template'; import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; import { DescriptionTemplateUploadDataEditorModel, DescriptionTemplateUploadOptionEditorModel } from '../../../description-template-editor.model'; @@ -43,7 +43,7 @@ export class DescriptionTemplateEditorUploadFieldComponent implements OnInit { ]; selected: string[] = []; - public typesFormControl = new UntypedFormControl(); + public typesFormControl = new FormControl([], Validators.required); @Input() form: UntypedFormGroup; @Input() validationErrorModel: ValidationErrorModel; diff --git a/frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts b/frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts index e842ee195..51fe572c8 100644 --- a/frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts +++ b/frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts @@ -124,9 +124,6 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple const field: DescriptionTemplateFieldPersist = this.form.getRawValue(); field.data.fieldType = type; - if (!this.canApplyVisibility) { - this.form.get('visibilityRules').reset(); - } // field.defaultValue = { // booleanValue: null, // dateValue: null, @@ -237,6 +234,11 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple this.form.setControl('data', form.controls.data) + + if (!this.canApplyVisibility) { + (this.form.get('visibilityRules') as UntypedFormArray).clear(); + } + this.reApplyValueChanges(); this.clearVisibilityRulesValue();