CASH-1790 updates for date-picker
This commit is contained in:
parent
ba2e138ac0
commit
7eed110bd2
1 changed files with 49 additions and 22 deletions
|
|
@ -1,17 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="date-picker text-center"
|
class="date-picker text-center"
|
||||||
:class="`${calendarViewDirection} calendar-2025 ${showPricingByDayClass}`">
|
:class="`${calendarViewDirection} calendar-2025 ${showPricingByDayClass} ${loadingStatus === 'reinitial' ? 'loading-reinitial' : ''}`">
|
||||||
<fieldset id="date-picker-fieldset" ref="datePickerFieldset">
|
<fieldset id="date-picker-fieldset" ref="datePickerFieldset">
|
||||||
<legend class="sr-only">Select a day and time</legend>
|
<legend class="sr-only">Select a day and time</legend>
|
||||||
<div
|
<div
|
||||||
v-for="month in months"
|
v-for="(month, i) in months"
|
||||||
:key="`${month.monthLabel}-${month.yearNum?.toString()}`"
|
:key="`${month.monthLabel}-${month.yearNum?.toString()}`"
|
||||||
:id="`${month.monthLabel}-${month.yearNum?.toString()}`"
|
:id="`${month.monthLabel}-${month.yearNum?.toString()}`"
|
||||||
class="calendar-grid-container"
|
class="calendar-grid-container month"
|
||||||
:class="[
|
:class="[
|
||||||
hideSomeDaysForInitialView ? 'partial-month-initial-view' : '',
|
hideSomeDaysForInitialView ? 'partial-month-initial-view' : '',
|
||||||
month.monthClass,
|
month.monthClass,
|
||||||
|
i === 0 ? 'first-month-shown' : '',
|
||||||
]">
|
]">
|
||||||
<div class="month-year body-small d-flex align-items-center">
|
<div class="month-year body-small d-flex align-items-center">
|
||||||
{{ month.monthLabel }} {{ month.yearNum?.toString() }}
|
{{ month.monthLabel }} {{ month.yearNum?.toString() }}
|
||||||
|
|
@ -114,7 +115,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<loader
|
<loader
|
||||||
:class="[!isLoading ? 'date-picker-hidden' : '']"
|
class="date-picker-loader"
|
||||||
|
:class="[loadingStatus !== 'none' ? 'show-loader' : '']"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="center" />
|
loaderPosition="center" />
|
||||||
<div class="row form-test-error" id="date-of-month-error">
|
<div class="row form-test-error" id="date-of-month-error">
|
||||||
|
|
@ -125,7 +127,7 @@
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-link view-more-dates"
|
class="btn btn-link view-more-dates"
|
||||||
id="viewMoreDates"
|
id="viewMoreDates"
|
||||||
:disabled="isLoading"
|
:disabled="loadingStatus !== 'none'"
|
||||||
@click="showAnotherMonth">
|
@click="showAnotherMonth">
|
||||||
View more dates
|
View more dates
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -200,6 +202,10 @@ export default {
|
||||||
pricingByDayUpcharge: Number,
|
pricingByDayUpcharge: Number,
|
||||||
isPricingByDayExperiment: Boolean,
|
isPricingByDayExperiment: Boolean,
|
||||||
isMobileSelected: Boolean,
|
isMobileSelected: Boolean,
|
||||||
|
loadingStatus: {
|
||||||
|
type: String,
|
||||||
|
default: "none",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const uuid = uuidv4();
|
const uuid = uuidv4();
|
||||||
|
|
@ -489,7 +495,6 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async setCalendarData(config = {}) {
|
async setCalendarData(config = {}) {
|
||||||
this.isLoading = true;
|
|
||||||
this.selectableDatesInshop = [];
|
this.selectableDatesInshop = [];
|
||||||
this.selectableDatesMobile = [];
|
this.selectableDatesMobile = [];
|
||||||
this.months = [];
|
this.months = [];
|
||||||
|
|
@ -541,7 +546,6 @@ export default {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
this.months = months;
|
this.months = months;
|
||||||
this.isLoading = false;
|
|
||||||
|
|
||||||
if (config.preSelectedDate) {
|
if (config.preSelectedDate) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
@ -729,7 +733,6 @@ export default {
|
||||||
},
|
},
|
||||||
async showAnotherMonth() {
|
async showAnotherMonth() {
|
||||||
if (!this.months) return;
|
if (!this.months) return;
|
||||||
this.isLoading = true;
|
|
||||||
let monthToShow;
|
let monthToShow;
|
||||||
let monthStartDate;
|
let monthStartDate;
|
||||||
|
|
||||||
|
|
@ -774,7 +777,6 @@ export default {
|
||||||
monthToShowDates[monthToShowDates.length - 1].inputValue
|
monthToShowDates[monthToShowDates.length - 1].inputValue
|
||||||
);
|
);
|
||||||
|
|
||||||
this.isLoading = false;
|
|
||||||
this.hideSomeDaysForInitialView = false; // if hid days on initial partial view, this will reveal those days
|
this.hideSomeDaysForInitialView = false; // if hid days on initial partial view, this will reveal those days
|
||||||
monthToShow.monthClass = monthToShow.monthClass.replace(" month-hidden", "");
|
monthToShow.monthClass = monthToShow.monthClass.replace(" month-hidden", "");
|
||||||
this.scrollToElement(monthToShow.monthString);
|
this.scrollToElement(monthToShow.monthString);
|
||||||
|
|
@ -787,7 +789,6 @@ export default {
|
||||||
},
|
},
|
||||||
async updateSelectableDates(monthStart, monthEnd) {
|
async updateSelectableDates(monthStart, monthEnd) {
|
||||||
const moreSelectableDates = await this.getMoreDatesCallback(monthStart, monthEnd);
|
const moreSelectableDates = await this.getMoreDatesCallback(monthStart, monthEnd);
|
||||||
|
|
||||||
moreSelectableDates.inshopTimeSlotsData.days.forEach((selectableDate) => {
|
moreSelectableDates.inshopTimeSlotsData.days.forEach((selectableDate) => {
|
||||||
const index = this.selectableDatesInshop.findIndex(
|
const index = this.selectableDatesInshop.findIndex(
|
||||||
(dateObj) => dateObj.date === selectableDate.date
|
(dateObj) => dateObj.date === selectableDate.date
|
||||||
|
|
@ -846,12 +847,6 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
isLoading(newValue) {
|
|
||||||
// if done loading dates, then set to first available date
|
|
||||||
if (newValue === false && this.firstAvailableSelectableDate) {
|
|
||||||
this.selectedDate = this.firstAvailableSelectableDate;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modelValue(newValue) {
|
modelValue(newValue) {
|
||||||
this.resetField({
|
this.resetField({
|
||||||
value: newValue,
|
value: newValue,
|
||||||
|
|
@ -872,9 +867,14 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.date-picker-hidden {
|
.date-picker-loader {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
max-height: 0;
|
max-height: 0;
|
||||||
|
|
||||||
|
&.show-loader {
|
||||||
|
opacity: 1;
|
||||||
|
max-height: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.date-picker {
|
.date-picker {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
@ -903,12 +903,12 @@ export default {
|
||||||
height: 1.5rem;
|
height: 1.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.calendar-grid-container {
|
.month {
|
||||||
margin: 0 auto 1rem auto;
|
margin: 0 auto 1rem auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
transition:
|
transition:
|
||||||
height ease 2s,
|
height ease 1s,
|
||||||
opacity ease 2s;
|
max-height ease 1s;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 1fr);
|
grid-template-columns: repeat(7, 1fr);
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
@ -1157,7 +1157,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
.past {
|
.past {
|
||||||
.calendar-grid-container {
|
.month {
|
||||||
.month-year {
|
.month-year {
|
||||||
grid-area: 1 / 1 / 2 / 6;
|
grid-area: 1 / 1 / 2 / 6;
|
||||||
}
|
}
|
||||||
|
|
@ -1214,7 +1214,7 @@ export default {
|
||||||
}
|
}
|
||||||
// new calendar styling overrides
|
// new calendar styling overrides
|
||||||
&.calendar-2025 {
|
&.calendar-2025 {
|
||||||
.calendar-grid-container .grid-item {
|
.month .grid-item {
|
||||||
margin: 0 0 0.15rem 0;
|
margin: 0 0 0.15rem 0;
|
||||||
}
|
}
|
||||||
.month-year {
|
.month-year {
|
||||||
|
|
@ -1316,6 +1316,33 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.loading-reinitial {
|
||||||
|
.month {
|
||||||
|
opacity: 0;
|
||||||
|
max-height: 0;
|
||||||
|
}
|
||||||
|
.month.first-month-shown {
|
||||||
|
opacity: 1;
|
||||||
|
max-height: none;
|
||||||
|
|
||||||
|
.grid-item.radio-wrapper.selectable-day {
|
||||||
|
input[type="radio"]:checked + label,
|
||||||
|
label {
|
||||||
|
background-color: $white;
|
||||||
|
border: none;
|
||||||
|
color: initial;
|
||||||
|
cursor: none;
|
||||||
|
&:hover {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
font-family: UrbanistRegular;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
:deep(.timeslots .button-inner-wrapper) {
|
:deep(.timeslots .button-inner-wrapper) {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue