WIP Partial fix for setting default radio buttons

This commit is contained in:
steve-lad 2021-07-01 10:11:02 +02:00
parent 02f0b401d0
commit dcd9c75886
3 changed files with 36 additions and 6 deletions

View file

@ -1057,7 +1057,7 @@ function sleep(milliseconds)
} }
$(".sccp-restore").click(function() { $(".sccp-restore").click(function() {
//input is sent by data-for where for is an attribute //input is sent by data-for where for as an attribute
var id = $(this).data("for"), input = $("#" + id); var id = $(this).data("for"), input = $("#" + id);
var edit_style = document.getElementById("edit_" + id).style; var edit_style = document.getElementById("edit_" + id).style;
@ -1066,9 +1066,11 @@ $(".sccp-restore").click(function() {
return; return;
} }
if ($(this).is(":checked")) { if ($(this).is(":checked")) {
console.log('restore/checked');
edit_style.display = 'block'; edit_style.display = 'block';
input.prop("readonly", true); input.prop("readonly", true);
} else { } else {
console.log('restore/unchecked');
edit_style.display = 'none'; edit_style.display = 'none';
input.data("custom", input.val()); input.data("custom", input.val());
input.prop("readonly", true); input.prop("readonly", true);
@ -1077,20 +1079,36 @@ $(".sccp-restore").click(function() {
}); });
$(".sccp-edit").click(function() { $(".sccp-edit").click(function() {
//input is sent by data-for where for is an attribute var id = $(this).data("for"), input = $("#" + id);
var id = $(this).data("for"), input = $("#" + id);
var edit_style = document.getElementById("edit_" + id).style; 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';
console.log('have radio type');
// $(':radio:not(:checked)').attr('disabled', true); to make readonly
// Need to use getElementBy Name
}
console.log(input); console.log(input);
if (input.length === 0) { if (input.length === 0) {
return; return;
} }
if ($(this).is(":checked")) { if ($(this).is(":checked")) {
console.log('edit/checked');
edit_style.display = 'block'; edit_style.display = 'block';
if (input == 'radio') {
return;
}
input.prop("readonly", false); input.prop("readonly", false);
input.focus(); input.focus();
} else { } else {
console.log('edit/unchecked');
edit_style.display = 'none'; edit_style.display = 'none';
if (input == 'radio') {
return;
}
input.data("custom", input.val()); input.data("custom", input.val());
input.prop("readonly", true); input.prop("readonly", true);
input.val(input.data("default")); input.val(input.data("default"));

View file

@ -403,6 +403,8 @@ foreach ($items as $child) {
$res_sec_class =''; $res_sec_class ='';
if (!empty($child ->class)) { if (!empty($child ->class)) {
$res_sec_class = (string)$child ->class; $res_sec_class = (string)$child ->class;
} else {
$res_sec_class = 'sccp-custom';
} }
echo '<!-- Begin '.$child->label.' -->'; echo '<!-- Begin '.$child->label.' -->';
@ -411,7 +413,7 @@ foreach ($items as $child) {
<div class="row"> <div class="row">
<div class="form-group <?php echo $res_sec_class;?>"> <div class="form-group <?php echo $res_sec_class;?>">
<div class="col-md-3 radioset"> <div class="col-md-3 radioset">
<label class="control-label" for="<?php echo $res_id ?>"><?php echo _($child->label)?></label> <label class="control-label" for="<?php echo $res_id; ?>"><?php echo _($child->label)?></label>
<i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i> <i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
@ -449,12 +451,14 @@ foreach ($items as $child) {
if ($usingSysDefaults) { if ($usingSysDefaults) {
// Setting a site specific value // Setting a site specific value
echo " data-for={$res_id}"; echo " data-for={$res_id}";
echo " data-type=radio";
echo " class=sccp-edit"; echo " class=sccp-edit";
echo " id=usedefault_{$res_id}"; echo " id=usedefault_{$res_id}";
echo " :checked"; echo " :checked";
} else { } else {
// reverting to chan-sccp default values // reverting to chan-sccp default values
echo " data-for={$res_id}"; echo " data-for={$res_id}";
echo " data-type=radio";
echo " class=sccp-restore"; echo " class=sccp-restore";
echo " id=usedefault_{$res_id}"; echo " id=usedefault_{$res_id}";
echo " "; echo " ";
@ -471,10 +475,11 @@ foreach ($items as $child) {
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="row" id="edit_<?php echo $res_id; ?>" style="display: none"> -->
<div class="row" id="edit_<?php echo $res_id; ?>" style="display: none"> <div class="row" id="edit_<?php echo $res_id; ?>" style="display: none">
<div class="form-group <?php echo $res_sec_class; ?>"> <div class="form-group <?php echo $res_id; ?>">
<div class="col-md-3"> <div class="col-md-3">
<i><?php echo "Enter new site value for {$shortId}"; ?></i> <i><?php echo "Enter new site value for {$res_n}"; ?></i>
</div> </div>
<div class="col-md-9 radioset " data-hide="on"> <div class="col-md-9 radioset " data-hide="on">

View file

@ -10,6 +10,13 @@
<form autocomplete="off" name="frm_device" id="frm_device" class="fpbx-submit" action="" method="post"> <form autocomplete="off" name="frm_device" id="frm_device" class="fpbx-submit" action="" method="post">
<input type="hidden" name="category" value="deviceform"> <input type="hidden" name="category" value="deviceform">
<input type="hidden" name="Submit" value="Submit"> <input type="hidden" name="Submit" value="Submit">
<div class="fpbx-container container-fluid">
<div class="row">
<div class="container">
<h2 style="border:2px solid Tomato;color:Tomato;" ><?php echo _("Warning : Any changes to the device configuration can cause all phones to restart"); ?></h2>
</div>
</div>
</div>
<?php <?php
$def_val_line = $this->getTableDefaults('sccpline'); $def_val_line = $this->getTableDefaults('sccpline');