From b291a2bb2403253730b961f33ad383e4267ed559 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 8 Dec 2020 14:16:58 +0200 Subject: [PATCH] Improved event selection for both default and table calendar views --- assets/js/backend_calendar_default_view.js | 21 ++++++++++++++-- assets/js/backend_calendar_table_view.js | 28 ++++++++++++++++++---- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/assets/js/backend_calendar_default_view.js b/assets/js/backend_calendar_default_view.js index 3929bbad..bfa68c57 100755 --- a/assets/js/backend_calendar_default_view.js +++ b/assets/js/backend_calendar_default_view.js @@ -1456,8 +1456,25 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; return provider.services.indexOf(service.id) !== -1 }); - $('#select-service').val(service.id).trigger('change'); - $('#select-provider').val(provider.id).trigger('change'); + if (service) { + $('#select-service').val(service.id); + } + + if (!$('#select-service').val()) { + $('#select-service option:first').prop('selected', true); + } + + $('#select-service').trigger('change'); + + if (provider) { + $('#select-provider').val(provider.id); + } + + if (!$('#select-provider').val()) { + $('#select-provider option:first').prop('selected', true); + } + + $('#select-provider').trigger('change'); } // Preselect time diff --git a/assets/js/backend_calendar_table_view.js b/assets/js/backend_calendar_table_view.js index 931cec5d..4402e505 100755 --- a/assets/js/backend_calendar_table_view.js +++ b/assets/js/backend_calendar_table_view.js @@ -206,6 +206,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; $dialog.find('#appointment-location').val(appointment.location); $dialog.find('#appointment-notes').val(appointment.notes); $dialog.find('#customer-notes').val(customer.notes); + + $dialog.modal('show'); } else { var unavailable = lastFocusedEventData.data; @@ -225,10 +227,9 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; $dialog.find('#unavailable-provider').val(unavailable.id_users_provider); $dialog.find('#unavailable-end').datetimepicker('setDate', endDatetime); $dialog.find('#unavailable-notes').val(unavailable.notes); - } - // :: DISPLAY EDIT DIALOG - $dialog.modal('show'); + $dialog.modal('show'); + } }); /** @@ -730,8 +731,25 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; return provider.services.indexOf(service.id) !== -1 }); - $('#select-service').val(service.id).trigger('change'); - $('#select-provider').val(provider.id).trigger('change'); + if (service) { + $('#select-service').val(service.id); + } + + if (!$('#select-service').val()) { + $('#select-service option:first').prop('selected', true); + } + + $('#select-service').trigger('change'); + + if (provider) { + $('#select-provider').val(provider.id); + } + + if (!$('#select-provider').val()) { + $('#select-provider option:first').prop('selected', true); + } + + $('#select-provider').trigger('change'); // Preselect time $('#start-datetime').datepicker('setDate', new Date(start.format('YYY/MM/DD HH:mm:ss')));