Hide/display fields based on the client tag

SSR-334
This commit is contained in:
Jethe 2023-04-18 13:38:13 +05:30
parent 0efa2a2c50
commit 964ae7553e
4 changed files with 37 additions and 1 deletions

View file

@ -13,10 +13,12 @@ export function fetchCmsContentForPage(issPage) {
(baseResponse) => {
if ( !clientOverride )
{
setClientTag(clientName,accountNumber);
// Return the base page if there are no client override.
return processPageData(baseResponse, null);
}
else {
setClientTag(clientName,accountNumber);
// Else get the client override page.
const pageName = issPage + "_" + clientName.toLowerCase().replace(/ /g, "");
@ -115,7 +117,17 @@ function processPageData(baseResponse, clientResponse) {
return pageDataFromCms;
}
//ClientTag function to identify essential or advance flow
function setClientTag(clientName,accountNumber)
{
const storeState = useMainStore();
if(clientName !="Generic Insurance" && accountNumber){
storeState.issConfig.flowType = "Advanced Flow";
}
if(clientName =="Generic Insurance" && accountNumber==0){
storeState.issConfig.flowType = "Essential Flow";
}
}
// Parent function for processWidgetItemForReplacement. This will loop through the parent
// object and pass any objects that need additional processing to the processWidgetItemForReplacement function.
function findAndReplaceGlobalStateValues(widgetModel, widgetName) {

View file

@ -35,6 +35,7 @@ describe("welcome-page.vue", () => {
const glassOnlyDamage = wrapper.findComponent({ ref: "glassOnlyDamage" });
const phoneNumber = wrapper.findComponent({ ref: "phoneNumber" });
const email = wrapper.findComponent({ ref: "email" });
const policyZip = wrapper.findComponent({ ref: "policyZip" });
// Assert
@ -46,6 +47,7 @@ describe("welcome-page.vue", () => {
expect(glassOnlyDamage.exists()).toBe(false);
expect(phoneNumber.exists()).toBe(true);
expect(email.exists()).toBe(true);
expect(policyZip.exists()).toBe(false);
});
});

View file

@ -17,6 +17,18 @@
validationRules="policy-number-required" />
</div>
</div>
<div class="row mt-4 px-3">
<div class="col">
<textboxQuestion
inputId="policyZipCode"
cmsWidgetName="PolicyZipQuestion"
v-model="welcomePageModel.policyZip"
isRequired
ref="policyZip"
v-if="this.displayPolicyZip"
validationRules="policy-zip-required|policy-zip-format" />
</div>
</div>
<div class="row mt-4 px-3">
<div class="col">
<textboxQuestion
@ -168,6 +180,8 @@ 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(
@ -242,6 +256,7 @@ export default {
isDamageGlassOnly : this.mainStore.order.policy.isDamageGlassOnly,
phoneNumber : this.mainStore.order.customer.phoneNumber,
email : this.mainStore.order.customer.emailAddress,
policyZip: this.mainStore.order.customer.policyZip,
}
},
},
@ -332,6 +347,11 @@ export default {
},
displayGlassOnlyQuestion(){
return !!this.getCmsContent("GlassOnlyQuestion","QuestionText");
},
displayPolicyZip(){
if(this.mainStore.issConfig.flowType=="Essential Flow"){
return true;
}
}
},
components: {

View file

@ -105,6 +105,7 @@ const getDefaultState = () => {
enableTPAFlow: false,
returnURL: null,
returnURL2: null,
flowType:"",
}
};
};
@ -613,6 +614,7 @@ export const useMainStore = defineStore({
this.issConfig.enableTPAFlow = false;
this.issConfig.returnURL = null;
this.issConfig.returnURL2 = null;
this.issConfig.flowType="";
},
updateVehicleYear(year) {