From 927186151ebfcefc277dd5b28628d1ca621ec074 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 2 Jul 2021 08:29:15 +0200 Subject: [PATCH] Update checkbox defaults logic --- assets/js/sccp_manager.js | 20 +++++++++++++++----- views/formShowSysDefs.php | 3 +++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 6f41438..c8633b3 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -1060,6 +1060,11 @@ $(".sccp-restore").click(function() { //input is sent by data-for where for as an attribute var id = $(this).data("for"), input = $("#" + id); var edit_style = document.getElementById("edit_" + id).style; + if ($(this).data("type") === 'radio') { + input = document.getElementsByName(id); + console.log('have radio type'); + // Need to use getElementBy Name + } console.log(input); if (input.length === 0) { @@ -1068,6 +1073,12 @@ $(".sccp-restore").click(function() { if ($(this).is(":checked")) { console.log('restore/checked'); edit_style.display = 'block'; + if ($(this).data("type") === 'radio') { + // simulate read only for checkboxes + + $(':radio:not(:checked)').attr('disabled', true) + return; + } input.prop("readonly", true); } else { console.log('restore/unchecked'); @@ -1079,18 +1090,16 @@ $(".sccp-restore").click(function() { }); $(".sccp-edit").click(function() { + //input is sent by data-xxx where xxx is an attribute var id = $(this).data("for"), input = $("#" + id); var edit_style = document.getElementById("edit_" + id).style; - //input is sent by data-for where for is an attribute if ($(this).data("type") === 'radio') { - input = 'radio'; + input = document.getElementsByName(id); console.log('have radio type'); // $(':radio:not(:checked)').attr('disabled', true); to make readonly // Need to use getElementBy Name } - - console.log(input); if (input.length === 0) { return; @@ -1098,7 +1107,8 @@ $(".sccp-edit").click(function() { if ($(this).is(":checked")) { console.log('edit/checked'); edit_style.display = 'block'; - if (input == 'radio') { + if ($(this).data("type") === 'radio') { + $(':radio:not(:checked)').attr('disabled', false) return; } input.prop("readonly", false); diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index f913457..a22e7cd 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -500,6 +500,9 @@ foreach ($items as $child) { $res_v = (string)$fvalues[$res_n]['data']; } } + if (!$usingSysDefaults) { + $res_v = $sccp_defaults[$res_n]['systemdefault']; + } if (!empty($child->option_hide)) { $opt_hide = ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" '; }