Skip to content

Commit 363fd38

Browse files
kshepherdgithub-actions[bot]
authored andcommitted
[TLC-1202] Disable fields hidden by type bind, so they are not validated
(cherry picked from commit c47d988)
1 parent 01cc3ab commit 363fd38

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
DynamicFormControlModel,
1414
DynamicFormControlRelation,
1515
DynamicFormRelationService,
16+
MATCH_DISABLED,
17+
MATCH_ENABLED,
1618
MATCH_VISIBLE,
1719
OR_OPERATOR,
1820
} from '@ng-dynamic-forms/core';
@@ -217,9 +219,9 @@ export class DsDynamicTypeBindRelationService {
217219
}
218220

219221
/**
220-
* Helper function to construct a typeBindRelations array
221-
* @param configuredTypeBindValues
222-
*/
222+
* Helper function to construct a typeBindRelations array
223+
* @param configuredTypeBindValues
224+
*/
223225
public getTypeBindRelations(configuredTypeBindValues: string[]): DynamicFormControlRelation[] {
224226
const bindValues = [];
225227
configuredTypeBindValues.forEach((value) => {
@@ -228,11 +230,18 @@ export class DsDynamicTypeBindRelationService {
228230
value: value,
229231
});
230232
});
231-
return [{
232-
match: MATCH_VISIBLE,
233-
operator: OR_OPERATOR,
234-
when: bindValues,
235-
}];
233+
return [
234+
{
235+
match: MATCH_ENABLED,
236+
operator: OR_OPERATOR,
237+
when: bindValues,
238+
},
239+
{
240+
match: MATCH_VISIBLE,
241+
operator: OR_OPERATOR,
242+
when: bindValues,
243+
},
244+
];
236245
}
237246

238247
}

src/app/shared/form/builder/parsers/field-parser.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
import {
66
DynamicFormControlLayout,
77
DynamicFormControlRelation,
8+
MATCH_DISABLED,
9+
MATCH_ENABLED,
810
MATCH_VISIBLE,
911
OR_OPERATOR,
1012
} from '@ng-dynamic-forms/core';
@@ -381,11 +383,18 @@ export abstract class FieldParser {
381383
// Example: Field [x] will be VISIBLE if item type = book OR item type = book_part
382384
//
383385
// The opposing match value will be the dc.type for the workspace item
384-
return [{
385-
match: MATCH_VISIBLE,
386-
operator: OR_OPERATOR,
387-
when: bindValues,
388-
}];
386+
return [
387+
{
388+
match: MATCH_ENABLED,
389+
operator: OR_OPERATOR,
390+
when: bindValues,
391+
},
392+
{
393+
match: MATCH_VISIBLE,
394+
operator: OR_OPERATOR,
395+
when: bindValues,
396+
},
397+
];
389398
}
390399

391400
protected hasRegex() {

0 commit comments

Comments
 (0)