diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue index ed7e54307..91dcf5e40 100644 --- a/src/layouts/molding-questions/molding-questions.vue +++ b/src/layouts/molding-questions/molding-questions.vue @@ -118,7 +118,7 @@ export default { return moldingQuestionsFromPageData && Object.keys(moldingQuestionsFromPageData).length > 0; }, 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; }, async forwardButtonAction() { @@ -137,7 +137,7 @@ export default { 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); // get parts from the questionAnswers @@ -460,7 +460,7 @@ export default { // add answerData to current glass glass.answerData = { - answerResult: savedPart.result, + answerResult: savedPart.partNum, answeredQuestions: savedPart.answeredQuestions } } diff --git a/src/store/index.js b/src/store/index.js index 1b2c1dbcd..e82b02251 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1040,15 +1040,10 @@ export const actions = { }, saveMoldingQuestionAnswers(context, 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 || - !previousResultsArray.every((x, i) => - x.answeredQuestions && - x.answeredQuestions.length === moldingQuestionAnswers[i].answeredQuestions?.length && - x.answeredQuestions.every((y, j) => y.selectedAnswerText === moldingQuestionAnswers[i].answeredQuestions[j].selectedAnswerText)); + !previousResultsArray.every((x, i) => x.partNum === moldingQuestionAnswers[i].partNum); if (haveMoldingQuestionAnswersChanged) { - // TODO reset glass parts context.commit(storeMutations.UPDATE_GLASS_PARTS, null); context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null); context.commit(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null });