This commit is contained in:
Jason Wheeler 2023-05-17 10:52:13 -04:00
parent 3ac9d786d3
commit 8593c32ae3
4 changed files with 143 additions and 104 deletions

View file

@ -1,5 +1,5 @@
const queryStrings = { const queryStrings = {
ISS_PAGE: 'issPage' ISS_PAGE: 'issPage',
}; };
export { queryStrings }; export { queryStrings };

View file

@ -33,15 +33,17 @@
this.$route this.$route
); );
}, },
async validateClientTagOnEntry() { parseQueryParms() {
// Dump the query string parameters into an array. Remove casing on the key for easy compare. // Dump the query string parameters into an array. Remove casing on the key for easy compare.
let queryStringParams = []; let queryStringParams = [];
for ( let param in this.$route.query) for ( let param in this.$route.query)
{ {
queryStringParams[param.toLowerCase()] = this.$route.query[param]; queryStringParams[param.toLowerCase()] = this.$route.query[param];
} }
return queryStringParams;
},
async validateClientTagOnEntry() {
const queryStringParams = this.parseQueryParms();
const clientTag = queryStringParams["clienttag"]; const clientTag = queryStringParams["clienttag"];
const clientTagPresent = !!clientTag; const clientTagPresent = !!clientTag;
let authorized = false; let authorized = false;

View file

@ -1,6 +1,6 @@
<template> <template>
<dropdownQuestion <dropdownQuestion
:options="Options" :options="values"
disableAutoFill disableAutoFill
placeHolderText="Select an option" placeHolderText="Select an option"
v-model="selectedValue" v-model="selectedValue"
@ -31,18 +31,28 @@ export default {
return this.modelValue?.toString(); return this.modelValue?.toString();
}, },
set: function(newValue) { set: function(newValue) {
this.$emit("update:modelValue",newValue?.toString()); if(newValue)
{
const val = this.values[newValue]
this.$emit("update:modelValue", val);
}
else
{
this.$emit("update:modelValue", null);
}
} }
}, },
Options() {
return this.values;
},
}, },
methods: { methods: {
async getNewValues() { async getNewValues() {
const results = await this.updateValues(); const results = await this.updateValues();
this.values = results?.data; this.values = results?.data;
this.selectedValue = null;
}, },
clearValues() {
this.values = [];
this.selectedValue = null;
}
}, },
}; };
</script> </script>

View file

@ -15,6 +15,7 @@
<vehicleQuestion class="px-4 mb-2 mt-4" v-model="selectedStyle" ref="vehicleStyleQuestion" cmsWidgetName="VehicleStyleQuestion" :updateValues="updateStyleValues" validationRules="style-required" inputId="styleQuestionField"/> <vehicleQuestion class="px-4 mb-2 mt-4" v-model="selectedStyle" ref="vehicleStyleQuestion" cmsWidgetName="VehicleStyleQuestion" :updateValues="updateStyleValues" validationRules="style-required" inputId="styleQuestionField"/>
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage="true" class="mt-5 mb-3" /> <vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage="true" class="mt-5 mb-3" />
<siteFooter <siteFooter
class="mx-4"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ -37,7 +38,7 @@ import siteHeader from "@/iss-components/site-header/site-header";
import siteFooter from "@/iss-components/site-footer/site-footer"; import siteFooter from "@/iss-components/site-footer/site-footer";
import siteSubHeader from "@/iss-components/site-sub-header/site-sub-header"; import siteSubHeader from "@/iss-components/site-sub-header/site-sub-header";
import vehicleBanner from "@/iss-components/vehicle-banner/vehicle-banner"; import vehicleBanner from "@/iss-components/vehicle-banner/vehicle-banner";
import vehicleQuestion from "@/iss-components/vehicle-question/vehicle-question"; import vehicleQuestion from "@/layouts/vehicle-selection/vehicle-question/vehicle-question.vue";
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
// Supporting files // Supporting files
@ -65,110 +66,136 @@ export default {
selectedStyle: null, selectedStyle: null,
}; };
}, },
props:{ props:{
cmsWidgetName:String, cmsWidgetName:String,
validationRules:String, validationRules:String,
}, },
mounted(){ mounted(){
this.Years.getNewValues(); this.Years.getNewValues();
}, },
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
// Settle promises and get results // Settle promises and get results
const promiseResultMap = [ const promiseResultMap = [
{ {
resultKey: "cmsContent", resultKey: "cmsContent",
promise: cmsContentPromise, promise: cmsContentPromise,
}, },
]; ];
let resultMap = await settleAllPromises(promiseResultMap); let resultMap = await settleAllPromises(promiseResultMap);
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
}); });
},
watch: {
selectedYear(yearIndex) {
const parsedYearIndex = parseInt(yearIndex);
this.mainStore.updateVehicleYear(this.Years.values[parsedYearIndex]);
this.Makes.getNewValues();
},
selectedMake(makeIndex) {
const parsedMakeIndex = parseInt(makeIndex);
this.mainStore.updateVehicleMake(this.Makes.values[parsedMakeIndex]);
this.Models.getNewValues();
},
selectedModel(modelIndex) {
const parsedModelIndex = parseInt(modelIndex);
this.mainStore.updateVehicleModel(this.Models.values[parsedModelIndex]);
this.Styles.getNewValues();
},
selectedStyle(styleIndex) {
const parsedStyleIndex = parseInt(styleIndex);
this.mainStore.updateVehicleStyle(this.Styles.values[parsedStyleIndex]);
},
},
computed:{
Years(){
return this.$refs["vehicleYearQuestion"];
}, },
Makes(){ watch: {
return this.$refs["vehicleMakeQuestion"]; selectedYear(value) {
this.mainStore.updateVehicleYear(value);
if(value)
{
this.Makes.getNewValues();
}
else{
this.Makes.clearValues();
}
},
selectedMake(value) {
this.mainStore.updateVehicleMake(value);
if(value)
{
this.Models.getNewValues();
}
else{
this.Models.clearValues();
}
},
selectedModel(value) {
this.mainStore.updateVehicleModel(value);
if(value)
{
this.Styles.getNewValues();
}
else{
this.Styles.clearValues();
}
},
selectedStyle(value) {
this.mainStore.updateVehicleStyle(value);
},
}, },
Models(){ computed:{
return this.$refs["vehicleModelQuestion"]; Years(){
}, return this.$refs["vehicleYearQuestion"];
Styles(){ },
return this.$refs["vehicleStyleQuestion"]; Makes(){
} return this.$refs["vehicleMakeQuestion"];
},
Models(){
return this.$refs["vehicleModelQuestion"];
},
Styles(){
return this.$refs["vehicleStyleQuestion"];
}
}, },
methods: { methods: {
arePagePrerequisitesValid() { handleValueChange(thisQuestion, nextQuestion, storeMethod, index)
return true; {
}, if(index === 0)
backButtonAction() { {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); storeMethod(null);
}, nextQuestion.clearValues();
async forwardButtonAction() { }
return this.navigateForward(); else{
}, storeMethod(thisQuestion.values[index]);
nextQuestion.getNewValues();
}
},
arePagePrerequisitesValid() {
return true;
},
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
async forwardButtonAction() {
return this.navigateForward();
},
navigateForward() { navigateForward() {
this.mainStore.setVehicle().then(() => { this.mainStore.setVehicle().then(() => {
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD, this.navigationScenarios.CLICKED_FORWARD,
this.$route this.$route
); );
}); });
}, },
async updateYearValues() { async updateYearValues() {
return await useMainStore().getVehicleYears(); return await useMainStore().getVehicleYears();
}, },
async updateMakeValues() { async updateMakeValues() {
return await this.mainStore.getVehicleMakes(); return await this.mainStore.getVehicleMakes();
}, },
async updateModelValues() { async updateModelValues() {
return await this.mainStore.getVehicleModels(); return await this.mainStore.getVehicleModels();
}, },
async updateStyleValues() { async updateStyleValues() {
return await this.mainStore.getVehicleStyles(); return await this.mainStore.getVehicleStyles();
}, },
},
components: {
siteHeader,
siteSubHeader,
vehicleBanner,
siteFooter,
Form,
vehicleQuestion
}, },
components: {
siteHeader,
siteSubHeader,
vehicleBanner,
siteFooter,
Form,
vehicleQuestion
},
}; };
</script> </script>