Skip to content

Commit d12aa01

Browse files
committed
94301: Limit error propagation to concat groups
1 parent 744bcae commit d12aa01

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/app/shared/form/form.service.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ describe('FormService test suite', () => {
186186
expect(formGroup.controls.description.touched).toBe(true);
187187
});
188188

189-
it('should add errors to fields of group', () => {
189+
it('should add errors to fields of concat group', () => {
190+
(builderService as any).isConcatGroup.and.returnValue(true);
191+
190192
let control = controls.addressLocation;
191193
let model = formModel.find((mdl: DynamicFormControlModel) => mdl.id === 'addressLocation');
192194
let errorKeys: string[];
@@ -240,7 +242,9 @@ describe('FormService test suite', () => {
240242
expect(formGroup.controls.description.touched).toBe(false);
241243
});
242244

243-
it('should remove errors from fields of group', () => {
245+
it('should remove errors from fields of concat group', () => {
246+
(builderService as any).isConcatGroup.and.returnValue(true);
247+
244248
let control = controls.addressLocation;
245249
let model = formModel.find((mdl: DynamicFormControlModel) => mdl.id === 'addressLocation');
246250
let errorKeys: string[];

src/app/shared/form/form.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ export class FormService {
161161
field.setErrors(error);
162162
}
163163

164-
// if the field in question is a group, pass down the error to its fields
165-
if (field instanceof FormGroup && model instanceof DynamicFormGroupModel) {
164+
// if the field in question is a concat group, pass down the error to its fields
165+
if (field instanceof FormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) {
166166
model.group.forEach((subModel) => {
167167
const subField = field.controls[subModel.id];
168168

@@ -182,8 +182,8 @@ export class FormService {
182182
field.setErrors(error);
183183
}
184184

185-
// if the field in question is a group, clear the error from its fields
186-
if (field instanceof FormGroup && model instanceof DynamicFormGroupModel) {
185+
// if the field in question is a concat group, clear the error from its fields
186+
if (field instanceof FormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) {
187187
model.group.forEach((subModel) => {
188188
const subField = field.controls[subModel.id];
189189

src/app/shared/mocks/form-builder-service.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function getMockFormBuilderService(): FormBuilderService {
1919
isQualdropGroup: false,
2020
isModelInCustomGroup: true,
2121
isRelationGroup: true,
22+
isConcatGroup: false,
2223
hasArrayGroupValue: true,
2324
getTypeBindModel: new DsDynamicInputModel({
2425
name: 'dc.type',

0 commit comments

Comments
 (0)