Skip to content

Commit

Permalink
(fix) Clear values of hidden fields (#110)
Browse files Browse the repository at this point in the history
* (fix) clearing hidden field values

* (test) clearing hidden field values

* (fix) hide expression fail within obsgroup or repeating question type
  • Loading branch information
icrc-jofrancisco authored Jan 4, 2024
1 parent c7af85d commit 1f2271c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export class AfeFormArray
}

setValue(value: any) {
super.setValue(value);
if (value !== null) {
super.setValue(value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ describe('Control Hider Helper Service:', () => {
show: () => {},
hiders: [],
updateHiddenState: () => {},
setHidingFn: (newHider: Hider) => {}
setHidingFn: (newHider: Hider) => {},
setValue: (value: any) => {}
};

control.hide();
Expand All @@ -56,7 +57,8 @@ describe('Control Hider Helper Service:', () => {
},
hiders: [],
updateHiddenState: () => {},
setHidingFn: (newHider: Hider) => {}
setHidingFn: (newHider: Hider) => {},
setValue: (value: any) => {}
};

control.show();
Expand All @@ -76,7 +78,8 @@ describe('Control Hider Helper Service:', () => {
updateHiddenState: () => {},
setHidingFn: (newHider: Hider) => {
helper.setHiderForControl(control, newHider);
}
},
setValue: (value: any) => {}
};

const hider: Hider = {
Expand All @@ -103,7 +106,8 @@ describe('Control Hider Helper Service:', () => {
show: () => {},
hiders: [],
updateHiddenState: () => {},
setHidingFn: (newHider: Hider) => {}
setHidingFn: (newHider: Hider) => {},
setValue: (value: any) => {}
};

const hider: Hider = {
Expand Down Expand Up @@ -138,7 +142,8 @@ describe('Control Hider Helper Service:', () => {
updateHiddenState: () => {
helper.evaluateControlHiders(control);
},
setHidingFn: (newHider: Hider) => {}
setHidingFn: (newHider: Hider) => {},
setValue: (value: any) => {}
};

const hider1: Hider = {
Expand Down Expand Up @@ -186,7 +191,8 @@ describe('Control Hider Helper Service:', () => {
updateHiddenState: () => {
helper.evaluateControlHiders(control2);
},
setHidingFn: (newHider: Hider) => {}
setHidingFn: (newHider: Hider) => {},
setValue: (value: any) => {}
};

const hider4: Hider = {
Expand Down Expand Up @@ -230,7 +236,8 @@ describe('Control Hider Helper Service:', () => {
helper.evaluateControlHiders(control);
},
setHidingFn: (newHider: Hider) => {},
valueChanges: subject.asObservable()
valueChanges: subject.asObservable(),
setValue: (value: any) => {}
};

const hider1: Hider = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class HiderHelper {
hider.reEvaluateHidingExpression();
if (hider.toHide === true) {
hiddenValue = true;
control.setValue(null);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ describe('Obs Value Adapter: ', () => {
expect(value['onArt']).toEqual('a899b35c-1350-11df-a1f1-0026b9348838');
expect(value['tbadhere']).toEqual({
tb_adherence: 'a8b0f882-1350-11df-a1f1-0026b9348838',
adherenceTbTreatment: '',
adherenceTbOther: ''
adherenceTbTreatment: null,
adherenceTbOther: null
});

// check complex values
Expand Down

0 comments on commit 1f2271c

Please sign in to comment.