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>
|
||||
<div
|
||||
:class="
|
||||
isOverflowScrollable
|
||||
? 'button-question button-question-overflow'
|
||||
: 'button-question'
|
||||
isOverflowScrollable ? 'button-question button-question-overflow' : 'button-question'
|
||||
">
|
||||
<div
|
||||
v-if="questionText && answers && answers.length > 0"
|
||||
class="question-text d-flex">
|
||||
<div v-if="questionText && answers && answers.length > 0" class="question-text d-flex">
|
||||
<span class="fw-bold w-100">{{ questionText }}</span>
|
||||
</div>
|
||||
|
||||
|
|
@ -51,8 +47,7 @@
|
|||
:textPosition="textPosition"
|
||||
:lastValuePushedToGa="lastValuePushedToGa"
|
||||
:setLastValuePushedToGa="setLastValuePushedToGa"
|
||||
v-model="selectedValues"
|
||||
/>
|
||||
v-model="selectedValues" />
|
||||
<!-- For nested questions -->
|
||||
<transition name="fade" mode="out-in">
|
||||
<div
|
||||
|
|
@ -68,9 +63,7 @@
|
|||
</fieldset>
|
||||
</div>
|
||||
<div class="row form-test-error mt-1">
|
||||
<error-message
|
||||
:name="formatString(groupName)"
|
||||
v-if="!suppressError"></error-message>
|
||||
<error-message :name="formatString(groupName)" v-if="!suppressError"></error-message>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -164,31 +157,19 @@ export default {
|
|||
|
||||
return classes;
|
||||
},
|
||||
getColLength() {
|
||||
if (this.isWide) {
|
||||
return "12";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
buttonsInfo() {
|
||||
return (Array.isArray(this.answers) ? this.answers : [])?.map(
|
||||
(answer) => ({
|
||||
buttonLabel: answer.buttonLabel ?? answer.Text ?? answer,
|
||||
altText:
|
||||
answer.altText ?? (answer.Name ? answer.Name : answer),
|
||||
buttonLabelSubCopy:
|
||||
answer.buttonLabelSubCopy ?? answer.SubText,
|
||||
buttonImage: answer.buttonImage ?? answer.AnswerImageUrl,
|
||||
buttonImageId: answer.buttonImageId ?? answer.ImageId,
|
||||
groupName: this.formatString(this.groupName),
|
||||
value:
|
||||
answer.value ??
|
||||
(this.useTextForValue
|
||||
? answer.Text
|
||||
: answer.Name ?? answer),
|
||||
})
|
||||
);
|
||||
return (Array.isArray(this.answers) ? this.answers : [])?.map((answer) => ({
|
||||
buttonLabel: answer.buttonLabel ?? answer.Text ?? answer,
|
||||
altText: answer.altText ?? (answer.Name ? answer.Name : answer),
|
||||
buttonLabelSubCopy: answer.buttonLabelSubCopy ?? answer.SubText,
|
||||
buttonImage: answer.buttonImage ?? answer.AnswerImageUrl,
|
||||
buttonImageId: answer.buttonImageId ?? answer.ImageId,
|
||||
groupName: this.formatString(this.groupName),
|
||||
value:
|
||||
answer.value ??
|
||||
(this.useTextForValue && answer.Text ? answer.Text : answer.Name) ??
|
||||
(typeof answer === "string" ? answer : null),
|
||||
}));
|
||||
},
|
||||
selectedValues: {
|
||||
get() {
|
||||
|
|
@ -196,30 +177,12 @@ export default {
|
|||
},
|
||||
set(selectedAnswers) {
|
||||
this.$emit("update:modelValue", selectedAnswers);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatString(str) {
|
||||
return str?.replace(" ", "-");
|
||||
},
|
||||
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());
|
||||
}
|
||||
return str?.replaceAll(" ", "-");
|
||||
},
|
||||
setLastValuePushedToGa(lastValuePushedToGa) {
|
||||
this.lastValuePushedToGa = lastValuePushedToGa;
|
||||
|
|
|
|||
|
|
@ -239,6 +239,8 @@ function navigateToUrl(url, optionalQuery = {}) {
|
|||
externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]);
|
||||
}
|
||||
|
||||
externalUrl.searchParams.append("experiments", "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true");
|
||||
|
||||
window.location.assign(externalUrl);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue