From 9b5fe2adf491ef2b4c23f54559cf647b69c4bdba Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 18 Feb 2022 09:48:29 -0500 Subject: [PATCH 1/7] Side Door Options --- .../side-door-options/side-door-options.vue | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/layouts/vehicle-damage/side-door-options/side-door-options.vue diff --git a/src/layouts/vehicle-damage/side-door-options/side-door-options.vue b/src/layouts/vehicle-damage/side-door-options/side-door-options.vue new file mode 100644 index 000000000..9f4cd0105 --- /dev/null +++ b/src/layouts/vehicle-damage/side-door-options/side-door-options.vue @@ -0,0 +1,62 @@ + + + \ No newline at end of file From 8974aa464cbd377d3c3276f1cd24f73275bfa041 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Mon, 21 Feb 2022 15:48:23 -0500 Subject: [PATCH 2/7] CSR-269 reset fields and remove unused --- .../windshield-options/windshield-options.vue | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue index 8f57f61b7..db6569709 100644 --- a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue +++ b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue @@ -27,16 +27,6 @@ import windshieldChipCountQuestion from"@/layouts/vehicle-damage/windshield-opti import replaceOptionsQuestion from"@/layouts/vehicle-damage/replace-options-question/replace-options-question"; export default ({ name: "windshieldOptions", - data(){ - return { - chipCountQuestionText: String, - chipCountAnswersFromCms: Array, - - selectedWindshieldDamageType: null, - selectedWindshieldChipCount: null, - selectedWindshieldReplaceOptions: [], - } - }, props: { modelValue: Array, @@ -50,9 +40,6 @@ export default ({ initializeComponent(windshieldDamageTypeQuestionFromCms, windshieldChipCountQuestionFromCms, windshieldReplaceOptionsQuestionFromCms, windshieldAvailableReplacementOptions){ - this.chipCountQuestionText = windshieldChipCountQuestionFromCms.QuestionText; - this.chipCountAnswersFromCms = windshieldChipCountQuestionFromCms.Answers; - this.$refs.windshieldDamageTypeQuestion.initializeComponent(windshieldDamageTypeQuestionFromCms); this.$refs.windshieldChipCountQuestion.initializeComponent(windshieldChipCountQuestionFromCms); this.$refs.replaceOptionsQuestion.initializeComponent(windshieldReplaceOptionsQuestionFromCms, windshieldAvailableReplacementOptions); @@ -79,9 +66,7 @@ export default ({ return this.selectedValues.selectedWindshieldDamageType; }, set: function(newValue) { - this.selectedValues.selectedWindshieldChipCount = null; - this.selectedValues.selectedWindshieldReplaceOptions = null; - this.selectedValues = this.getWindshieldOptions(newValue, this.selectedWindshieldChipCountValues, this.selectedWindshieldReplaceOptionsValues); + this.selectedValues = this.getWindshieldOptions(newValue, null, null); } }, selectedWindshieldChipCountValues: { @@ -89,8 +74,7 @@ export default ({ return this.selectedValues.selectedChipCount; }, set: function(newValue) { - this.selectedValues.selectedWindshieldReplaceOptions = null; - this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, newValue, this.selectedWindshieldReplaceOptionsValues); + this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, newValue, null); } }, selectedWindshieldReplaceOptionsValues: { @@ -98,8 +82,7 @@ export default ({ return this.selectedValues.selectedWindshieldReplaceOptions; }, set: function(newValue) { - this.selectedValues.selectedWindshieldChipCount = null; - this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, this.selectedWindshieldChipCountValues, newValue); + this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, null, newValue); } }, isWindshieldDamageLocation() { From 1e68d8c293f23b31234374713279cd24c4b65e74 Mon Sep 17 00:00:00 2001 From: bmauger Date: Tue, 22 Feb 2022 09:57:31 -0500 Subject: [PATCH 3/7] CSR-341 Set z-index to fix overlap issue. --- .../list-button-horizontal/list-button-horizontal.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 35a01ded9..af7044a04 100644 --- a/src/ux-components/list-button-horizontal/list-button-horizontal.vue +++ b/src/ux-components/list-button-horizontal/list-button-horizontal.vue @@ -133,7 +133,7 @@ export default { height: 0; &:focus-visible + label { box-shadow: 0 0 0 2px $blue; - z-index: 3; + z-index: 2; } &:focus + label { box-shadow: 0 0 0 2px $blue; @@ -159,7 +159,7 @@ export default { &:hover { box-shadow: 0 0 0 4px $blue-300; cursor: pointer; - z-index: 3 !important; + z-index: 4 !important; } + p { display: none; From 830c4749555e1029636cc4e1ca308e7ee5a6e147 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 22 Feb 2022 10:28:02 -0500 Subject: [PATCH 4/7] Adding groupname to buttons buttonIDs to ensure they are unique, and adjusting button emits to emit button value --- .../button-question/button-question.spec.js | 4 ++-- .../button-question/button-question.vue | 14 ++++++++------ .../list-button-horizontal.spec.js | 6 +++--- .../list-button-horizontal.vue | 10 +++++----- src/ux-components/list-button/list-button.spec.js | 6 +++--- src/ux-components/list-button/list-button.vue | 10 +++++----- src/ux-components/list-card/list-card.spec.js | 8 ++++---- src/ux-components/list-card/list-card.vue | 10 +++++----- src/ux-components/radio/radio.vue | 2 +- 9 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/common-components/button-question/button-question.spec.js b/src/common-components/button-question/button-question.spec.js index 464fcf245..d36b73012 100644 --- a/src/common-components/button-question/button-question.spec.js +++ b/src/common-components/button-question/button-question.spec.js @@ -53,7 +53,7 @@ describe("buttonQuestion.vue", () => { answers: ["2022", "2021", "2020"], isMultiSelect: false }); - const val = {isChecked: true, buttonId: "2021", } + const val = {checkValue: true, value: "2021", } wrapper.vm.handleCheckedChanged(val); // Assert expect(wrapper.emitted()["update:modelValue"][0]).toEqual([["2021"]]); @@ -69,7 +69,7 @@ describe("buttonQuestion.vue", () => { isMultiSelect: true, } }); - const val = {isChecked: true, buttonId: "2019", } + const val = {checkValue: true, value: "2019", } wrapper.vm.handleCheckedChanged(val); // Assert expect(wrapper.emitted()["update:modelValue"][0]).toEqual([["2022", "2021", "2020", "2019"]]); diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index e8cf4a967..71d79b31f 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -12,7 +12,7 @@ v-for="answer in answers" :key="answer.Name ? answer.Name : answer" @isCheckedChanged="handleCheckedChanged" - :buttonID="answer.Name ? answer.Name : answer" + :buttonID="answer.Name ? groupName + '-' + answer.Name : groupName + '-' + answer" :value="answer.Name ? answer.Name : answer" :buttonLabel="answer.Text ? answer.Text : answer" :buttonLabelSubCopy="answer.SubText" @@ -29,7 +29,7 @@ :altText="answer.Name ? answer.Name : answer" screenReaderOnlyText="(opens new window)" :colLength="getColLength" - :selectedButtonIDs="selectedValues" + :selectedValues="selectedValues" data-test="button" :validationRules="validationRules" /> @@ -124,11 +124,13 @@ export default { handleCheckedChanged(val) { if(this.isMultiSelect) { // Add or remove item to array of data to emit - const newSelectedValues = this.selectedValues; - val.isChecked ? newSelectedValues.push(val.buttonId) : newSelectedValues.splice(newSelectedValues.indexOf(val.buttonId), 1); - this.selectedValues = newSelectedValues; + 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.buttonId]; + this.selectedValues = [val.value]; } }, }, diff --git a/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js b/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js index d1175620c..f95b378d7 100644 --- a/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js +++ b/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js @@ -161,7 +161,7 @@ describe("list-button-horizontal.vue", () => { propsData: { isRadioHorizontal: true, buttonLabel: "Windshield", - buttonID: "List Card Checkbox", + value: "List Card Checkbox", groupID: "radio-demo-1", groupName: "radio 1", buttonImage: "windshield-damage.svg", @@ -172,7 +172,7 @@ describe("list-button-horizontal.vue", () => { }); wrapper.vm.handleCheckChange(); // Assert - expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{buttonId: "List Card Checkbox", isChecked: Boolean}]); + expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{value: "List Card Checkbox", checkValue: Boolean}]); }); it("Should set checkValue data if selectedButtonIDs has value(s)", async () => { @@ -189,7 +189,7 @@ describe("list-button-horizontal.vue", () => { isWide: false, modelValue: ["List Card Checkbox"], isMultiSelect: false, - selectedButtonIDs: ["Car-Front"] + selectedValues: ["Car-Front"] }, }); // Assert 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 35a01ded9..b6f33676b 100644 --- a/src/ux-components/list-button-horizontal/list-button-horizontal.vue +++ b/src/ux-components/list-button-horizontal/list-button-horizontal.vue @@ -9,7 +9,7 @@ :type="isMultiSelect ? 'checkbox' : 'radio'" :id="buttonID" :name="groupName" - :value="buttonID" + :value="value" :aria-required="isRequired" :data-focus-target="groupName" v-model="checkValue" @@ -69,7 +69,7 @@ export default { type: String, default: "", }, - selectedButtonIDs: [Array, String], + selectedValues: [Array, String], hasError: Boolean, }, data() { @@ -79,8 +79,8 @@ export default { }; }, created(){ - if(this.selectedButtonIDs){ - this.checkValue = this.isMultiSelect ? this.selectedButtonIDs.includes(this.buttonID) : this.selectedButtonIDs[0]; + if(Array.isArray(this.selectedValues)){ + this.checkValue = this.isMultiSelect ? this.selectedValues.includes(this.value) : this.selectedValues[0]; } }, methods: { @@ -97,7 +97,7 @@ export default { handleCheckChange(newValue, oldValue){ const isInitialization = typeof(oldValue) === 'function'; if (!isInitialization) { - this.$emit('isCheckedChanged', { isChecked: this.checkValue, buttonId: this.buttonID.toString() }); + this.$emit('isCheckedChanged', { checkValue: this.checkValue, value: this.value.toString() }); } } }, diff --git a/src/ux-components/list-button/list-button.spec.js b/src/ux-components/list-button/list-button.spec.js index 1e900ce62..18707e45f 100644 --- a/src/ux-components/list-button/list-button.spec.js +++ b/src/ux-components/list-button/list-button.spec.js @@ -159,7 +159,7 @@ describe("list-button.vue", () => { propsData: { isRadioHorizontal: true, buttonLabel: "Windshield", - buttonID: "List Card Checkbox", + value: "List Card Checkbox", groupID: "radio-demo-1", groupName: "radio 1", buttonImage: "windshield-damage.svg", @@ -170,7 +170,7 @@ describe("list-button.vue", () => { }); wrapper.vm.handleCheckChange(); // Assert - expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{buttonId: "List Card Checkbox", isChecked: Boolean}]); + expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{value: "List Card Checkbox", checkValue: Boolean}]); }); it("Should set checkValue data if selectedButtonIDs has value(s)", async () => { @@ -186,7 +186,7 @@ describe("list-button.vue", () => { isRequired: true, isWide: false, modelValue: ["List Card Checkbox"], - selectedButtonIDs: ["Car-Front"] + selectedValues: ["Car-Front"] }, }); // Assert diff --git a/src/ux-components/list-button/list-button.vue b/src/ux-components/list-button/list-button.vue index 04a9c18e7..4727f9743 100644 --- a/src/ux-components/list-button/list-button.vue +++ b/src/ux-components/list-button/list-button.vue @@ -9,7 +9,7 @@ :type="isMultiSelect ? 'checkbox' : 'radio'" :id="buttonID" :name="groupName" - :value="buttonID" + :value="value" :aria-required="isRequired" :data-focus-target="groupName" v-model="checkValue" @@ -71,7 +71,7 @@ export default { type: [String, Number], default: "", }, - selectedButtonIDs: [Array, String], + selectedValues: [Array, String], hasError: Boolean, }, data() { @@ -81,8 +81,8 @@ export default { }; }, created(){ - if(this.selectedButtonIDs){ - this.checkValue = this.isMultiSelect ? this.selectedButtonIDs.includes(this.buttonID) : this.selectedButtonIDs[0]; + if(Array.isArray(this.selectedValues)){ + this.checkValue = this.isMultiSelect ? this.selectedValues.includes(this.value) : this.selectedValues[0]; } }, methods: { @@ -99,7 +99,7 @@ export default { handleCheckChange(newValue, oldValue){ const isInitialization = typeof(oldValue) === 'function'; if (!isInitialization) { - this.$emit('isCheckedChanged', { isChecked: this.checkValue, buttonId: this.buttonID.toString() }); + this.$emit('isCheckedChanged', { checkValue: this.checkValue, value: this.value.toString() }); } }, }, diff --git a/src/ux-components/list-card/list-card.spec.js b/src/ux-components/list-card/list-card.spec.js index 30af40ec3..a345c7b18 100644 --- a/src/ux-components/list-card/list-card.spec.js +++ b/src/ux-components/list-card/list-card.spec.js @@ -197,7 +197,7 @@ describe("list-card.vue", () => { propsData: { isRadioHorizontal: true, buttonLabel: "Windshield", - buttonID: "List Card Checkbox", + value: "List Card Checkbox", groupID: "radio-demo-1", groupName: "radio 1", buttonImage: "windshield-damage.svg", @@ -208,7 +208,7 @@ describe("list-card.vue", () => { }); wrapper.vm.handleCheckChange(); // Assert - expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{buttonId: "List Card Checkbox", isChecked: Boolean}]); + expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{value: "List Card Checkbox", checkValue: Boolean}]); }); it("Should set checkValue data if selectedButtonIDs has value(s)", async () => { @@ -217,14 +217,14 @@ describe("list-card.vue", () => { propsData: { isRadioHorizontal: true, buttonLabel: "Windshield", - buttonID: "List Card Checkbox", + value: "List Card Checkbox", groupID: "radio-demo-1", groupName: "radio 1", buttonImage: "windshield-damage.svg", isRequired: true, isWide: false, modelValue: ["List Card Checkbox"], - selectedButtonIDs: ["Car-Front"] + selectedValues: ["Car-Front"] }, }); // Assert diff --git a/src/ux-components/list-card/list-card.vue b/src/ux-components/list-card/list-card.vue index 1fe25c408..59518deb7 100644 --- a/src/ux-components/list-card/list-card.vue +++ b/src/ux-components/list-card/list-card.vue @@ -8,7 +8,7 @@ :type="isMultiSelect ? 'checkbox' : 'radio'" :id="buttonID" :name="groupName" - :value="buttonID" + :value="value" :aria-required="isRequired" :data-focus-target="groupName" @click="handleChange(value)" @@ -70,7 +70,7 @@ export default { }, colLength: String, validationRules: String, - selectedButtonIDs: [Array, String], + selectedValues: [Array, String], hasError: Boolean, }, data(){ @@ -79,8 +79,8 @@ export default { } }, created(){ - if(this.selectedButtonIDs){ - this.checkValue = this.isMultiSelect ? this.selectedButtonIDs.includes(this.buttonID) : this.selectedButtonIDs[0]; + if(Array.isArray(this.selectedValues)){ + this.checkValue = this.isMultiSelect ? this.selectedValues.includes(this.value) : this.selectedValues[0]; } }, computed: { @@ -100,7 +100,7 @@ export default { handleCheckChange(newValue, oldValue){ const isInitialization = typeof(oldValue) === 'function'; if (!isInitialization) { - this.$emit('isCheckedChanged', { isChecked: this.checkValue, buttonId: this.buttonID.toString() }); + this.$emit('isCheckedChanged', { checkValue: this.checkValue, value: this.value.toString() }); } } }, diff --git a/src/ux-components/radio/radio.vue b/src/ux-components/radio/radio.vue index aedead0eb..209b7ddab 100644 --- a/src/ux-components/radio/radio.vue +++ b/src/ux-components/radio/radio.vue @@ -54,7 +54,7 @@ export default { handleCheckChange(newValue, oldValue){ const isInitialization = typeof(oldValue) === 'function'; if (!isInitialization) { - this.$emit('isCheckedChanged', { isChecked: this.checkValue, buttonId: this.buttonID.toString() }); + this.$emit('isCheckedChanged', { checkValue: this.checkValue, value: this.value.toString() }); } } }, From 1dfee19cfd02515b2e24c9f06c22ef87b6c1b198 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 22 Feb 2022 10:29:16 -0500 Subject: [PATCH 5/7] Creating side-door-options component --- .../damage-location-question.spec.js | 2 +- .../damage-location-question.vue | 7 +- .../replace-options-question.spec.js | 2 +- .../replace-options-question.vue | 17 ++- .../side-door-options.spec.js | 124 ++++++++++++++++++ .../side-door-options/side-door-options.vue | 77 ++++++++++- .../vehicle-damage/vehicle-damage.spec.js | 44 ++----- src/layouts/vehicle-damage/vehicle-damage.vue | 20 +-- 8 files changed, 233 insertions(+), 60 deletions(-) create mode 100644 src/layouts/vehicle-damage/side-door-options/side-door-options.spec.js diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js index 01f063eef..92feec9b8 100644 --- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js +++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js @@ -41,7 +41,7 @@ describe("damage-location-question.vue", () => { damageLocationQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent, damageOptions, "car-group"); //Assert - expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'car-Windshield' }, { Name: 'car-SideDoor' } ]) + expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'Windshield' }, { Name: 'SideDoor' } ]) }); }); diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue index 58a74a31c..89b3244e3 100644 --- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue +++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue @@ -67,13 +67,18 @@ export default ({ } }, answersToDisplay(){ - return Array.isArray(this.answersFromCms) + const filteredAnswers = Array.isArray(this.answersFromCms) ? this.answersFromCms.filter(ans => { const name = ans.Name.split('-'); return name[0].toUpperCase() === store.getters.vehicle.category && this.damageOptionsMap[name[1]]; }) : []; + return filteredAnswers.map(ans => { + const newName = ans.Name.includes('-') ? ans.Name.split('-')[1] : ans.Name; + ans.Name = newName; + return ans; + }); }, }, components: { diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js index df8a16f90..8a5ad8a50 100644 --- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js +++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js @@ -30,7 +30,7 @@ describe("replace-options-question.vue", () => { replaceOptionsQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent, replaceOptions, "car-group"); //Assert - expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'car-Windshield' }, { Name: 'car-FrontDoor' } ]) + expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'Windshield' }, { Name: 'FrontDoor' } ]) }); }); diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue index f47abea5d..081df53a8 100644 --- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue +++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue @@ -1,8 +1,7 @@