Merge pull request #534 from Safelite/feature/digital/SSR-792.2

Prepopulating vehicle selection page with content from store
This commit is contained in:
michaela-brydon-safelite 2024-01-16 09:43:16 -05:00 committed by GitHub
commit 82de91ab35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 8 deletions

View file

@ -32,9 +32,9 @@ export default {
get() {
return this.selectedIndex?.toString();
},
set(newValue) {
this.selectedIndex = newValue;
newValue = newValue != null && newValue > -1 ? this.values[newValue] : null;
set(newIndex) {
this.selectedIndex = newIndex;
const newValue = newIndex != null && newIndex > -1 ? this.values[newIndex] : null;
this.$emit('update:modelValue', newValue);
}
}
@ -46,7 +46,8 @@ export default {
if (this.values.length === 1) {
this.selectedValue = 0;
} else {
this.selectedValue = null;
const valueIndex = this.values.indexOf(this.modelValue);
this.selectedValue = valueIndex === -1 ? null : valueIndex;
}
},
clearValues() {

View file

@ -134,11 +134,12 @@ export default {
validationRules: String
},
data() {
const { year, make, model, style } = useMainStore().order.vehicle;
return {
selectedYear: null,
selectedMake: null,
selectedModel: null,
selectedStyle: null
selectedYear: year,
selectedMake: make,
selectedModel: model,
selectedStyle: style
};
},
computed: {
@ -176,6 +177,15 @@ export default {
},
mounted() {
this.$refs.vehicleYearQuestion.getNewValues();
if (this.selectedYear) {
this.$refs.vehicleMakeQuestion.getNewValues();
}
if (this.selectedMake) {
this.$refs.vehicleModelQuestion.getNewValues();
}
if (this.selectedModel) {
this.$refs.vehicleStyleQuestion.getNewValues();
}
},
methods: {
arePagePrerequisitesValid() {