Adding textbox question page

This commit is contained in:
Michaela Brydon 2023-11-02 09:42:43 -04:00
parent 5f395b3421
commit a388f2cff1
5 changed files with 923 additions and 120 deletions

View file

@ -30,7 +30,7 @@
:aria-label="questionText" :aria-label="questionText"
:min="min" :min="min"
:max="max" :max="max"
required :required="isRequired"
:class="[ :class="[
hasIcon ? 'has-icon' : '', hasIcon ? 'has-icon' : '',
iconRight ? 'icon-right' : '', iconRight ? 'icon-right' : '',
@ -59,6 +59,7 @@
</div> </div>
<div <div
v-show="errorMessage" v-show="errorMessage"
ref="errorMessageDiv"
class="row my-1 form-test-error"> class="row my-1 form-test-error">
<span <span
class="d-inline-flex mt-0" class="d-inline-flex mt-0"
@ -100,7 +101,10 @@ export default {
default: '' default: ''
}, },
validationRules: String, validationRules: String,
cmsWidgetName: String, cmsWidgetName: {
String,
default: ''
},
maxLength: String, maxLength: String,
questionAlignment: String, // Left or center. Left is default. questionAlignment: String, // Left or center. Left is default.
cornerStyle: String, // Rounded or square. Square is default. cornerStyle: String, // Rounded or square. Square is default.
@ -153,6 +157,7 @@ export default {
return this.modelValue; return this.modelValue;
}, },
set(newValue) { set(newValue) {
console.log('set happened');
this.$emit('update:modelValue', newValue); this.$emit('update:modelValue', newValue);
} }
}, },
@ -183,7 +188,9 @@ export default {
}, },
watch: { watch: {
async value(newValue) { async value(newValue) {
console.log('watch triggered');
const result = await validate(newValue, this.validationRules); // do a test validation check, without triggering full validation const result = await validate(newValue, this.validationRules); // do a test validation check, without triggering full validation
console.log(JSON.stringify(result));
if (result.valid) { if (result.valid) {
this.handleChange(newValue); // trigger full validation on this field only this.handleChange(newValue); // trigger full validation on this field only
} }

View file

@ -246,7 +246,8 @@ function mapStringToState(str) {
console.warn('Unable to resolve global state data.'); console.warn('Unable to resolve global state data.');
return ''; // if we can't map our string to state data, return an empty string. return ''; // if we can't map our string to state data, return an empty string.
} }
const stringWithReplacement = str.replace(match[0], valueFromStore); const valueFromStoreWrapped = `<span>${valueFromStore}</span>`;
const stringWithReplacement = str.replace(match[0], valueFromStoreWrapped);
// If we still have values we need to substitute, call this function again. // If we still have values we need to substitute, call this function again.
if (stringWithReplacement.includes(dynamicStrings.GLOBAL_STATE)) { if (stringWithReplacement.includes(dynamicStrings.GLOBAL_STATE)) {

View file

@ -89,7 +89,6 @@ export default {
}, },
mixins: [BaseFormMixin], mixins: [BaseFormMixin],
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
console.log('beforeRouteEnter');
// 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
@ -105,7 +104,6 @@ export default {
const pageData = useMainStore().pageData(to.query.issPage); const pageData = useMainStore().pageData(to.query.issPage);
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
console.log(JSON.stringify(pageData[routerParams.NOT_SEEING_PREFERRED_SHOP]));
vm.setNotSeeingPreferShop(pageData[routerParams.NOT_SEEING_PREFERRED_SHOP]); vm.setNotSeeingPreferShop(pageData[routerParams.NOT_SEEING_PREFERRED_SHOP]);
}); });
}, },
@ -176,7 +174,6 @@ export default {
}; };
}, },
setNotSeeingPreferShop(value) { setNotSeeingPreferShop(value) {
console.log(`set flag: ${value}`);
this.notSeeingPreferredShop = value ?? false; this.notSeeingPreferredShop = value ?? false;
} }
} }

View file

@ -93,6 +93,7 @@ import errorMessages from '@/constants/error-messages';
import damageLocationsCms from '@/constants/damage-locations-cms.js'; import damageLocationsCms from '@/constants/damage-locations-cms.js';
import damageLocationsSelected from '@/constants/damage-locations-selected.js'; import damageLocationsSelected from '@/constants/damage-locations-selected.js';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import routerParams from '@/router/router-constants/router-params';
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
defineRule('replace-options-required', required(errorMessages.REPLACE_OPTIONS_REQUIRED)); defineRule('replace-options-required', required(errorMessages.REPLACE_OPTIONS_REQUIRED));
@ -226,7 +227,7 @@ export default {
); );
}, },
shouldDisplayVehicleChangeAlert() { shouldDisplayVehicleChangeAlert() {
return this.$route.params[this.routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]; return this.$route.params[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT];
} }
}, },
methods: { methods: {