CSR-343 Save glassParts
This commit is contained in:
parent
7e4494eb25
commit
f208cb031c
3 changed files with 11 additions and 56 deletions
|
|
@ -130,7 +130,6 @@ export default {
|
|||
return this.modelValue;
|
||||
},
|
||||
set: function(newValue) {
|
||||
console.log(newValue)
|
||||
this.$emit("update:modelValue", newValue);
|
||||
}
|
||||
},
|
||||
|
|
@ -140,24 +139,19 @@ export default {
|
|||
if (this.useTextForValue){
|
||||
return answer.Text
|
||||
}
|
||||
// console.log(answer.Name ? answer.Name : answer)
|
||||
|
||||
return answer.Name ? answer.Name : answer;
|
||||
},
|
||||
handleCheckedChanged(val) {
|
||||
console.log(val)
|
||||
console.log("A")
|
||||
if(this.selectingInitiatesLoad) {
|
||||
console.log("B")
|
||||
this.selectedValues = [val.value];
|
||||
} else {
|
||||
if(Array.isArray(this.selectedValues)) {
|
||||
console.log("C")
|
||||
const newSelectedValues = this.selectedValues;
|
||||
val.checkValue ? newSelectedValues.push(val.value) : newSelectedValues.splice(newSelectedValues.indexOf(val.value), 1);
|
||||
this.selectedValues = newSelectedValues;
|
||||
}
|
||||
else {
|
||||
console.log("D")
|
||||
this.selectedValues = val.value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
<p class="mb-0 color-question-text">{{ colorQuestionText }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{{ selectedPart }}
|
||||
|
||||
<div class="container nested-radio">
|
||||
<div class="row my-2">
|
||||
|
|
@ -119,7 +118,6 @@ export default {
|
|||
return this.modelValue;
|
||||
},
|
||||
set: function (newValue) {
|
||||
console.log(newValue)
|
||||
this.$emit("update:modelValue", newValue);
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -62,12 +62,7 @@ import { settleAllPromises } from "@/helpers/layout-helper";
|
|||
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import store from "@/store";
|
||||
import { Form, defineRule } from "vee-validate";
|
||||
import { required } from "@/helpers/validation-rules";
|
||||
import { errorMessages } from "@/constants/error-messages";
|
||||
|
||||
// DEFINE VALIDATION RULES
|
||||
// defineRule("replace-options-required", required(errorMessages.OPTION_REQUIRED));
|
||||
import { Form } from "vee-validate";
|
||||
|
||||
export default {
|
||||
name: "vehicle-parts",
|
||||
|
|
@ -166,53 +161,24 @@ methods: {
|
|||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||
},
|
||||
forwardButtonAction() {
|
||||
const selectedGlassPartNumbers = [];
|
||||
const matchedParts = [];
|
||||
|
||||
// Compile all selected parts from the page.
|
||||
for (let [key, value] of Object.entries(this.glassParts)) {
|
||||
selectedGlassPartNumbers.push(value);
|
||||
// for (let [glassKey, glassValue] of Object.entries(value)) {
|
||||
// selectedGlassPartNumbers.push(glassValue[0]);
|
||||
// }
|
||||
}
|
||||
|
||||
console.log(this.glassParts)
|
||||
console.log(selectedGlassPartNumbers)
|
||||
console.log(this.PartsFromApi.partsOrQuestions)
|
||||
|
||||
// Match them to the parts from the API.
|
||||
for (let [key, value] of Object.entries(this.PartsFromApi.partsOrQuestions)) {
|
||||
// const partsForGlassPart = value
|
||||
const isMatched = selectedGlassPartNumbers.some(
|
||||
(p) => p === value.partNumber
|
||||
);
|
||||
this.PartsFromApi.partsOrQuestions.forEach(part => {
|
||||
const selectedPartNumberForGlassLocationAndName = this.glassParts[`${part.glassLocation}-${part.glassName}`];
|
||||
const selectedPartData = part.parts.filter(part => part.partNumber == selectedPartNumberForGlassLocationAndName);
|
||||
|
||||
if (isMatched) {
|
||||
// matchedParts.push(currentPart);
|
||||
}
|
||||
|
||||
// for (let [partKey, partValue] of Object.entries(value.parts)) {
|
||||
// const currentPart = this.PartsFromApi.partsOrQuestions[key].parts[partKey];
|
||||
// const isMatched = selectedGlassPartNumbers.some(
|
||||
// (p) => p === currentPart.partNumber
|
||||
// );
|
||||
|
||||
// if (isMatched) {
|
||||
// matchedParts.push(currentPart);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
console.log(matchedParts)
|
||||
matchedParts.push(selectedPartData[0]);
|
||||
})
|
||||
|
||||
// If no parts could be matched, throw an error.
|
||||
if (matchedParts.length === 0) {
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
throw new Error("Could not match any parts to the selected parts");
|
||||
}
|
||||
|
||||
// // Save parts to the store.
|
||||
// store.commit(storeMutations.UPDATE_GLASS_PARTS, matchedParts);
|
||||
// Save parts to the store.
|
||||
store.commit(storeMutations.UPDATE_GLASS_PARTS, matchedParts);
|
||||
|
||||
// // Navigate to the next page.
|
||||
// this.$router.navigateAfterSave(
|
||||
|
|
@ -227,10 +193,7 @@ methods: {
|
|||
|
||||
LoadInitialPartsData() {
|
||||
const partsData = this.PartsFromApi;
|
||||
const alreadyPopulatedPartsData =
|
||||
this.$store.getters.lineItems.glassParts === null
|
||||
? {}
|
||||
: this.$store.getters.lineItems.glassParts;
|
||||
const alreadyPopulatedPartsData = this.$store.getters.lineItems.glassParts === null ? {} : this.$store.getters.lineItems.glassParts;
|
||||
|
||||
partsData.partsOrQuestions.map((g) => {
|
||||
// If the part is already populated, use the value from the store and populate the v-model.
|
||||
|
|
|
|||
Loading…
Reference in a new issue