From c47d988bca3d0542a7632570c0bdef3dbf6b7ca3 Mon Sep 17 00:00:00 2001 From: Kim Shepherd Date: Thu, 18 Sep 2025 14:39:48 +0200 Subject: [PATCH] [TLC-1202] Disable fields hidden by type bind, so they are not validated --- .../ds-dynamic-type-bind-relation.service.ts | 25 +++++++++++++------ .../form/builder/parsers/field-parser.ts | 19 ++++++++++---- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service.ts index 03ca4b26cf..fd80e7ba5a 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service.ts @@ -13,6 +13,8 @@ import { DynamicFormControlModel, DynamicFormControlRelation, DynamicFormRelationService, + MATCH_DISABLED, + MATCH_ENABLED, MATCH_VISIBLE, OR_OPERATOR, } from '@ng-dynamic-forms/core'; @@ -217,9 +219,9 @@ export class DsDynamicTypeBindRelationService { } /** - * Helper function to construct a typeBindRelations array - * @param configuredTypeBindValues - */ + * Helper function to construct a typeBindRelations array + * @param configuredTypeBindValues + */ public getTypeBindRelations(configuredTypeBindValues: string[]): DynamicFormControlRelation[] { const bindValues = []; configuredTypeBindValues.forEach((value) => { @@ -228,11 +230,18 @@ export class DsDynamicTypeBindRelationService { value: value, }); }); - return [{ - match: MATCH_VISIBLE, - operator: OR_OPERATOR, - when: bindValues, - }]; + return [ + { + match: MATCH_ENABLED, + operator: OR_OPERATOR, + when: bindValues, + }, + { + match: MATCH_VISIBLE, + operator: OR_OPERATOR, + when: bindValues, + }, + ]; } } diff --git a/src/app/shared/form/builder/parsers/field-parser.ts b/src/app/shared/form/builder/parsers/field-parser.ts index c634c7d876..3ea371083d 100644 --- a/src/app/shared/form/builder/parsers/field-parser.ts +++ b/src/app/shared/form/builder/parsers/field-parser.ts @@ -5,6 +5,8 @@ import { import { DynamicFormControlLayout, DynamicFormControlRelation, + MATCH_DISABLED, + MATCH_ENABLED, MATCH_VISIBLE, OR_OPERATOR, } from '@ng-dynamic-forms/core'; @@ -381,11 +383,18 @@ export abstract class FieldParser { // Example: Field [x] will be VISIBLE if item type = book OR item type = book_part // // The opposing match value will be the dc.type for the workspace item - return [{ - match: MATCH_VISIBLE, - operator: OR_OPERATOR, - when: bindValues, - }]; + return [ + { + match: MATCH_ENABLED, + operator: OR_OPERATOR, + when: bindValues, + }, + { + match: MATCH_VISIBLE, + operator: OR_OPERATOR, + when: bindValues, + }, + ]; } protected hasRegex() {