From b10d8c55cea6db94638fdb6191ffab28a73ecb1b Mon Sep 17 00:00:00 2001 From: FrankRua Date: Thu, 3 Mar 2022 16:38:04 -0500 Subject: [PATCH 1/5] POC tint aut oselection --- .../glass-part-question.vue | 71 ++++++++++++------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue index 7e8639ee0..b33eca98f 100644 --- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue +++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue @@ -6,7 +6,7 @@
- +{{ selectedTint }}
{ - const currentGlassSelection = partsData.partsOrQuestions[key]; + Object.keys(this.PartDataFromApi.partsOrQuestions).forEach((key) => { + const currentGlassSelection = this.PartDataFromApi.partsOrQuestions[key]; if (currentGlassSelection.glassName === this.glassName && currentGlassSelection.glassLocation === this.glassLocation) { if (currentGlassSelection.parts.length === 1) { - this.selectedPart = { [currentGlassSelection.glassLocation]: [currentGlassSelection.parts[0].partNumber]}; + this.selectedPart = { + [currentGlassSelection.glassLocation]: [currentGlassSelection.parts[0].partNumber] + }; } } }); + }, + + AutoSelectTintIfOnlyOneColor(tintColor) { + this.selectedTint[tintColor] = { + buttonId: `${this.glassLocation}-${this.glassName}-${tintColor}`, + checkValue: "", + value: "", + }; + }, + + LoadPreselectedValues() { + if (this.modelValue !== undefined) { + // Populate button-question model-value if parts data already exists in VueX + const alreadyPopulatedPartsData = + this.$store.getters.lineItems.glassParts; + + Object.keys(alreadyPopulatedPartsData).forEach((key) => { + const partNumber = alreadyPopulatedPartsData[key].partNumber; + const tintColor = alreadyPopulatedPartsData[key].color; + + Object.keys(this.modelValue).forEach((key) => { + if (this.modelValue[key][0] === partNumber) { + this.selectedTint[tintColor] = { + buttonId: `${this.glassLocation}-${this.glassName}-${tintColor}`, + checkValue: "", + value: "", + }; + } + }); + }); + } } }, }; From 46791251b23b9e1088744ddc823daadae22b35aa Mon Sep 17 00:00:00 2001 From: FrankRua Date: Fri, 4 Mar 2022 10:43:39 -0500 Subject: [PATCH 2/5] default model value --- .../glass-part-question/glass-part-question.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue index b33eca98f..37f58e677 100644 --- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue +++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue @@ -6,10 +6,9 @@
-{{ selectedTint }}
-
- +
-

{{ colorQuestionText }}

+

{{ colorQuestionText }}

-
+
-
+
-
- + -
+ " + :buttonLabel="name" + altText="" + :buttonID="`${glassLocation}-${glassName}-${name}`" + :groupName="`${glassLocation}-${glassName}`" + @isCheckedChanged="ResetTintAndPartSelections()" + /> +
-
-
- -
+ " + class="row my-2" + aria-live="polite" + > +
+
+
-
+
diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index 7c0efeda7..39c8bbbf3 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -136,7 +136,7 @@ export default { } }); }); - + console.log(this.glassParts) return { glassName: g.glassName, glassLocation: g.glassLocation, diff --git a/src/ux-components/list-card/list-card.vue b/src/ux-components/list-card/list-card.vue index c1fc6d089..832f33c6b 100644 --- a/src/ux-components/list-card/list-card.vue +++ b/src/ux-components/list-card/list-card.vue @@ -70,6 +70,7 @@ export default { colLength: String, validationRules: String, selectedValues: [Array, String], + modelValue: Object, hasError: Boolean, }, data(){ @@ -81,6 +82,14 @@ export default { if(Array.isArray(this.selectedValues)){ this.checkValue = this.isMultiSelect ? this.selectedValues.includes(this.value) : this.selectedValues[0]; } + this.$nextTick(() => { + if(Object.keys(this.modelValue).length > 0) { + this.checkValue = this.modelValue.value; + const emitEvent = { checkValue: this.checkValue, value: this.value.toString(), buttonId: this.buttonID.toString() }; + this.$emit('isCheckedChanged', emitEvent); + this.$emit('update:modelValue', emitEvent); + } + }) }, computed: { getLabelClasses() { From 533c79938532c0b71fa232fae3f9e4048b2f713e Mon Sep 17 00:00:00 2001 From: FrankRua Date: Fri, 4 Mar 2022 16:56:58 -0500 Subject: [PATCH 5/5] defects --- .../glass-part-question.vue | 54 +-- src/layouts/vehicle-parts/vehicle-parts.vue | 381 +++++++++--------- src/ux-components/list-card/list-card.vue | 101 +++-- 3 files changed, 285 insertions(+), 251 deletions(-) diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue index e923af0c6..9be24b91b 100644 --- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue +++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue @@ -82,16 +82,10 @@ export default { glassName: String, glassLocation: String, colorAnswers: Array, - modelValue: { - type: Object, - default: () => ({}), - }, + modelValue: Object, }, mounted() { this.LoadPreselectedValues(); - if (Object.keys(this.featureListData).length === 1) { - this.AutoSelectTintIfOnlyOneColor(Object.keys(this.featureListData)[0]); - } }, components: { listCard, @@ -144,6 +138,7 @@ export default { }, }, methods: { + // Initialize the component data initializeComponent(cmsContent) { this.glassColorQuestion = cmsContent.ColorQuestionWidget.QuestionText; this.glassFeatureQuestion = cmsContent.FeatureQuestionWidget.QuestionText; @@ -191,35 +186,30 @@ export default { }); }, - AutoSelectTintIfOnlyOneColor(tintColor) { - this.selectedTint[tintColor] = { - buttonId: `${this.glassLocation}-${this.glassName}-${tintColor}`, - checkValue: "", - value: `${this.glassLocation}-${this.glassName}-${tintColor}`, - }; - }, - + // Loads the preselected values from the store. LoadPreselectedValues() { - if (Object.keys(this.modelValue).length !== 0) { - // Populate button-question model-value if parts data already exists in VueX - const alreadyPopulatedPartsData = - this.$store.getters.lineItems.glassParts; + this.$nextTick(() => { + if (this.modelValue !== undefined) { + // Populate button-question model-value if parts data already exists in VueX + const alreadyPopulatedPartsData = + this.$store.getters.lineItems.glassParts; - Object.keys(alreadyPopulatedPartsData).forEach((key) => { - const partNumber = alreadyPopulatedPartsData[key].partNumber; - const tintColor = alreadyPopulatedPartsData[key].color; + Object.keys(alreadyPopulatedPartsData).forEach((key) => { + const partNumber = alreadyPopulatedPartsData[key].partNumber; + const tintColor = alreadyPopulatedPartsData[key].color; - Object.keys(this.modelValue).forEach((key) => { - if (this.modelValue[key][0] === partNumber) { - this.selectedTint[tintColor] = { - buttonId: `${this.glassLocation}-${this.glassName}-${tintColor}`, - checkValue: "", - value: `${this.glassLocation}-${this.glassName}-${tintColor}`, - }; - } + Object.keys(this.modelValue).forEach((key) => { + if (this.modelValue[key][0] === partNumber) { + this.selectedTint[tintColor] = { + buttonId: `${this.glassLocation}-${this.glassName}-${tintColor}`, + checkValue: "", + value: `${this.glassLocation}-${this.glassName}-${tintColor}`, + }; + } + }); }); - }); - } + } + }); }, }, }; diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index 39c8bbbf3..41e17f601 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -1,42 +1,26 @@ diff --git a/src/ux-components/list-card/list-card.vue b/src/ux-components/list-card/list-card.vue index 832f33c6b..8c5ac9e23 100644 --- a/src/ux-components/list-card/list-card.vue +++ b/src/ux-components/list-card/list-card.vue @@ -2,7 +2,11 @@
- {{buttonLabel}} + {{ buttonLabel }}

-

- {{buttonLabelSubCopy}} +

+ {{ buttonLabelSubCopy }}

{{ buttonLabel }}

@@ -73,23 +81,26 @@ export default { modelValue: Object, hasError: Boolean, }, - data(){ + data() { return { checkValue: Boolean, + }; + }, + created() { + if (Array.isArray(this.selectedValues)) { + this.checkValue = this.isMultiSelect + ? this.selectedValues.includes(this.value) + : this.selectedValues[0]; } }, - created(){ - if(Array.isArray(this.selectedValues)){ - this.checkValue = this.isMultiSelect ? this.selectedValues.includes(this.value) : this.selectedValues[0]; - } - this.$nextTick(() => { - if(Object.keys(this.modelValue).length > 0) { - this.checkValue = this.modelValue.value; - const emitEvent = { checkValue: this.checkValue, value: this.value.toString(), buttonId: this.buttonID.toString() }; - this.$emit('isCheckedChanged', emitEvent); - this.$emit('update:modelValue', emitEvent); + watch: { + // Changing this will impact pre-selection data loads on vehicle-parts. + // If changed, please regression test that vehicle-parts data still loads correctly with previous selections. + modelValue(newVal) { + if (newVal !== undefined) { + this.checkValue = newVal.value; } - }) + }, }, computed: { getLabelClasses() { @@ -105,23 +116,26 @@ export default { }, }, methods: { - handleCheckChange(newValue, oldValue){ - const isInitialization = typeof(oldValue) === 'function'; + handleCheckChange(newValue, oldValue) { + const isInitialization = typeof oldValue === "function"; if (!isInitialization) { - const emitEvent = { checkValue: this.checkValue, value: this.value.toString(), buttonId: this.buttonID.toString() }; - this.$emit('isCheckedChanged', emitEvent); - this.$emit('update:modelValue', emitEvent); + const emitEvent = { + checkValue: this.checkValue, + value: this.value.toString(), + buttonId: this.buttonID.toString(), + }; + this.$emit("isCheckedChanged", emitEvent); + this.$emit("update:modelValue", emitEvent); } - } + }, }, setup(props) { const inputType = props.isMultiSelect ? "checkbox" : "radio"; const { - value: inputValue, - handleChange, - errors, - } = useField(props.groupName, props.validationRules, - { + value: inputValue, + handleChange, + errors, + } = useField(props.groupName, props.validationRules, { type: inputType, checkedValue: props.value, }); @@ -136,10 +150,12 @@ export default { \ No newline at end of file +