fix preselecting issue on vehicle-parts
This commit is contained in:
parent
a05a4ac1d3
commit
dd15196502
1 changed files with 11 additions and 16 deletions
|
|
@ -28,7 +28,8 @@
|
|||
isRequired
|
||||
isSmallQuestionText
|
||||
:groupName="`${glassLocation}-${glassName}-${selectedTint}`"
|
||||
:validationRules="partValidationRules" />
|
||||
:validationRules="partValidationRules"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</buttonQuestion>
|
||||
|
|
@ -181,25 +182,25 @@ export default {
|
|||
return tintSourceObject.src;
|
||||
},
|
||||
|
||||
// Check if only a single part is present for the tint and set the v-model if it is.
|
||||
AutoSelect() {
|
||||
if(this.partsForSelectedTint?.length > 0)
|
||||
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(() => {
|
||||
document.querySelector('input[value=' + this.selectedPartNumber + ']').checked = true;
|
||||
});
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// If selected part isn't in the current list or it's null, select the first part
|
||||
if(!this.selectedPartNumber || this.partsForSelectedTint.filter(x => x.partNumber == this.selectedPartNumber).length === 0)
|
||||
{
|
||||
this.selectedPartNumber = { value: this.partsForSelectedTint[0].partNumber };
|
||||
}
|
||||
}
|
||||
|
||||
//select element with matching partNumber
|
||||
this.$nextTick(() => {
|
||||
document.querySelector('input[value=' + this.selectedPartNumber + ']').checked = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -207,16 +208,10 @@ export default {
|
|||
LoadPreselectedValues() {
|
||||
this.$nextTick(() => {
|
||||
// Populate button-question model-value if parts data already exists in store
|
||||
if(this.modelValue)
|
||||
if(this.modelValue !== undefined)
|
||||
{
|
||||
this.selectedTint = this.modelValue.color;
|
||||
}
|
||||
else{
|
||||
// If one item in list, select it
|
||||
if (this.tintSelectionOptions?.length == 1) {
|
||||
this.selectedTint = this.tintSelectionOptions[0].value;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue