diff --git a/assets/js/pages/api_settings.js b/assets/js/pages/api_settings.js index 7c7e1baa..4dc5a725 100644 --- a/assets/js/pages/api_settings.js +++ b/assets/js/pages/api_settings.js @@ -52,7 +52,11 @@ App.Pages.ApiSettings = (function () { function deserialize(apiSettings) { apiSettings.forEach((apiSetting) => { - $('[data-field="' + apiSetting.name + '"]').val(apiSetting.value); + const $field = $('[data-field="' + apiSetting.name + '"]'); + + $field.is(':checkbox') + ? $field.prop('checked', Boolean(Number(apiSetting.value))) + : $field.val(apiSetting.value); }); } @@ -64,7 +68,7 @@ App.Pages.ApiSettings = (function () { apiSettings.push({ name: $field.data('field'), - value: $field.val() + value: $field.is(':checkbox') ? Number($field.prop('checked')) : $field.val() }); }); diff --git a/assets/js/pages/business_settings.js b/assets/js/pages/business_settings.js index 4658b3ba..1c5fdb15 100644 --- a/assets/js/pages/business_settings.js +++ b/assets/js/pages/business_settings.js @@ -17,7 +17,7 @@ App.Pages.BusinessSettings = (function () { const $saveSettings = $('#save-settings'); const $applyGlobalWorkingPlan = $('#apply-global-working-plan'); - const $appointmentStatusOptions = $('#appointment-status-options') + const $appointmentStatusOptions = $('#appointment-status-options'); let workingPlanManager = null; /** @@ -55,7 +55,11 @@ App.Pages.BusinessSettings = (function () { function deserialize(businessSettings) { businessSettings.forEach((businessSetting) => { - $('[data-field="' + businessSetting.name + '"]').val(businessSetting.value); + const $field = $('[data-field="' + businessSetting.name + '"]'); + + $field.is(':checkbox') + ? $field.prop('checked', Boolean(Number(businessSetting.value))) + : $field.val(businessSetting.value); }); } @@ -67,7 +71,7 @@ App.Pages.BusinessSettings = (function () { businessSettings.push({ name: $field.data('field'), - value: $field.val() + value: $field.is(':checkbox') ? Number($field.prop('checked')) : $field.val() }); }); @@ -160,7 +164,7 @@ App.Pages.BusinessSettings = (function () { workingPlanManager.setup(companyWorkingPlan); workingPlanManager.timepickers(false); workingPlanManager.addEventListeners(); - + App.Components.AppointmentStatusOptions.setOptions($appointmentStatusOptions, appointmentStatusOptions); $saveSettings.on('click', onSaveSettingsClick); diff --git a/assets/js/pages/general_settings.js b/assets/js/pages/general_settings.js index 06d415b5..209656f2 100644 --- a/assets/js/pages/general_settings.js +++ b/assets/js/pages/general_settings.js @@ -70,7 +70,11 @@ App.Pages.GeneralSettings = (function () { $resetCompanyColor.prop('hidden', false); } - $('[data-field="' + generalSetting.name + '"]').val(generalSetting.value); + const $field = $('[data-field="' + generalSetting.name + '"]'); + + $field.is(':checkbox') + ? $field.prop('checked', Boolean(Number(generalSetting.value))) + : $field.val(generalSetting.value); }); } @@ -82,7 +86,7 @@ App.Pages.GeneralSettings = (function () { generalSettings.push({ name: $field.data('field'), - value: $field.val() + value: $field.is(':checkbox') ? Number($field.prop('checked')) : $field.val() }); }); diff --git a/assets/js/pages/google_analytics_settings.js b/assets/js/pages/google_analytics_settings.js index 009dcbeb..dcc6a393 100644 --- a/assets/js/pages/google_analytics_settings.js +++ b/assets/js/pages/google_analytics_settings.js @@ -52,7 +52,11 @@ App.Pages.GoogleAnalyticsSettings = (function () { function deserialize(googleAnalyticsSettings) { googleAnalyticsSettings.forEach((googleAnalyticsSetting) => { - $('[data-field="' + googleAnalyticsSetting.name + '"]').val(googleAnalyticsSetting.value); + const $field = $('[data-field="' + googleAnalyticsSetting.name + '"]'); + + $field.is(':checkbox') + ? $field.prop('checked', Boolean(Number(googleAnalyticsSetting.value))) + : $field.val(googleAnalyticsSetting.value); }); } @@ -64,7 +68,7 @@ App.Pages.GoogleAnalyticsSettings = (function () { googleAnalyticsSettings.push({ name: $field.data('field'), - value: $field.val() + value: $field.is(':checkbox') ? Number($field.prop('checked')) : $field.val() }); }); diff --git a/assets/js/pages/matomo_analytics_settings.js b/assets/js/pages/matomo_analytics_settings.js index ee7bff75..50211516 100644 --- a/assets/js/pages/matomo_analytics_settings.js +++ b/assets/js/pages/matomo_analytics_settings.js @@ -52,7 +52,11 @@ App.Pages.MatomoAnalyticsSettings = (function () { function deserialize(matomoAnalyticsSettings) { matomoAnalyticsSettings.forEach((matomoAnalyticsSetting) => { - $('[data-field="' + matomoAnalyticsSetting.name + '"]').val(matomoAnalyticsSetting.value); + const $field = $('[data-field="' + matomoAnalyticsSetting.name + '"]'); + + $field.is(':checkbox') + ? $field.prop('checked', Boolean(Number(matomoAnalyticsSetting.value))) + : $field.val(matomoAnalyticsSetting.value); }); } @@ -64,7 +68,7 @@ App.Pages.MatomoAnalyticsSettings = (function () { matomoAnalyticsSettings.push({ name: $field.data('field'), - value: $field.val() + value: $field.is(':checkbox') ? Number($field.prop('checked')) : $field.val() }); });