diff --git a/jest.config.js b/jest.config.js index a73aac7ea..a511fdc02 100644 --- a/jest.config.js +++ b/jest.config.js @@ -23,6 +23,7 @@ module.exports = { "!src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue", "!src/ux-components/alert/alert.vue", "!src/helpers/validation-rules.js", + "!src/common-components/question-chain/question-chain", // END ], // ! means exclude from coverage. testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], diff --git a/src/common-components/button-question/button-question.spec.js b/src/common-components/button-question/button-question.spec.js index b70304035..9cf75368e 100644 --- a/src/common-components/button-question/button-question.spec.js +++ b/src/common-components/button-question/button-question.spec.js @@ -112,7 +112,8 @@ describe("buttonQuestion.vue", () => { const wrapper = shallowMount(buttonQuestion, setupMocks({})); await wrapper.setProps({ answers: ["2022", "2021", "2020"], - isMultiSelect: false + isMultiSelect: false, + modelValue: [] }); const val = { checkValue: true, value: "2021", } wrapper.vm.handleCheckedChanged(val); diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index efc1cf051..f1c2ad98a 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -36,6 +36,7 @@ data-test="button" :validationRules="validationRules" :class="[suppressError ? 'alertError' : '']" + :clearOnUnmount="clearOnUnmount" /> @@ -84,6 +85,10 @@ export default { validationRules: String, suppressError: Boolean, useTextForValue: Boolean, + clearOnUnmount: { + type: Boolean, + default: true + } }, computed: { getFieldSetClasses() { @@ -133,17 +138,14 @@ export default { return answer.Name ? answer.Name : answer; }, handleCheckedChanged(val) { - - if(this.isMultiSelect && this.selectedValues) { - // Add or remove item to array of data to emit - const newSelectedValues = this.selectedValues; - + if(this.selectingInitiatesLoad) { + this.selectedValues = [val.value]; + } else { if(Array.isArray(this.selectedValues)) { + const newSelectedValues = this.selectedValues; val.checkValue ? newSelectedValues.push(val.value) : newSelectedValues.splice(newSelectedValues.indexOf(val.value), 1); this.selectedValues = newSelectedValues; } - } else { - this.selectedValues = [val.value]; } }, }, diff --git a/src/common-components/question-chain/question-chain.vue b/src/common-components/question-chain/question-chain.vue new file mode 100644 index 000000000..d605d7fde --- /dev/null +++ b/src/common-components/question-chain/question-chain.vue @@ -0,0 +1,119 @@ + + + \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 74ee110de..2b2d09859 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -46,6 +46,7 @@ const routes = [ // If the saved session has timed out, clear the session, execute 404 logic. if (getFunnelCookie() !== null && !isSavedSessionStillActive()) { + await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); await GoToFunnelStartOn404(next); } diff --git a/src/ux-components/list-button-horizontal/list-button-horizontal.vue b/src/ux-components/list-button-horizontal/list-button-horizontal.vue index eef4be443..dfd322cb3 100644 --- a/src/ux-components/list-button-horizontal/list-button-horizontal.vue +++ b/src/ux-components/list-button-horizontal/list-button-horizontal.vue @@ -78,6 +78,10 @@ export default { validationRules: String, selectedValues: [Array, String], hasError: Boolean, + clearOnUnmount: { + type: Boolean, + default: true + } }, data() { return { @@ -92,9 +96,11 @@ export default { : this.selectedValues[0]; } }, - unmounted() { // needed to clear this button's selectedValues if it is removed - this.checkValue = false; - this.handleCheckChange(); + unmounted() { // needed to clear this button's selectedValues if it is removed to keep validation in sync + if (this.clearOnUnmount) { + this.checkValue = false; + this.handleCheckChange(); + } }, methods: { displayLoader() { diff --git a/src/ux-components/list-button/list-button.vue b/src/ux-components/list-button/list-button.vue index f09384934..861619093 100644 --- a/src/ux-components/list-button/list-button.vue +++ b/src/ux-components/list-button/list-button.vue @@ -78,6 +78,10 @@ export default { validationRules: String, selectedValues: [Array, String], hasError: Boolean, + clearOnUnmount: { + type: Boolean, + default: true + } }, data() { return { @@ -92,9 +96,11 @@ export default { : this.selectedValues[0]; } }, - unmounted() { // needed to clear this button's selectedValues if it is removed - this.checkValue = false; - this.handleCheckChange(); + unmounted() { // needed to clear this button's selectedValues if it is removed to keep validation in sync + if (this.clearOnUnmount) { + this.checkValue = false; + this.handleCheckChange(); + } }, methods: { displayLoader() { diff --git a/src/ux-components/list-card/list-card.vue b/src/ux-components/list-card/list-card.vue index 264d7c299..88aad0b6a 100644 --- a/src/ux-components/list-card/list-card.vue +++ b/src/ux-components/list-card/list-card.vue @@ -86,6 +86,10 @@ export default { selectedValues: [Array, String], modelValue: Object, hasError: Boolean, + clearOnUnmount: { + type: Boolean, + default: true + } }, data() { return { @@ -99,9 +103,11 @@ export default { : this.selectedValues[0]; } }, - unmounted() { // needed to clear this button's selectedValues if it is removed - this.checkValue = false; - this.handleCheckChange(); + unmounted() { // needed to clear this button's selectedValues if it is removed to keep validation in sync + if (this.clearOnUnmount) { + this.checkValue = false; + this.handleCheckChange(); + } }, computed: { getLabelClasses() {