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
|
||||
* @returns part
|
||||
*/
|
||||
function setPartRecalibrationProperties(part, capabilityAnswerResult) {
|
||||
part.RecalibrationType = capabilityAnswerResult.Result1;
|
||||
part.RequiresRecalibration = capabilityAnswerResult.Result2 != "0";
|
||||
return part;
|
||||
export default function setPartRecalibrationProperties(part, capabilityAnswerResult) {
|
||||
Object.assign(part, {
|
||||
recalibrationType: capabilityAnswerResult.result1,
|
||||
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 vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
|
||||
import questionsPageLayout from '@/iss-components/questions-page-layout/questions-page-layout.vue';
|
||||
import setPartRecalibrationProperties from '@/helpers/capability-question-helper';
|
||||
|
||||
export default {
|
||||
name: 'capability-questions',
|
||||
|
|
@ -131,22 +132,18 @@ export default {
|
|||
},
|
||||
async forwardButtonAction() {
|
||||
const questionAnswersArray = this.questionsData.map((glass) => {
|
||||
// get answerResult2 of returned answer
|
||||
let selectedAnswerResult2;
|
||||
glass.questions.forEach((q) => {
|
||||
const idx = q.answers.findIndex((a) => a.answerResult === glass.answerData.answerResult);
|
||||
if (idx !== -1) {
|
||||
selectedAnswerResult2 = q.answers[idx].answerResult2;
|
||||
}
|
||||
});
|
||||
const { glassLocation, glassName, isSuppressedPart, answerData, questions } = glass;
|
||||
const { answerResult, answeredQuestions } = answerData
|
||||
return {
|
||||
glassLocation: glass.glassLocation,
|
||||
glassName: glass.glassName,
|
||||
result: glass.answerData.answerResult,
|
||||
result1: glass.answerData.answerResult,
|
||||
result2: selectedAnswerResult2,
|
||||
answeredQuestions: glass.answerData.answeredQuestions,
|
||||
isSuppressedPart: glass.isSuppressedPart
|
||||
glassLocation,
|
||||
glassName,
|
||||
result: answerResult,
|
||||
result1: answerResult,
|
||||
result2: questions
|
||||
.flatMap(q => q.answers)
|
||||
.find(a => a.answerResult === answerData.answerResult)?.answerResult2,
|
||||
answeredQuestions,
|
||||
isSuppressedPart
|
||||
};
|
||||
});
|
||||
// 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)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue