CASH-1183: Load more timeslots

This commit is contained in:
Chris Redelinghuys 2025-08-05 12:51:53 -04:00
parent ad20eb7b08
commit 8a49b56f21
3 changed files with 50 additions and 0 deletions

View file

@ -64,6 +64,7 @@ https://safelite.atlassian.net/wiki/spaces/DC/pages/76644418/Button+Question+Com
:isInsuranceSelected="isInsuranceSelected" :isInsuranceSelected="isInsuranceSelected"
:suppressError="suppressError" :suppressError="suppressError"
:labelBold="labelBold" :labelBold="labelBold"
:isHidden="setIsHidden(index)"
@buttonEvent="handleButtonEvent" @buttonEvent="handleButtonEvent"
v-model="selectedValues" /> v-model="selectedValues" />
<!-- For nested questions --> <!-- For nested questions -->
@ -96,6 +97,11 @@ https://safelite.atlassian.net/wiki/spaces/DC/pages/76644418/Button+Question+Com
:name="formatString(groupName)" :name="formatString(groupName)"
v-if="!suppressError"></error-message> v-if="!suppressError"></error-message>
</div> </div>
<div v-if="lazyLoad.isLazyLoad && !showAllButtons" id="show-more-button">
<button class="btn btn-link" type="button" @click="toggleShowAllButtons">
View more times
</button>
</div>
</div> </div>
</template> </template>
@ -163,6 +169,13 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
lazyLoad: {
type: Object,
default: () => ({
isLazyLoad: false,
amountToLoad: null,
}),
},
}, },
setup(props) { setup(props) {
const propsClone = Object.assign({}, props); const propsClone = Object.assign({}, props);
@ -194,6 +207,7 @@ export default {
data() { data() {
return { return {
lastValuePushedToGa: null, lastValuePushedToGa: null,
showAllButtons: false,
}; };
}, },
computed: { computed: {
@ -289,6 +303,15 @@ export default {
this.$emit("update:modelValue", selectedAnswers); this.$emit("update:modelValue", selectedAnswers);
}, },
}, },
setIsHidden() {
return (index) => {
return (
this.lazyLoad.isLazyLoad &&
index >= this.lazyLoad.amountToLoad &&
!this.showAllButtons
);
};
},
}, },
methods: { methods: {
formatString(str) { formatString(str) {
@ -301,6 +324,9 @@ export default {
const eventName = event.eventName; const eventName = event.eventName;
this.$emit(`buttonEvent.${eventName}`, event.args); this.$emit(`buttonEvent.${eventName}`, event.args);
}, },
toggleShowAllButtons() {
this.showAllButtons = true;
},
}, },
watch: { watch: {
modelValue(newValue, oldValue) { modelValue(newValue, oldValue) {
@ -362,6 +388,28 @@ export default {
font-family: UrbanistSemibold; font-family: UrbanistSemibold;
color: $black; color: $black;
&.timeslots {
.col {
& > label[isHidden="true"] {
display: none;
}
}
#show-more-button {
width: 100%;
text-align: center;
margin-top: 0.5rem;
button {
color: $blue;
text-underline-offset: 4px;
&:active {
background: unset;
}
}
}
}
.radio-button-container { .radio-button-container {
&:not(:last-child) { &:not(:last-child) {
padding-bottom: map-get($spacers, 2); padding-bottom: map-get($spacers, 2);

View file

@ -1042,6 +1042,7 @@ export default {
.view-more-dates { .view-more-dates {
color: $blue; color: $blue;
font-family: UrbanistSemiBold;
} }
} }
.loader { .loader {

View file

@ -31,6 +31,7 @@
isInshopOrDropOffAppointment ? 'is-inshop-or-drop-off-appointment' : '', isInshopOrDropOffAppointment ? 'is-inshop-or-drop-off-appointment' : '',
]" ]"
:answers="availableTimeSlots" :answers="availableTimeSlots"
:lazyLoad="{ isLazyLoad: true, amountToLoad: 10 }"
groupName="chooseTimeSlot" groupName="chooseTimeSlot"
textPosition="text-center" textPosition="text-center"
v-model="selectedAnswerForTimeSlots" v-model="selectedAnswerForTimeSlots"