Merge pull request #292 from Safelite/feature/Digital/SSR-442

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 11:32:38 -04:00 committed by GitHub
commit 8f27feb9f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 76 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -43,6 +43,7 @@ const getDefaultState = () => {
}, },
policy: { policy: {
policyNumber: null, policyNumber: null,
policyZipCode: null,
dateOfLoss: null, dateOfLoss: null,
damageCause: null, damageCause: null,
damageState: null, damageState: null,
@ -106,7 +107,8 @@ const getDefaultState = () => {
returnURL: null, returnURL: null,
returnURL2: null, returnURL2: null,
disabledFields: { disabledFields: {
policyNumber: null policyNumber: null,
policyZipCode: null
} }
} }
}; };
@ -608,6 +610,7 @@ export const useMainStore = defineStore({
if (isDamageChanging) { if (isDamageChanging) {
//Reset dependent state when changing //Reset dependent state when changing
//Was resetGlassPartsState, added dependencies for SSR-290
this.resetPartsAndDependencies(); this.resetPartsAndDependencies();
// Save new values // Save new values
@ -668,7 +671,8 @@ export const useMainStore = defineStore({
this.order.vehicle.imageVifNumber = vehicle.imageVifNumber; this.order.vehicle.imageVifNumber = vehicle.imageVifNumber;
this.order.vehicle.imageColor = vehicle.imageVifColor; this.order.vehicle.imageColor = vehicle.imageVifColor;
this.resetDamagePartsAndDependencies(); this.resetSupportingItemsState();
this.resetVapsState();
}, },
updateVehicleVin(vin) { updateVehicleVin(vin) {
@ -715,8 +719,8 @@ export const useMainStore = defineStore({
resetMoldingAndCapabilityQuestionAnswersIfNeeded(matchedParts) { resetMoldingAndCapabilityQuestionAnswersIfNeeded(matchedParts) {
const partsOrQuestionsDataToCompareWith = const partsOrQuestionsDataToCompareWith =
this.pageData(issPageValues.MOLDING_QUESTIONS)?.partsOrQuestions ?? this.pageData(issPageValues.MOLDING_QUESTIONS)?.partsOrQuestions ??
this.pageData(issPageValues.CAPABILITY_QUESTIONS)?.partsOrQuestions ?? this.pageData(issPageValues.CAPABILITY_QUESTIONS)?.partsOrQuestions ??
[]; [];
const previouslySelectedPartNumbers = getAllPartNumbers(partsOrQuestionsDataToCompareWith); const previouslySelectedPartNumbers = getAllPartNumbers(partsOrQuestionsDataToCompareWith);
const currentlySelectedPartNumbers = getAllPartNumbers(matchedParts); const currentlySelectedPartNumbers = getAllPartNumbers(matchedParts);
@ -725,11 +729,12 @@ export const useMainStore = defineStore({
previouslySelectedPartNumbers !== currentlySelectedPartNumbers; previouslySelectedPartNumbers !== currentlySelectedPartNumbers;
if (haveSelectedVehiclePartsChanged) { if (haveSelectedVehiclePartsChanged) {
//was updateGlassParts, added dependencies for SSR-290
this.resetPartsAndDependencies(); this.resetPartsAndDependencies();
this.updateMoldingQuestionAnswers(null); this.updateMoldingQuestionAnswers(null);
this.updateCapabilityQuestionAnswers(null); this.updateCapabilityQuestionAnswers(null);
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null}); this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null });
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null}); this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null });
} }
}, },
@ -743,14 +748,15 @@ export const useMainStore = defineStore({
this.issConfig.enableTPAFlow = false; this.issConfig.enableTPAFlow = false;
this.issConfig.returnURL = null; this.issConfig.returnURL = null;
this.issConfig.returnURL2 = null; this.issConfig.returnURL2 = null;
this.issConfig.disabledFields.policyNumber = null; this.issConfig.disabledFields.policyNumber = false;
this.issConfig.disabledFields.policyZipCode = false;
}, },
updateVehicleYear(year) { updateVehicleYear(year) {
if(this.order.vehicle.year !== year) if(this.order.vehicle.year !== year)
{ {
this.resetVehicleState(); this.resetVehicleState();
this.resetDamagePartsAndDependencies(); this.resetDamageAndDependencies();
this.order.vehicle.year = year; this.order.vehicle.year = year;
} }
@ -762,7 +768,7 @@ export const useMainStore = defineStore({
const year = this.order.vehicle.year; const year = this.order.vehicle.year;
this.resetVehicleState(); this.resetVehicleState();
this.resetDamagePartsAndDependencies(); this.resetDamageAndDependencies();
this.order.vehicle.year = year; this.order.vehicle.year = year;
this.order.vehicle.make = make; this.order.vehicle.make = make;
@ -776,7 +782,7 @@ export const useMainStore = defineStore({
const make = this.order.vehicle.make; const make = this.order.vehicle.make;
this.resetVehicleState(); this.resetVehicleState();
this.resetDamagePartsAndDependencies(); this.resetDamageAndDependencies();
this.order.vehicle.year = year; this.order.vehicle.year = year;
this.order.vehicle.make = make; this.order.vehicle.make = make;
@ -793,7 +799,7 @@ export const useMainStore = defineStore({
const model = this.order.vehicle.model; const model = this.order.vehicle.model;
this.resetVehicleState(); this.resetVehicleState();
this.resetDamagePartsAndDependencies(); this.resetDamageAndDependencies();
this.order.vehicle.year = year; this.order.vehicle.year = year;
this.order.vehicle.make = make; this.order.vehicle.make = make;
@ -836,6 +842,7 @@ export const useMainStore = defineStore({
updatePolicyData(welcomePageModel) updatePolicyData(welcomePageModel)
{ {
this.order.policy.policyNumber = welcomePageModel?.policyNumber; this.order.policy.policyNumber = welcomePageModel?.policyNumber;
this.order.policy.policyZipCode = welcomePageModel?.policyZipCode;
this.order.policy.dateOfLoss = welcomePageModel?.dateOfLoss; this.order.policy.dateOfLoss = welcomePageModel?.dateOfLoss;
this.order.policy.damageCause = welcomePageModel?.damageCause; this.order.policy.damageCause = welcomePageModel?.damageCause;
this.order.policy.damageState = welcomePageModel?.damageState; this.order.policy.damageState = welcomePageModel?.damageState;
@ -874,16 +881,17 @@ export const useMainStore = defineStore({
this.updateGlassParts(null); this.updateGlassParts(null);
this.updateMoldingQuestionAnswers(null); this.updateMoldingQuestionAnswers(null);
this.updateCapabilityQuestionAnswers(null); this.updateCapabilityQuestionAnswers(null);
this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: null}); this.resetSupportingItemsState();
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null}); this.resetVapsState();
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: 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 });
} }
//Save new values //Save new values
this.updatePartQuestionAnswers(partQuestionAnswersArray); this.updatePartQuestionAnswers(partQuestionAnswersArray);
this.resetSupportingItemsState();
this.resetVapsState();
}, },
saveMoldingQuestionAnswers(moldingQuestionAnswersArray) { saveMoldingQuestionAnswers(moldingQuestionAnswersArray) {
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue( const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(
@ -903,10 +911,7 @@ export const useMainStore = defineStore({
if (haveMoldingQuestionAnswersChanged) { if (haveMoldingQuestionAnswersChanged) {
this.resetPartsAndDependencies(); this.resetPartsAndDependencies();
this.updateCapabilityQuestionAnswers(null); this.updateCapabilityQuestionAnswers(null);
this.updatePageData({ this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null });
page: issPageValues.CAPABILITY_QUESTIONS,
data: null
});
} }
// Save new values // Save new values
@ -929,8 +934,7 @@ export const useMainStore = defineStore({
); );
if (haveCapabilityQuestionAnswersChanged) { if (haveCapabilityQuestionAnswersChanged) {
this.updateGlassParts(null); this.resetPartsAndDependencies();
this.updateSupportingItems(null);
} }
// Save new values // Save new values
@ -1158,6 +1162,7 @@ export const useMainStore = defineStore({
if (!isSelectedGlassAvailableForVehicle) { if (!isSelectedGlassAvailableForVehicle) {
this.resetDamageState(); this.resetDamageState();
this.resetGlassPartsState();
} }
//Save new values //Save new values
@ -1173,6 +1178,7 @@ export const useMainStore = defineStore({
if (!isSelectedGlassAvailableForVehicle) { if (!isSelectedGlassAvailableForVehicle) {
this.resetDamageState(); this.resetDamageState();
this.resetGlassPartsState();
} }
//Save new values //Save new values
@ -1186,8 +1192,10 @@ export const useMainStore = defineStore({
{ {
this.resetRegistrationAndDependencies(); this.resetRegistrationAndDependencies();
if (!isSelectedGlassAvailableForVehicle) { if (!isSelectedGlassAvailableForVehicle) {
// Dependencies already cleared in above statement
this.resetDamageState(); this.resetDamageState();
this.resetGlassPartsState();
} }
//Save new values //Save new values
@ -1204,9 +1212,9 @@ export const useMainStore = defineStore({
this.resetVapsState(); this.resetVapsState();
}, },
resetDamagePartsAndDependencies() { resetDamageAndDependencies() {
//this.resetDamageState(); this.resetDamageState();
//this.resetGlassPartsState(); this.resetGlassPartsState();
this.resetSupportingItemsState(); this.resetSupportingItemsState();
this.resetVapsState(); this.resetVapsState();
}, },