mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-28 02:43:32 +03:00
Preselect the date with a query parameter (#1376)
This commit is contained in:
parent
66dfd36d6d
commit
4d58075ef7
1 changed files with 13 additions and 3 deletions
|
@ -22,9 +22,9 @@ App.Http.Booking = (function () {
|
|||
const $availableHours = $('#available-hours');
|
||||
const $captchaHint = $('#captcha-hint');
|
||||
const $captchaTitle = $('.captcha-title');
|
||||
|
||||
|
||||
const moment = window.moment;
|
||||
|
||||
|
||||
let unavailableDatesBackup;
|
||||
let selectedDateStringBackup;
|
||||
let processingUnavailableDates = false;
|
||||
|
@ -283,7 +283,7 @@ App.Http.Booking = (function () {
|
|||
if (setDate && !vars('manage_mode')) {
|
||||
for (let i = 1; i <= numberOfDays; i++) {
|
||||
const currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
|
||||
|
||||
|
||||
if (unavailableDates.indexOf(moment(currentDate).format('YYYY-MM-DD')) === -1) {
|
||||
$('#select-date')[0]._flatpickr.setDate(currentDate);
|
||||
getAvailableHours(moment(currentDate).format('YYYY-MM-DD'));
|
||||
|
@ -300,6 +300,16 @@ App.Http.Booking = (function () {
|
|||
// Grey out unavailable dates.
|
||||
$('#select-date')[0]._flatpickr.set('disable', unavailableDates.map(unavailableDate => new Date(unavailableDate)));
|
||||
|
||||
const dateQueryParam = App.Utils.Url.queryParam('date');
|
||||
|
||||
if (dateQueryParam) {
|
||||
const dateQueryParamMoment = moment(dateQueryParam);
|
||||
|
||||
if (dateQueryParamMoment.isValid() && !unavailableDates.includes(dateQueryParam) && dateQueryParamMoment.format('YYYY-MM') === selectedDateMoment.format('YYYY-MM')) {
|
||||
$('#select-date')[0]._flatpickr.setDate(dateQueryParamMoment.toDate());
|
||||
}
|
||||
}
|
||||
|
||||
processingUnavailableDates = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue