CSR-762 Add tests, fix some buttonsInfo logic
This commit is contained in:
parent
f8c11140f1
commit
751a04dc31
3 changed files with 1021 additions and 101 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -2,13 +2,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
:class="
|
:class="
|
||||||
isOverflowScrollable
|
isOverflowScrollable ? 'button-question button-question-overflow' : 'button-question'
|
||||||
? 'button-question button-question-overflow'
|
|
||||||
: 'button-question'
|
|
||||||
">
|
">
|
||||||
<div
|
<div v-if="questionText && answers && answers.length > 0" class="question-text d-flex">
|
||||||
v-if="questionText && answers && answers.length > 0"
|
|
||||||
class="question-text d-flex">
|
|
||||||
<span class="fw-bold w-100">{{ questionText }}</span>
|
<span class="fw-bold w-100">{{ questionText }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -51,8 +47,7 @@
|
||||||
:textPosition="textPosition"
|
:textPosition="textPosition"
|
||||||
:lastValuePushedToGa="lastValuePushedToGa"
|
:lastValuePushedToGa="lastValuePushedToGa"
|
||||||
:setLastValuePushedToGa="setLastValuePushedToGa"
|
:setLastValuePushedToGa="setLastValuePushedToGa"
|
||||||
v-model="selectedValues"
|
v-model="selectedValues" />
|
||||||
/>
|
|
||||||
<!-- For nested questions -->
|
<!-- For nested questions -->
|
||||||
<transition name="fade" mode="out-in">
|
<transition name="fade" mode="out-in">
|
||||||
<div
|
<div
|
||||||
|
|
@ -68,9 +63,7 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="row form-test-error mt-1">
|
<div class="row form-test-error mt-1">
|
||||||
<error-message
|
<error-message :name="formatString(groupName)" v-if="!suppressError"></error-message>
|
||||||
:name="formatString(groupName)"
|
|
||||||
v-if="!suppressError"></error-message>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -164,31 +157,19 @@ export default {
|
||||||
|
|
||||||
return classes;
|
return classes;
|
||||||
},
|
},
|
||||||
getColLength() {
|
|
||||||
if (this.isWide) {
|
|
||||||
return "12";
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
buttonsInfo() {
|
buttonsInfo() {
|
||||||
return (Array.isArray(this.answers) ? this.answers : [])?.map(
|
return (Array.isArray(this.answers) ? this.answers : [])?.map((answer) => ({
|
||||||
(answer) => ({
|
buttonLabel: answer.buttonLabel ?? answer.Text ?? answer,
|
||||||
buttonLabel: answer.buttonLabel ?? answer.Text ?? answer,
|
altText: answer.altText ?? (answer.Name ? answer.Name : answer),
|
||||||
altText:
|
buttonLabelSubCopy: answer.buttonLabelSubCopy ?? answer.SubText,
|
||||||
answer.altText ?? (answer.Name ? answer.Name : answer),
|
buttonImage: answer.buttonImage ?? answer.AnswerImageUrl,
|
||||||
buttonLabelSubCopy:
|
buttonImageId: answer.buttonImageId ?? answer.ImageId,
|
||||||
answer.buttonLabelSubCopy ?? answer.SubText,
|
groupName: this.formatString(this.groupName),
|
||||||
buttonImage: answer.buttonImage ?? answer.AnswerImageUrl,
|
value:
|
||||||
buttonImageId: answer.buttonImageId ?? answer.ImageId,
|
answer.value ??
|
||||||
groupName: this.formatString(this.groupName),
|
(this.useTextForValue && answer.Text ? answer.Text : answer.Name) ??
|
||||||
value:
|
(typeof answer === "string" ? answer : null),
|
||||||
answer.value ??
|
}));
|
||||||
(this.useTextForValue
|
|
||||||
? answer.Text
|
|
||||||
: answer.Name ?? answer),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
selectedValues: {
|
selectedValues: {
|
||||||
get() {
|
get() {
|
||||||
|
|
@ -196,30 +177,12 @@ export default {
|
||||||
},
|
},
|
||||||
set(selectedAnswers) {
|
set(selectedAnswers) {
|
||||||
this.$emit("update:modelValue", selectedAnswers);
|
this.$emit("update:modelValue", selectedAnswers);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatString(str) {
|
formatString(str) {
|
||||||
return str?.replace(" ", "-");
|
return str?.replaceAll(" ", "-");
|
||||||
},
|
|
||||||
getValue(answer) {
|
|
||||||
if (this.useTextForValue) {
|
|
||||||
return answer.Text;
|
|
||||||
}
|
|
||||||
return answer.Name ? answer.Name : answer;
|
|
||||||
},
|
|
||||||
getAnswerString(answer, prop = "Name") {
|
|
||||||
switch (typeof answer) {
|
|
||||||
case "string":
|
|
||||||
case "number":
|
|
||||||
case "boolean":
|
|
||||||
return this.formatString(answer.toString());
|
|
||||||
default:
|
|
||||||
return answer[prop]
|
|
||||||
? this.formatString(answer[prop])
|
|
||||||
: this.formatString(answer.toString());
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
setLastValuePushedToGa(lastValuePushedToGa) {
|
setLastValuePushedToGa(lastValuePushedToGa) {
|
||||||
this.lastValuePushedToGa = lastValuePushedToGa;
|
this.lastValuePushedToGa = lastValuePushedToGa;
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,8 @@ function navigateToUrl(url, optionalQuery = {}) {
|
||||||
externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]);
|
externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
externalUrl.searchParams.append("experiments", "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true");
|
||||||
|
|
||||||
window.location.assign(externalUrl);
|
window.location.assign(externalUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue