Changes for SSR-442, Defect SSR-463 and a little bit of cleanup for SSR-290

This commit is contained in:
DavidAtSafelite 2023-05-10 08:52:10 -04:00
parent 519f936e13
commit ff0d877170
5 changed files with 107 additions and 81 deletions

View file

@ -147,6 +147,11 @@
this.mainStore.issConfig.disabledFields.policyNumber = true;
break;
case "policyzipcode":
this.mainStore.order.policy.policyZipCode = value;
this.mainStore.issConfig.disabledFields.policyZipCode = true;
break;
case "lossdate":
// NOTE: May need some date parsing logic in here depending on client.
this.mainStore.order.policy.dateOfLoss = value;
@ -167,7 +172,7 @@
break;
}
}
},
}
},
computed:{
},

View file

@ -95,9 +95,12 @@ export default {
name: "vehicle-damage",
mixins: [BaseFormMixin],
async beforeRouteEnter(to, from, next) {
const store = useMainStore();
// Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
const damageOptionsPromise = useMainStore().getDamageOptions(useMainStore().order.vehicle.carId);
const damageOptionsPromise = store.getDamageOptions(store.order.vehicle.carId);
// Settle promises and get results
const promiseResultMap = [

View file

@ -108,7 +108,7 @@ data() {
},
computed: {
isForwardActionDisabled() {
return this.selectedGlassPartNumbers.length !== this.PartsFromApi.partsOrQuestions.length
return this.selectedGlassPartNumbers?.length !== this.PartsFromApi.partsOrQuestions?.length
},
selectedGlassPartNumbers() {
// Compile all selected parts from the page.
@ -124,7 +124,7 @@ computed: {
const partsData = this.PartsFromApi;
// Map API result data, to vehicle-parts data structure
const mappedData = partsData.partsOrQuestions.map((g) => {
const mappedData = partsData.partsOrQuestions?.map((g) => {
return {
glassName: g.glassName,
glassLocation: g.glassLocation,

View file

@ -18,13 +18,15 @@
validationRules="policy-number-required" />
</div>
</div>
<div class="row mt-4 " v-if="this.displayPolicyZip">
<div class="row mt-4" v-if="this.displayPolicyZip">
<div class="col">
<textboxQuestion
inputId="policyZipCode"
cmsWidgetName="PolicyZipQuestion"
v-model="welcomePageModel.policyZipCode"
isRequired
ref="policyZip" />
ref="policyZip"
validationRules="policy-zip-required|policy-zip-format" />
</div>
</div>
<div class="row mt-4">
@ -152,51 +154,49 @@
</template>
<script>
// Components
import siteHeader from '@/iss-components/site-header/site-header';
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header';
import siteFooter from "@/iss-components/site-footer/site-footer";
import textboxQuestion from "@/digital-components/textbox-question/textbox-question";
import buttonQuestion from "@/digital-components/button-question/button-question";
import dropdownQuestion from "@/digital-components/dropdown-question/dropdown-question";
import textBlock from "@/digital-components/text-block/text-block";
// Components
import siteHeader from '@/iss-components/site-header/site-header';
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header';
import siteFooter from "@/iss-components/site-footer/site-footer";
import textboxQuestion from "@/digital-components/textbox-question/textbox-question";
import buttonQuestion from "@/digital-components/button-question/button-question";
import dropdownQuestion from "@/digital-components/dropdown-question/dropdown-question";
import textBlock from "@/digital-components/text-block/text-block";
// Supporting files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
import { Form, defineRule } from "vee-validate";
import { required, regex } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages";
import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store';
import { states } from "@/constants/states"
// Supporting files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
import { Form, defineRule } from "vee-validate";
import { required, regex } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages";
import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { useMainStore } from '@/store';
import { states } from "@/constants/states"
//define validation rules
defineRule("loss-date-required", required(errorMessages.LOSS_DATE_REQUIRED));
defineRule("loss-cause-required", required(errorMessages.LOSS_CAUSE_REQUIRED));
defineRule("policy-number-required", required(errorMessages.POLICY_NUMBER_REQUIRED));
defineRule("loss-date-required", required(errorMessages.LOSS_DATE_REQUIRED));
defineRule("loss-state-required", required(errorMessages.LOSS_STATE_REQUIRED));
defineRule("loss-city-required", required(errorMessages.LOSS_CITY_REQUIRED));
defineRule("phone-number-required", required(errorMessages.PHONE_NUMBER_FORMAT));
defineRule("email-address-required", required(errorMessages.EMAIL_ADDRESS_REQUIRED));
defineRule("damage-option-required", required(errorMessages.DAMAGE_OPTION_REQUIRED));
defineRule("policy-zip-required", required(errorMessages.POLICY_ZIP_REQUIRED));
defineRule("policy-zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.POLICY_ZIP_FORMAT));
//define validation rules
defineRule("loss-date-required", required(errorMessages.LOSS_DATE_REQUIRED));
defineRule("loss-cause-required", required(errorMessages.LOSS_CAUSE_REQUIRED));
defineRule("policy-number-required", required(errorMessages.POLICY_NUMBER_REQUIRED));
defineRule("loss-date-required", required(errorMessages.LOSS_DATE_REQUIRED));
defineRule("loss-state-required", required(errorMessages.LOSS_STATE_REQUIRED));
defineRule("loss-city-required", required(errorMessages.LOSS_CITY_REQUIRED));
defineRule("phone-number-required", required(errorMessages.PHONE_NUMBER_FORMAT));
defineRule("email-address-required", required(errorMessages.EMAIL_ADDRESS_REQUIRED));
defineRule("damage-option-required", required(errorMessages.DAMAGE_OPTION_REQUIRED));
defineRule("policy-zip-required", required(errorMessages.POLICY_ZIP_REQUIRED));
defineRule("policy-zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.POLICY_ZIP_FORMAT));
defineRule("email-address-format",
regex(
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/,
errorMessages.EMAIL_ADDRESS_FORMAT
)
);
defineRule("email-address-format",
regex(
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/,
errorMessages.EMAIL_ADDRESS_FORMAT
));
defineRule("phone-number-format",
regex(
/^(\([0-9]{3}\)|[0-9]{3}) *[-.]? *[0-9]{3} *[-.]? *[0-9]{4}$/,
errorMessages.PHONE_NUMBER_FORMAT
)
);
defineRule("phone-number-format",
regex(
/^(\([0-9]{3}\)|[0-9]{3}) *[-.]? *[0-9]{3} *[-.]? *[0-9]{4}$/,
errorMessages.PHONE_NUMBER_FORMAT
));
export default {
name: "welcome-page",
@ -249,7 +249,8 @@ export default {
},
getWelcomePageModelFromStore() {
return {
policyNumber : this.mainStore.order.policy.policyNumber,
policyNumber: this.mainStore.order.policy.policyNumber,
policyZipCode: this.mainStore.order.policy.policyZipCode,
dateOfLoss : this.mainStore.order.policy.dateOfLoss,
damageCause : this.mainStore.order.policy.damageCause,
damageState : this.mainStore.order.policy.damageState,
@ -257,7 +258,7 @@ export default {
isDamageGlassOnly : this.mainStore.order.policy.isDamageGlassOnly,
phoneNumber : this.mainStore.order.customer.phoneNumber,
email : this.mainStore.order.customer.emailAddress,
isPolicyNumberDisabled: this.mainStore.order.policy.isPolicyNumberDisabled,
isPolicyNumberDisabled: this.mainStore.order.policy.isPolicyNumberDisabled
}
},
},
@ -293,7 +294,8 @@ export default {
return !!this.getCmsContent("GlassOnlyQuestion","QuestionText");
},
displayPolicyZip(){
if(this.mainStore.issConfig.isAuthenticated){
if (this.mainStore.issConfig.isAuthenticated &&
!!this.mainStore.issConfig.disabledFields.policyZipCode) {
return false;
}
else{

View file

@ -43,6 +43,7 @@ const getDefaultState = () => {
},
policy: {
policyNumber: null,
policyZipCode: null,
dateOfLoss: null,
damageCause: null,
damageState: null,
@ -106,7 +107,8 @@ const getDefaultState = () => {
returnURL: null,
returnURL2: null,
disabledFields: {
policyNumber: null
policyNumber: null,
policyZipCode: null
}
}
};
@ -608,6 +610,7 @@ export const useMainStore = defineStore({
if (isDamageChanging) {
//Reset dependent state when changing
//Was resetGlassPartsState, added dependencies for SSR-290
this.resetPartsAndDependencies();
// Save new values
@ -668,7 +671,9 @@ export const useMainStore = defineStore({
this.order.vehicle.imageVifNumber = vehicle.imageVifNumber;
this.order.vehicle.imageColor = vehicle.imageVifColor;
this.resetDamagePartsAndDependencies();
// added for SSR-290
this.resetSupportingItemsState();
this.resetVapsState();
},
updateVehicleVin(vin) {
@ -694,10 +699,10 @@ export const useMainStore = defineStore({
this.order.damage.partQuestionAnswers = null;
this.order.damage.moldingQuestionAnswers = null;
this.order.damage.capabilityQuestionAnswers = null;
this.applicationUser.pageData[issPageValues.PART_QUESTIONS] = null;
this.applicationUser.pageData[issPageValues.VEHICLE_PARTS] = null;
this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = null;
this.applicationUser.pageData[issPageValues.CAPABILITY_QUESTIONS] = null;
this.applicationUser.pageData[issPageValues.PART_QUESTIONS] = {};
this.applicationUser.pageData[issPageValues.VEHICLE_PARTS] = {};
this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = {};
this.applicationUser.pageData[issPageValues.CAPABILITY_QUESTIONS] = {};
},
resetSupportingItemsState() {
@ -715,8 +720,8 @@ export const useMainStore = defineStore({
resetMoldingAndCapabilityQuestionAnswersIfNeeded(matchedParts) {
const partsOrQuestionsDataToCompareWith =
this.pageData(issPageValues.MOLDING_QUESTIONS)?.partsOrQuestions ??
this.pageData(issPageValues.CAPABILITY_QUESTIONS)?.partsOrQuestions ??
[];
this.pageData(issPageValues.CAPABILITY_QUESTIONS)?.partsOrQuestions ??
[];
const previouslySelectedPartNumbers = getAllPartNumbers(partsOrQuestionsDataToCompareWith);
const currentlySelectedPartNumbers = getAllPartNumbers(matchedParts);
@ -725,11 +730,12 @@ export const useMainStore = defineStore({
previouslySelectedPartNumbers !== currentlySelectedPartNumbers;
if (haveSelectedVehiclePartsChanged) {
//was updateGlassParts, added dependencies for SSR-290
this.resetPartsAndDependencies();
this.updateMoldingQuestionAnswers(null);
this.updateCapabilityQuestionAnswers(null);
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null});
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null});
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: {} });
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: {} });
}
},
@ -743,14 +749,16 @@ export const useMainStore = defineStore({
this.issConfig.enableTPAFlow = false;
this.issConfig.returnURL = null;
this.issConfig.returnURL2 = null;
this.issConfig.disabledFields.policyNumber = null;
this.issConfig.disabledFields.policyNumber = false;
this.issConfig.disabledFields.policyZipCode = false;
},
updateVehicleYear(year) {
if(this.order.vehicle.year !== year)
{
this.resetVehicleState();
this.resetDamagePartsAndDependencies();
// was resetDamageState, added dependencies for SSR-290
this.resetDamageAndDependencies();
this.order.vehicle.year = year;
}
@ -762,7 +770,8 @@ export const useMainStore = defineStore({
const year = this.order.vehicle.year;
this.resetVehicleState();
this.resetDamagePartsAndDependencies();
// was resetDamageState, added dependencies for SSR-290
this.resetDamageAndDependencies();
this.order.vehicle.year = year;
this.order.vehicle.make = make;
@ -776,7 +785,8 @@ export const useMainStore = defineStore({
const make = this.order.vehicle.make;
this.resetVehicleState();
this.resetDamagePartsAndDependencies();
// was resetDamageState, added dependencies for SSR-290
this.resetDamageAndDependencies();
this.order.vehicle.year = year;
this.order.vehicle.make = make;
@ -793,7 +803,8 @@ export const useMainStore = defineStore({
const model = this.order.vehicle.model;
this.resetVehicleState();
this.resetDamagePartsAndDependencies();
// was resetDamageState, added dependencies for SSR-290
this.resetDamageAndDependencies();
this.order.vehicle.year = year;
this.order.vehicle.make = make;
@ -831,11 +842,12 @@ export const useMainStore = defineStore({
},
updatePageData(pageData) {
this.applicationUser.pageData[pageData.page] = pageData.data;
this.applicationUser.pageData[pageData.page] = (!!pageData.data) ? pageData.data : {};
},
updatePolicyData(welcomePageModel)
{
this.order.policy.policyNumber = welcomePageModel?.policyNumber;
this.order.policy.policyZipCode = welcomePageModel?.policyZipCode;
this.order.policy.dateOfLoss = welcomePageModel?.dateOfLoss;
this.order.policy.damageCause = welcomePageModel?.damageCause;
this.order.policy.damageState = welcomePageModel?.damageState;
@ -874,16 +886,18 @@ export const useMainStore = defineStore({
this.updateGlassParts(null);
this.updateMoldingQuestionAnswers(null);
this.updateCapabilityQuestionAnswers(null);
this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: null});
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null});
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null});
// Added for SSR-290
this.resetSupportingItemsState();
this.resetVapsState();
this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: {} });
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: {} });
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: {} });
}
//Save new values
this.updatePartQuestionAnswers(partQuestionAnswersArray);
this.resetSupportingItemsState();
this.resetVapsState();
},
saveMoldingQuestionAnswers(moldingQuestionAnswersArray) {
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(
@ -901,12 +915,10 @@ export const useMainStore = defineStore({
);
if (haveMoldingQuestionAnswersChanged) {
// was updateGlassParts(null), added dependencies for SSR-290
this.resetPartsAndDependencies();
this.updateCapabilityQuestionAnswers(null);
this.updatePageData({
page: issPageValues.CAPABILITY_QUESTIONS,
data: null
});
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: {} });
}
// Save new values
@ -929,8 +941,8 @@ export const useMainStore = defineStore({
);
if (haveCapabilityQuestionAnswersChanged) {
this.updateGlassParts(null);
this.updateSupportingItems(null);
// was updateGlassPars(null), added dependencies for SSR-290
this.resetPartsAndDependencies();
}
// Save new values
@ -1158,6 +1170,7 @@ export const useMainStore = defineStore({
if (!isSelectedGlassAvailableForVehicle) {
this.resetDamageState();
this.resetGlassPartsState();
}
//Save new values
@ -1173,6 +1186,7 @@ export const useMainStore = defineStore({
if (!isSelectedGlassAvailableForVehicle) {
this.resetDamageState();
this.resetGlassPartsState();
}
//Save new values
@ -1186,8 +1200,10 @@ export const useMainStore = defineStore({
{
this.resetRegistrationAndDependencies();
if (!isSelectedGlassAvailableForVehicle) {
if (!isSelectedGlassAvailableForVehicle) {
// Dependencies already cleared in above statement
this.resetDamageState();
this.resetGlassPartsState();
}
//Save new values
@ -1204,9 +1220,9 @@ export const useMainStore = defineStore({
this.resetVapsState();
},
resetDamagePartsAndDependencies() {
//this.resetDamageState();
//this.resetGlassPartsState();
resetDamageAndDependencies() {
this.resetDamageState();
this.resetGlassPartsState();
this.resetSupportingItemsState();
this.resetVapsState();
},