conditionally show endorsement questions

This commit is contained in:
Katie Kroell 2023-10-12 11:58:01 -04:00
parent 33420c6077
commit 8fbb991989

View file

@ -16,6 +16,7 @@
cmsWidgetName="SiteSubHeaderWidget" cmsWidgetName="SiteSubHeaderWidget"
class="mt-5" /> class="mt-5" />
<buttonQuestion <buttonQuestion
v-if="educatorEndorsement"
ref="schoolPropertyQuestion" ref="schoolPropertyQuestion"
v-model="schoolPropertyAnswer" v-model="schoolPropertyAnswer"
class="radioQuestion windshield-chip-count-question mb-4" class="radioQuestion windshield-chip-count-question mb-4"
@ -29,6 +30,7 @@
:validationRules="rules.selectionRequired"> :validationRules="rules.selectionRequired">
</buttonQuestion> </buttonQuestion>
<buttonQuestion <buttonQuestion
v-if="parkingGuardEndorsement"
ref="parkingLotQuestion" ref="parkingLotQuestion"
v-model="parkingLotAnswer" v-model="parkingLotAnswer"
class="radioQuestion windshield-chip-count-question" class="radioQuestion windshield-chip-count-question"
@ -117,6 +119,12 @@ export default {
}, },
parkingLotAnswersFromCms() { parkingLotAnswersFromCms() {
return this.getCmsContent('ParkingLotQuestion', 'Answers'); return this.getCmsContent('ParkingLotQuestion', 'Answers');
},
educatorEndorsement() {
return useMainStore().order.policy.endorsements.includes('Educator');
},
parkingGuardEndorsement() {
return useMainStore().order.policy.endorsements.includes('Parking Guard');
} }
}, },
methods: methods:
@ -126,18 +134,24 @@ export default {
}, },
async forwardButtonAction() { async forwardButtonAction() {
// TO DO: remove hard coding and update data format once service returns endorsement questions // TO DO: remove hard coding and update data format once service returns endorsement questions
if (this.educatorEndorsement) {
this.questionAnswersArray.push( this.questionAnswersArray.push(
{ {
questionNum: 1, questionNum: 1,
endorsement: 'Educator',
questionText: this.schoolPropertyQuestionText, questionText: this.schoolPropertyQuestionText,
selectedAnswer: this.schoolPropertyAnswer selectedAnswer: this.schoolPropertyAnswer
}, });
};
if (this.parkingGuardEndorsement) {
this.questionAnswersArray.push(
{ {
questionNum: 2, questionNum: 2,
endorsement: 'Parking Guard',
questionText: this.parkingLotQuestionText, questionText: this.parkingLotQuestionText,
selectedAnswer: this.parkingLotAnswer selectedAnswer: this.parkingLotAnswer
} });
); };
// save answers to store as order.policy.endorsementQuestionAnswers // save answers to store as order.policy.endorsementQuestionAnswers
useMainStore().saveEndorsementQuestionAnswers(this.questionAnswersArray); useMainStore().saveEndorsementQuestionAnswers(this.questionAnswersArray);