SSR-1290 Set previous selected when navigating back to vehicle-parts
This commit is contained in:
parent
95e49cb88c
commit
24ca91d30a
1 changed files with 22 additions and 8 deletions
|
|
@ -51,6 +51,7 @@ import getCustomTransformValue from '@/constants/dynamictext-mapper';
|
|||
import { defineRule } from 'vee-validate';
|
||||
import { required } from '@/helpers/validation-rules';
|
||||
import errorMessages from '@/constants/error-messages';
|
||||
import { useMainStore } from '@/store';
|
||||
|
||||
export default {
|
||||
name: 'glass-part-question',
|
||||
|
|
@ -189,14 +190,8 @@ export default {
|
|||
if (this.partsForSelectedTint?.length > 0) {
|
||||
// Check if only a single part is present for the tint and set the v-model if it is.
|
||||
if (this.partsForSelectedTint?.length === 1) {
|
||||
this.selectedPartNumber = { value: this.partsForSelectedTint[0].partNumber };
|
||||
|
||||
// //select element with matching partNumber
|
||||
this.$nextTick(() => {
|
||||
const radioInput = document.querySelector(`input[value=${this.selectedPartNumber}]`);
|
||||
// Fire a click event on the input so the field is updated
|
||||
radioInput?.click();
|
||||
});
|
||||
// select element with matching partNumber
|
||||
this.updateSelectedPartNumber(this.partsForSelectedTint[0].partNumber);
|
||||
} else {
|
||||
this.selectedPartNumber = null;
|
||||
}
|
||||
|
|
@ -209,10 +204,29 @@ export default {
|
|||
// Populate button-question model-value if parts data already exists in store
|
||||
if (this.modelValue !== undefined) {
|
||||
this.selectedTint = this.modelValue.color;
|
||||
for (const tintPart of this.partsForSelectedTint) {
|
||||
for (const glassPart of useMainStore().order.lineItems.glassParts) {
|
||||
if (tintPart.partNumber === glassPart.partNumber) {
|
||||
this.$nextTick(() => {
|
||||
this.updateSelectedPartNumber(tintPart.partNumber);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
updateSelectedPartNumber(partNumber) {
|
||||
this.selectedPartNumber = { value: partNumber };
|
||||
this.$nextTick(() => {
|
||||
const radioInput = document.querySelector(`input[value=${this.selectedPartNumber}]`);
|
||||
// Fire a click event on the input so the field is updated
|
||||
radioInput?.click();
|
||||
});
|
||||
},
|
||||
|
||||
replaceAllSpaceWithDash(str) {
|
||||
return String(str).replaceAll(' ', '-');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue