Setting recal properties
This commit is contained in:
parent
aa1236ec38
commit
1377b40b6e
2 changed files with 23 additions and 49 deletions
|
|
@ -6,37 +6,9 @@
|
||||||
* @param {*} capabilityAnswerResult
|
* @param {*} capabilityAnswerResult
|
||||||
* @returns part
|
* @returns part
|
||||||
*/
|
*/
|
||||||
function setPartRecalibrationProperties(part, capabilityAnswerResult) {
|
export default function setPartRecalibrationProperties(part, capabilityAnswerResult) {
|
||||||
part.RecalibrationType = capabilityAnswerResult.Result1;
|
Object.assign(part, {
|
||||||
part.RequiresRecalibration = capabilityAnswerResult.Result2 != "0";
|
recalibrationType: capabilityAnswerResult.result1,
|
||||||
return part;
|
requiresRecalibration: capabilityAnswerResult.result2 !== "0"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// function x(capabilityQuestionAnswers, glassLocation) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// setAllPartRecalibrationProperties(parts, context, { payload, pageNameToLog }) {
|
|
||||||
// const glassLocation = payload;
|
|
||||||
// const pageData = context.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS);
|
|
||||||
|
|
||||||
// const part = pageData.partsOrQuestions.find((x) => x.glassLocation === glassLocation)
|
|
||||||
// .parts[0];
|
|
||||||
// const capabilityQuestionAnswers = context.getters.damage.capabilityQuestionAnswers;
|
|
||||||
// const capabilityQuestionAnswersForPart = capabilityQuestionAnswers.find(
|
|
||||||
// (x) => x.glassLocation === glassLocation
|
|
||||||
// );
|
|
||||||
|
|
||||||
// return globalMethods.callHttpClient({
|
|
||||||
// method: endpoints.GetPartFromCapabilityAnswer.method,
|
|
||||||
// endpoint: endpoints.GetPartFromCapabilityAnswer.url,
|
|
||||||
// payload: {
|
|
||||||
// part,
|
|
||||||
// capabilityAnswerResults: capabilityQuestionAnswersForPart,
|
|
||||||
// },
|
|
||||||
// logApiCall: true,
|
|
||||||
// pageNameToLog: pageNameToLog,
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
|
|
||||||
export default setPartRecalibrationProperties;
|
|
||||||
|
|
@ -31,6 +31,7 @@ import { useMainStore } from '@/store';
|
||||||
import globalRules from '@/constants/global-rules';
|
import globalRules from '@/constants/global-rules';
|
||||||
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
|
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
|
||||||
import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout.vue';
|
import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout.vue';
|
||||||
|
import setPartRecalibrationProperties from '@/helpers/capability-question-helper';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'capability-questions',
|
name: 'capability-questions',
|
||||||
|
|
@ -131,22 +132,18 @@ export default {
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
const questionAnswersArray = this.questionsData.map((glass) => {
|
const questionAnswersArray = this.questionsData.map((glass) => {
|
||||||
// get answerResult2 of returned answer
|
const { glassLocation, glassName, isSuppressedPart, answerData, questions } = glass;
|
||||||
let selectedAnswerResult2;
|
const { answerResult, answeredQuestions } = answerData
|
||||||
glass.questions.forEach((q) => {
|
|
||||||
const idx = q.answers.findIndex((a) => a.answerResult === glass.answerData.answerResult);
|
|
||||||
if (idx !== -1) {
|
|
||||||
selectedAnswerResult2 = q.answers[idx].answerResult2;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return {
|
return {
|
||||||
glassLocation: glass.glassLocation,
|
glassLocation,
|
||||||
glassName: glass.glassName,
|
glassName,
|
||||||
result: glass.answerData.answerResult,
|
result: answerResult,
|
||||||
result1: glass.answerData.answerResult,
|
result1: answerResult,
|
||||||
result2: selectedAnswerResult2,
|
result2: questions
|
||||||
answeredQuestions: glass.answerData.answeredQuestions,
|
.flatMap(q => q.answers)
|
||||||
isSuppressedPart: glass.isSuppressedPart
|
.find(a => a.answerResult === answerData.answerResult)?.answerResult2,
|
||||||
|
answeredQuestions,
|
||||||
|
isSuppressedPart
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
// clear out answerData for future page loads; must occur prior to store save
|
// clear out answerData for future page loads; must occur prior to store save
|
||||||
|
|
@ -155,7 +152,12 @@ export default {
|
||||||
});
|
});
|
||||||
// save to store as order.damage.moldingQuestionArrays (array)
|
// save to store as order.damage.moldingQuestionArrays (array)
|
||||||
await this.mainStore.saveCapabilityQuestionAnswers(questionAnswersArray);
|
await this.mainStore.saveCapabilityQuestionAnswers(questionAnswersArray);
|
||||||
// TODO call get parts from the capabilityQuestionAnswers endpoint
|
|
||||||
|
for (let answer of questionAnswersArray) {
|
||||||
|
const partAssociatedWithAnswer = this.partsOrQuestionsData.find((x) => x.glassLocation === answer.glassLocation).parts[0];
|
||||||
|
setPartRecalibrationProperties(partAssociatedWithAnswer, answer);
|
||||||
|
}
|
||||||
|
|
||||||
this.navigateForward(this.partsOrQuestionsData, null);
|
this.navigateForward(this.partsOrQuestionsData, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue