CSR-111 Add resetting logic for molding-questions
This commit is contained in:
parent
602512c23f
commit
756a6e3ce9
2 changed files with 4 additions and 9 deletions
|
|
@ -118,7 +118,7 @@ export default {
|
||||||
return moldingQuestionsFromPageData && Object.keys(moldingQuestionsFromPageData).length > 0;
|
return moldingQuestionsFromPageData && Object.keys(moldingQuestionsFromPageData).length > 0;
|
||||||
},
|
},
|
||||||
showThisQuestionChain(glass, i) {
|
showThisQuestionChain(glass, i) {
|
||||||
if (glass.questions?.length < 1 || glass.isSuppressedPart) { return false; } // return false if no questions or if suppressed
|
if (!glass.questions || glass.questions?.length < 1 || glass.isSuppressedPart) { return false; } // return false if no questions or if suppressed
|
||||||
return this.currentGlassIndex === i || glass.answerData?.answerResult?.length > 0;
|
return this.currentGlassIndex === i || glass.answerData?.answerResult?.length > 0;
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
|
|
@ -137,7 +137,7 @@ export default {
|
||||||
glass.answerData = {};
|
glass.answerData = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
// save to vuex store as order.damage.partQuestionAnswers (array)
|
// save to vuex store as order.damage.moldingQuestionArrays (array)
|
||||||
await this.dispatchStoreAction(this.storeActions.SAVE_MOLDING_QUESTION_ANSWERS, questionAnswersArray, false);
|
await this.dispatchStoreAction(this.storeActions.SAVE_MOLDING_QUESTION_ANSWERS, questionAnswersArray, false);
|
||||||
|
|
||||||
// get parts from the questionAnswers
|
// get parts from the questionAnswers
|
||||||
|
|
@ -460,7 +460,7 @@ export default {
|
||||||
|
|
||||||
// add answerData to current glass
|
// add answerData to current glass
|
||||||
glass.answerData = {
|
glass.answerData = {
|
||||||
answerResult: savedPart.result,
|
answerResult: savedPart.partNum,
|
||||||
answeredQuestions: savedPart.answeredQuestions
|
answeredQuestions: savedPart.answeredQuestions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1040,15 +1040,10 @@ export const actions = {
|
||||||
},
|
},
|
||||||
saveMoldingQuestionAnswers(context, moldingQuestionAnswers) {
|
saveMoldingQuestionAnswers(context, moldingQuestionAnswers) {
|
||||||
const previousResultsArray = context.getters.damage.moldingQuestionAnswers;
|
const previousResultsArray = context.getters.damage.moldingQuestionAnswers;
|
||||||
// TODO NOT ACCURATE!! answerData/answerQuestions keeps changing, partNum is undefined a lot
|
|
||||||
const haveMoldingQuestionAnswersChanged = previousResultsArray?.length !== moldingQuestionAnswers.length ||
|
const haveMoldingQuestionAnswersChanged = previousResultsArray?.length !== moldingQuestionAnswers.length ||
|
||||||
!previousResultsArray.every((x, i) =>
|
!previousResultsArray.every((x, i) => x.partNum === moldingQuestionAnswers[i].partNum);
|
||||||
x.answeredQuestions &&
|
|
||||||
x.answeredQuestions.length === moldingQuestionAnswers[i].answeredQuestions?.length &&
|
|
||||||
x.answeredQuestions.every((y, j) => y.selectedAnswerText === moldingQuestionAnswers[i].answeredQuestions[j].selectedAnswerText));
|
|
||||||
|
|
||||||
if (haveMoldingQuestionAnswersChanged) {
|
if (haveMoldingQuestionAnswersChanged) {
|
||||||
// TODO reset glass parts
|
|
||||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||||
context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null);
|
context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null);
|
||||||
context.commit(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null });
|
context.commit(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue