diff --git a/src/common-components/question-chain/question-chain.vue b/src/common-components/question-chain/question-chain.vue index 3f77a87be..432fd2eca 100644 --- a/src/common-components/question-chain/question-chain.vue +++ b/src/common-components/question-chain/question-chain.vue @@ -7,7 +7,7 @@ :class="q.questionSequence === currentQuestionNum && 'current-question'" :questionText="q.questionText" :answers="q.answers" - :groupName="`question-${glassPieceIndex}-${q.questionSequence}`" + :groupName="`question-${index}-${q.questionSequence}`" :modelValue="q.answerSelected" @update:modelValue="handleAnswer(q, $event)" isRequired @@ -32,7 +32,7 @@ export default { questionData: Object, validationRules: String, modelValue: Object, - glassPieceIndex: Number, + index: Number, answerKey: String, }, async created() { @@ -155,7 +155,7 @@ export default { return { answerResult: questionAnswer, answeredQuestions: answeredQuestions, - index: this.glassPieceIndex, + index: this.index, }; } }, diff --git a/src/common-components/questions-page/questions-page.vue b/src/common-components/questions-page-layout/questions-page-layout.vue similarity index 95% rename from src/common-components/questions-page/questions-page.vue rename to src/common-components/questions-page-layout/questions-page-layout.vue index de58727f6..85ccd33ad 100644 --- a/src/common-components/questions-page/questions-page.vue +++ b/src/common-components/questions-page-layout/questions-page-layout.vue @@ -18,7 +18,7 @@ ref="questionChain" v-model="selectedAnswers[questionsDatum.answerKey]" :questionData="questionsDatum.questions" - :glassPieceIndex="i" + :index="i" v-if="showThisQuestionChain(questionsDatum, i)" :answerKey="questionsDatum.answerKey" :validationRules="validationRules" /> @@ -52,7 +52,7 @@ export default { questionsData: Array, validationRules: String, modelValue: Array, - currentGlassPieceIndex: Number, + index: Number, }, computed: { selectedAnswers: { @@ -69,7 +69,7 @@ export default { if (!glass.questions || glass.questions?.length < 1 || glass.isSuppressedPart) { return false; } // return false if no questions or if suppressed - return this.currentGlassPieceIndex === i || glass.answerData?.answerResult?.length > 0; + return this.index === i || glass.answerData?.answerResult?.length > 0; }, handleForwardButtonAction() { this.$emit("forwardButtonAction"); diff --git a/src/layouts/capability-questions/capability-questions.vue b/src/layouts/capability-questions/capability-questions.vue index 2f6fa4f74..67b95a707 100644 --- a/src/layouts/capability-questions/capability-questions.vue +++ b/src/layouts/capability-questions/capability-questions.vue @@ -1,7 +1,7 @@ diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue index d0b7c93c4..cfae7af71 100644 --- a/src/layouts/molding-questions/molding-questions.vue +++ b/src/layouts/molding-questions/molding-questions.vue @@ -1,7 +1,7 @@ diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index 6be2e8028..9d1b54c66 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -1,7 +1,7 @@ diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index f54b462ee..a50a85755 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -66,7 +66,7 @@ export default { currentPageComesAfterPage(currentPage = this.$route.query.fmgPage, fmgPage) { return this.comparePageIndices(currentPage, fmgPage) > 0; }, - setupInitialData(glass, i, alreadyAnsweredQuestions, vm) { + setupInitialData(glass, index, alreadyAnsweredQuestions, vm) { const self = vm ?? this; // clear answerData if no questions are already answered @@ -124,8 +124,8 @@ export default { } }); - // advance the currentGlassPieceIndex - self.currentGlassPieceIndex = i; + // advance the currentGlassIndex + self.currentGlassIndex = index; const answerResult = answeredGlass.partNum ? answeredGlass.partNum @@ -182,9 +182,9 @@ export default { // HANDLE DUPLICATE QUESTIONS - // loop through all glass pieces data - self.questionsData.forEach((glassPiece, pieceIndex) => { - /* glassPiece example format: + // loop through all glass data + self.questionsData.forEach((glass, glassIndex) => { + /* glass example format: { "glassName": "Single", "glassLocation": "Windshield", @@ -213,14 +213,14 @@ export default { */ // limit duplicate search to glass pieces that follow after the currently being answered glass piece - if (pieceIndex > answer.index) { + if (glassIndex > answer.index) { let indexToSuppressTo; // reset this glass piece, in case user is changing their previous answers - glassPiece.answerData = null; - glassPiece.isSuppressedPart = null; + glass.answerData = null; + glass.isSuppressedPart = null; // loop through this glass piece's questions, looking for a questionText match - glassPiece.questions.forEach((question, questionIndex) => { + glass.questions.forEach((question, questionIndex) => { // clear out any previously set answers question.answerSelected = null; @@ -248,7 +248,7 @@ export default { // handle duplicate's nextQuestion logic on other related questions if (matchedAnswer.nextQuestionSequence) { // clear any suppression on the nextQuestion - glassPiece.questions[ + glass.questions[ matchedAnswer.nextQuestionSequence - 1 ].suppressThisQuestion = null; // if the duplicate is 1ST question in array, set indexToSuppressTo @@ -263,7 +263,7 @@ export default { } // update answers in this glass piece's questions with duplication logic modifications - glassPiece.questions.forEach((q) => { + glass.questions.forEach((q) => { q.answers.forEach((a) => { // revert any previously set nextQuestion logic modifications if ( @@ -305,7 +305,7 @@ export default { question.suppressThisQuestion = true; // are there any questions left that are not suppressed? - const remainingQuestions = glassPiece.questions.filter((q) => { + const remainingQuestions = glass.questions.filter((q) => { return !q.suppressThisQuestion; }); @@ -320,7 +320,7 @@ export default { suppressThisQuestion: question.suppressThisQuestion, }; // set the answerData (used as indicator that it has been already answered) - glassPiece.answerData = { + glass.answerData = { answerResult: matchedAnswer.nextQuestionSequence ? matchedAnswer.nextQuestionSequence : matchedAnswer.answerResult, @@ -328,14 +328,14 @@ export default { }; // suppress this glass piece because it has an answer - glassPiece.isSuppressedPart = true; + glass.isSuppressedPart = true; } } }); // Update key to force re-render of glass piece with duplicate question in case user changes previous related answer in the chain - self.questionsData[pieceIndex].key = - self.questionsData[pieceIndex].key + Date.now().toString(); + self.questionsData[glassIndex].key = + self.questionsData[glassIndex].key + Date.now().toString(); } }); }); @@ -350,7 +350,7 @@ export default { for (let i = answer.index + 1; i < this.questionsData.length; i++) { // if this part has not yet been fully answered, then make it the current part if (!this.questionsData[i].answerData?.answerResult) { - this.currentGlassPieceIndex = i; + this.currentGlassIndex = i; break; } } diff --git a/src/mixins/vehicle-questions-mixin.spec.js b/src/mixins/vehicle-questions-mixin.spec.js index 6fb8f33d8..873614fc4 100644 --- a/src/mixins/vehicle-questions-mixin.spec.js +++ b/src/mixins/vehicle-questions-mixin.spec.js @@ -664,10 +664,10 @@ describe("vehicle-questions-mixin", () => { // Act wrapper.vm.handleAnswerUpdates(answerNo, "", wrapper.vm); - const glassPieceWithDuplicate = wrapper.vm.questionsData[1]; + const glassWithDuplicate = wrapper.vm.questionsData[1]; // Assert - expect(glassPieceWithDuplicate.key).not.toBe("testkey2"); + expect(glassWithDuplicate.key).not.toBe("testkey2"); }); test("then that question should be supressed", () => {