Make sure the right provider timezone information is displayed in the appointment and unavailability modals

This commit is contained in:
Alex Tselegidis 2022-05-24 10:47:56 +02:00
parent 46e6661bde
commit ae71c4c89d
3 changed files with 28 additions and 0 deletions

View file

@ -168,6 +168,8 @@ App.Components.AppointmentsModal = (function () {
$selectService.find('option:first').prop('selected', true).trigger('change');
}
$selectProvider.trigger('change');
const serviceId = $selectService.val();
const service = vars('available_services').find(

View file

@ -28,10 +28,34 @@ App.Components.UnavailabilitiesModal = (function () {
const $selectFilterItem = $('#select-filter-item');
const $reloadAppointments = $('#reload-appointments');
/**
* Update the displayed timezone.
*/
function updateTimezone() {
const providerId = $selectProvider.val();
const provider = vars('available_providers').find(
(availableProvider) => Number(availableProvider.id) === Number(providerId)
);
if (provider && provider.timezone) {
$unavailabilitiesModal.find('.provider-timezone').text(
vars('timezones')[provider.timezone]
);
}
}
/**
* Add the component event listeners.
*/
function addEventListeners() {
/**
* Event: Provider "Change"
*/
$selectProvider.on('change', () => {
updateTimezone();
});
/**
* Event: Manage Unavailability Dialog Save Button "Click"
*

View file

@ -1506,6 +1506,8 @@ App.Utils.CalendarDefaultView = (function () {
$('#unavailability-provider option:first').prop('selected', true);
}
$('#unavailability-provider').trigger('change');
$('#unavailability-start').datepicker('setDate', info.start);
$('#unavailability-end').datepicker('setDate', info.end);