mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-28 17:42:27 +03:00
Move the blocked period end date automatically on start date change (#1499)
This commit is contained in:
parent
dfeb213f5b
commit
01ddd00554
1 changed files with 24 additions and 0 deletions
|
@ -26,6 +26,7 @@ App.Pages.BlockedPeriods = (function () {
|
||||||
|
|
||||||
let filterResults = {};
|
let filterResults = {};
|
||||||
let filterLimit = 20;
|
let filterLimit = 20;
|
||||||
|
let backupStartDateTimeObject = undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the page event listeners.
|
* Add the page event listeners.
|
||||||
|
@ -159,6 +160,27 @@ App.Pages.BlockedPeriods = (function () {
|
||||||
select(id, true);
|
select(id, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$blockedPeriods.on('focus', '#start-date-time', () => {
|
||||||
|
backupStartDateTimeObject = App.Utils.UI.getDateTimePickerValue($startDateTime);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event: Start Date Time Input "Change"
|
||||||
|
*/
|
||||||
|
$blockedPeriods.on('change', '#start-date-time', (event) => {
|
||||||
|
const endDateTimeObject = App.Utils.UI.getDateTimePickerValue($endDateTime);
|
||||||
|
|
||||||
|
if (!backupStartDateTimeObject || !endDateTimeObject) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const endDateTimeMoment = moment(endDateTimeObject);
|
||||||
|
const backupStartDateTimeMoment = moment(backupStartDateTimeObject);
|
||||||
|
const diff = endDateTimeMoment.diff(backupStartDateTimeMoment);
|
||||||
|
const newEndDateTimeMoment = endDateTimeMoment.clone().add(diff, 'milliseconds');
|
||||||
|
App.Utils.UI.setDateTimePickerValue($endDateTime, newEndDateTimeMoment.toDate());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,6 +320,8 @@ App.Pages.BlockedPeriods = (function () {
|
||||||
|
|
||||||
$blockedPeriods.find('.record-details .is-invalid').removeClass('is-invalid');
|
$blockedPeriods.find('.record-details .is-invalid').removeClass('is-invalid');
|
||||||
$blockedPeriods.find('.record-details .form-message').hide();
|
$blockedPeriods.find('.record-details .form-message').hide();
|
||||||
|
|
||||||
|
backupStartDateTimeObject = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue