diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ca7fec1..a01f950f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - #480: Make the app GDPR - new EU privacy regulations compliant. - #489: REST API response headers must use the Content-Type application/json value. - +- #500: Performance optimization in backend calendar page, after the user clicks the insert appointment button. + ## [1.3.1] ### Added diff --git a/src/assets/js/backend_calendar_appointments_modal.js b/src/assets/js/backend_calendar_appointments_modal.js index bdd506e0..d3021b7c 100755 --- a/src/assets/js/backend_calendar_appointments_modal.js +++ b/src/assets/js/backend_calendar_appointments_modal.js @@ -127,16 +127,16 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa // Set the selected filter item and find the next appointment time as the default modal values. if ($('#select-filter-item option:selected').attr('type') == 'provider') { - var $providerOption = $dialog.find('#select-provider option[value="' - + $('#select-filter-item').val() + '"]'); - if ($providerOption.length === 0) { // Change the services until you find the correct. - $.each($dialog.find('#select-service option'), function () { - $(this).prop('selected', true).parent().change(); - if ($providerOption.length > 0) - return false; - }); + var providerId = $('#select-filter-item').val(); + + var providers = GlobalVariables.availableProviders.filter(function (provider) { + return provider.id == providerId; + }); + + if (providers.length) { + $dialog.find('#select-service').val(providers[0].services[0]).trigger('change'); + $dialog.find('#select-provider').val(providerId); } - $providerOption.prop('selected', true); } else { $dialog.find('#select-service option[value="' + $('#select-filter-item').val() + '"]').prop('selected', true);