CSR-343 Fix back button

This commit is contained in:
Katie 2022-06-29 08:40:46 -04:00
parent 8fe1dd8d7b
commit a979bf2c85
3 changed files with 14 additions and 58 deletions

View file

@ -14,7 +14,7 @@
isRequired isRequired
:groupName="`${glassLocation}-${glassName}`" :groupName="`${glassLocation}-${glassName}`"
@isCheckedChanged="ResetTintAndPartSelections" @isCheckedChanged="ResetTintAndPartSelections"
:validationRules="`${glassLocation}-${glassName}-tint-required`" :validationRules="tintValidationRules"
> >
<div class="row my-2" aria-live="polite"> <div class="row my-2" aria-live="polite">
<div class="col"> <div class="col">
@ -28,7 +28,7 @@
:loaderEnabled="false" :loaderEnabled="false"
isRequired isRequired
:groupName="`${glassLocation}-${glassName}-${selectedTint}`" :groupName="`${glassLocation}-${glassName}-${selectedTint}`"
:validationRules="`${glassLocation}-${glassName}-part-required`" :validationRules="partValidationRules"
/> />
</div> </div>
</div> </div>
@ -67,13 +67,22 @@ export default {
alreadyPopulatedPartsData: Object alreadyPopulatedPartsData: Object
}, },
mounted() { mounted() {
this.setAllValidationRules();
this.LoadPreselectedValues(); this.LoadPreselectedValues();
}, },
components: { components: {
buttonQuestion, buttonQuestion,
}, },
computed: { computed: {
tintValidationRules() {
const validationRuleName = `${this.glassLocation}-${this.glassName}-tint-required`;
defineRule(validationRuleName, required(errorMessages.OPTION_REQUIRED));
return validationRuleName;
},
partValidationRules() {
const validationRuleName = `${this.glassLocation}-${this.glassName}-part-required`;
defineRule(validationRuleName, required(errorMessages.OPTION_REQUIRED));
return validationRuleName;
},
colorQuestionText() { colorQuestionText() {
return getCustomTransformValue( return getCustomTransformValue(
this.glassColorQuestion, this.glassColorQuestion,
@ -107,10 +116,10 @@ export default {
}, },
partsForSelectedTint() { partsForSelectedTint() {
return this.PartDataFromApi.partsOrQuestions.filter(dataForGlassLocationAndName => return this.PartDataFromApi.partsOrQuestions?.filter(dataForGlassLocationAndName =>
dataForGlassLocationAndName.glassName == this.glassName && dataForGlassLocationAndName.glassName == this.glassName &&
dataForGlassLocationAndName.glassLocation == this.glassLocation)[0] dataForGlassLocationAndName.glassLocation == this.glassLocation)[0]
.parts.filter(part => part.color == this.selectedTint); .parts?.filter(part => part.color == this.selectedTint) ?? [];
}, },
// Creates a map of the feature list data in the correct Name/Value // Creates a map of the feature list data in the correct Name/Value
@ -192,10 +201,6 @@ export default {
} }
}); });
}, },
setAllValidationRules() {
defineRule(`${this.glassLocation}-${this.glassName}-tint-required`, required(errorMessages.OPTION_REQUIRED));
defineRule(`${this.glassLocation}-${this.glassName}-part-required`, required(errorMessages.OPTION_REQUIRED));
}
}, },
watch: { watch: {
selectedTint() { selectedTint() {

View file

@ -21,7 +21,6 @@
</div> </div>
</div> </div>
</div> </div>
{{ glassParts }}
<div v-for="(item, i) in PartsOrQuestions" :key="i"> <div v-for="(item, i) in PartsOrQuestions" :key="i">
<!-- Render horizontal lines if there is multi-glass (aka if i > 0) --> <!-- Render horizontal lines if there is multi-glass (aka if i > 0) -->
<hr v-if="i > 0" /> <hr v-if="i > 0" />
@ -177,8 +176,6 @@ methods: {
throw new Error("Could not match any parts to the selected parts"); throw new Error("Could not match any parts to the selected parts");
} }
console.log(matchedParts)
// Save parts to the store. // Save parts to the store.
store.commit(storeMutations.UPDATE_GLASS_PARTS, matchedParts); store.commit(storeMutations.UPDATE_GLASS_PARTS, matchedParts);
@ -194,48 +191,14 @@ methods: {
}, },
LoadInitialPartsData() { LoadInitialPartsData() {
console.log("Loading in vehicle-parts")
this.alreadyPopulatedPartsData = this.$store.getters.lineItems.glassParts ?? []; this.alreadyPopulatedPartsData = this.$store.getters.lineItems.glassParts ?? [];
// MOCKKKK, real one is above
// console.log(this.PartsFromApi.partsOrQuestions[0])
// this.alreadyPopulatedPartsData = [this.PartsFromApi.partsOrQuestions[0].parts[0], this.PartsFromApi.partsOrQuestions[1].parts[0], this.PartsFromApi.partsOrQuestions[2].parts[0], this.PartsFromApi.partsOrQuestions[3].parts[0], this.PartsFromApi.partsOrQuestions[4].parts[0]];
// console.log("MOCK alreadyPopulatedPartsData")
// console.log(this.alreadyPopulatedPartsData)
const savedPartNumbers = this.alreadyPopulatedPartsData.map(part => part.partNumber) const savedPartNumbers = this.alreadyPopulatedPartsData.map(part => part.partNumber)
console.log(savedPartNumbers)
// const allPartsForGlass = this.PartsFromApi.partsOrQuestions.filter(glass => glass.glassLocation == this.glassLocation && glass.glassName == this.glassName)[0].parts;
this.PartsFromApi.partsOrQuestions.forEach(glass => { this.PartsFromApi.partsOrQuestions.forEach(glass => {
console.log("glass")
console.log(glass)
const savedPart = glass.parts.filter(part => savedPartNumbers.includes(part.partNumber))[0]; const savedPart = glass.parts.filter(part => savedPartNumbers.includes(part.partNumber))[0];
console.log('savedPart')
console.log(savedPart)
if (savedPart) { if (savedPart) {
this.glassParts[`${glass.glassLocation}-${glass.glassName}`.replace(" ", "-")] = savedPart; this.glassParts[`${glass.glassLocation}-${glass.glassName}`.replace(" ", "-")] = savedPart;
} }
console.log('glassParts')
console.log(this.glassParts)
// this.glassParts[`${glass.glassLocation}-${glass.glassName}`] =
// If the part is already populated, use the value from the store and populate the v-model.
// Object.keys(alreadyPopulatedPartsData).forEach(savedPart => {
// const savedPartNumber = savedPart.partNumber;
// let test = partFromApi.parts.filter(part => part.partNumber == savedPartNumber);
// console.log(test);
// // g.parts.forEach((p) => {
// // if (p.partNumber === partNumber) {
// // this.glassParts[g.glassLocation + "-" + g.glassName] = {
// // [g.glassLocation]: [partNumber],
// // };
// // }
// // });
// });
}); });
}, },
}, },

View file

@ -105,9 +105,6 @@ export default {
: this.selectedValues[0]; : this.selectedValues[0];
} }
else { else {
console.log("HI")
console.log(this.modelValue)
console.log(this.value)
this.checkValue = this.selectedValues == this.value || this.modelValue == this.value; this.checkValue = this.selectedValues == this.value || this.modelValue == this.value;
} }
}, },
@ -132,9 +129,7 @@ export default {
}, },
methods: { methods: {
handleInputChange() { handleInputChange() {
console.log("HI 1")
if(!this.selectingInitiatesLoad) { if(!this.selectingInitiatesLoad) {
console.log("HI 2")
this.handleCheckChange(); this.handleCheckChange();
} }
}, },
@ -175,14 +170,7 @@ export default {
} }
}, },
selectedValues(newVal) { selectedValues(newVal) {
// this.handleChange(newVal == this.value);
console.log("WATCH")
console.log(newVal)
console.log(typeof newVal)
console.log(typeof newVal === "string")
if (typeof newVal === "string") { if (typeof newVal === "string") {
console.log(this.value)
// console.log(newVal == this.value)
this.handleChange(this.value); this.handleChange(this.value);
this.checkValue = newVal == this.value; this.checkValue = newVal == this.value;
} }