Fix reset of defaults for text fields

Still need to address bindaddress:port and externalIP: Name
This commit is contained in:
stevenA 2021-12-31 15:01:02 +01:00
parent 8268bbf81a
commit 8953484e1f
2 changed files with 46 additions and 43 deletions

View file

@ -1192,16 +1192,18 @@ $(".sccp-restore").click(function() {
var edit_style = document.getElementById("edit_" + id).style;
if ($(this).data("type") === 'radio') {
input = document.getElementsByName(id);
} else if ($(this).data("type") === 'text') {
input = document.getElementsByName(id);
}
if (input.length === 0) {
return;
}
if ($(this).is(":checked")) {
console.log("Restore checked");
edit_style.display = 'block';
var defaultVal = $(this).data("default");
if ($(this).data("type") === 'radio') {
// simulate read only for checkboxes
console.log(input);
// simulate read only for checkboxes except default
input.forEach(
function(radioElement) {
radioElement.setAttribute('disabled', true);
@ -1209,19 +1211,18 @@ $(".sccp-restore").click(function() {
radioElement.removeAttribute('disabled');
radioElement.setAttribute('checked', true);
} else {
radioElement.setAttribute('disabled', true);
radioElement.removeAttribute('checked');
}
}
);
return;
} else if ($(this).data("type") === 'text') {
input[0].value = defaultVal;
input[0].readOnly = true;
}
input.prop("readonly", true);
} else {
console.log('restore/unchecked');
edit_style.display = 'none';
if ($(this).data("type") === 'radio') {
// simulate read only for checkboxes
input.forEach(
function(radioElement) {
radioElement.removeAttribute('disabled');

View file

@ -94,8 +94,10 @@ class formcreate
} else {
// reverting to chan-sccp default values
echo " data-for={$res_id}";
echo " data-type=text";
echo " class=sccp-restore";
echo " id=usedefault_{$res_id}";
echo " data-default={$sccp_defaults[$res_n]['systemdefault']}";
echo " ";
}
?>