Add site defaults buttons to IS
This commit is contained in:
parent
b927523071
commit
8e6d7b7e14
|
@ -160,7 +160,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
* Generate Input elements in Html Code from sccpgeneral.xml
|
* Generate Input elements in Html Code from sccpgeneral.xml
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = array()) {
|
public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = array(), $defButton = '') {
|
||||||
|
|
||||||
// load xml data - moved from Construct to simplify Construct.
|
// load xml data - moved from Construct to simplify Construct.
|
||||||
// TODO: This is static data so only load first time. Left as is for dbug.
|
// TODO: This is static data so only load first time. Left as is for dbug.
|
||||||
|
@ -186,7 +186,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
'fvalues' => $form_values,
|
'fvalues' => $form_values,
|
||||||
'installedLangs' => $this->findInstLangs(),
|
'installedLangs' => $this->findInstLangs(),
|
||||||
'chanSccpHelp' => $this->sccpHelpInfo,
|
'chanSccpHelp' => $this->sccpHelpInfo,
|
||||||
'sccp_defaults' => $this->sccpvalues
|
'sccp_defaults' => $this->sccpvalues,
|
||||||
|
'defButton' => $defButton
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1222,9 +1222,18 @@ function sleep(milliseconds)
|
||||||
// custom values. Clicking on these buttons is handled by the 2 functions below.
|
// custom values. Clicking on these buttons is handled by the 2 functions below.
|
||||||
$(".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 is an attribute
|
||||||
|
console.log('have click');
|
||||||
var id = $(this).data("for"), input = $("#" + id);
|
var id = $(this).data("for"), input = $("#" + id);
|
||||||
|
console.log('id ' + id);
|
||||||
|
console.log('input ' + input);
|
||||||
var edit_style = document.getElementById("edit_" + id).style;
|
var edit_style = document.getElementById("edit_" + id).style;
|
||||||
|
console.log('edit style ' + edit_style);
|
||||||
input = document.getElementsByName(id);
|
input = document.getElementsByName(id);
|
||||||
|
console.log(input);
|
||||||
|
input = $("input[id^=" + id);
|
||||||
|
console.log(input);
|
||||||
|
//input = document.querySelectorAll("[id^=" + id]));
|
||||||
|
//console.log(input);
|
||||||
if (input.length === 0) {
|
if (input.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1236,7 +1245,7 @@ $(".sccp-restore").click(function() {
|
||||||
var defaultVal = $(this).data("default");
|
var defaultVal = $(this).data("default");
|
||||||
if ($(this).data("type") === 'radio') {
|
if ($(this).data("type") === 'radio') {
|
||||||
// simulate read only for checkboxes except default
|
// simulate read only for checkboxes except default
|
||||||
input.forEach(
|
input.each(
|
||||||
function(radioElement) {
|
function(radioElement) {
|
||||||
radioElement.setAttribute('disabled', true);
|
radioElement.setAttribute('disabled', true);
|
||||||
if (radioElement.value === defaultVal){
|
if (radioElement.value === defaultVal){
|
||||||
|
|
|
@ -337,11 +337,14 @@ class formcreate
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons) {
|
function addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons, $defButton = '') {
|
||||||
if ($npref == 'sccp_hw_') {
|
if ($npref == 'sccp_hw_') {
|
||||||
$this->buttonDefLabel = 'site';
|
$this->buttonDefLabel = 'site';
|
||||||
$this->buttonHelpLabel = 'device';
|
$this->buttonHelpLabel = 'device';
|
||||||
}
|
}
|
||||||
|
if ($defButton == 'site'){
|
||||||
|
$this->buttonDefLabel = 'site';
|
||||||
|
}
|
||||||
$res_n = (string)$child->name;
|
$res_n = (string)$child->name;
|
||||||
$res_id = $npref.$res_n;
|
$res_id = $npref.$res_n;
|
||||||
$res_ext = str_replace($npref,'',$res_n);
|
$res_ext = str_replace($npref,'',$res_n);
|
||||||
|
@ -384,8 +387,12 @@ class formcreate
|
||||||
if ($sccp_defaults[$res_n]['systemdefault'] != $res_v) {
|
if ($sccp_defaults[$res_n]['systemdefault'] != $res_v) {
|
||||||
$usingSysDefaults = false;
|
$usingSysDefaults = false;
|
||||||
}
|
}
|
||||||
if (!empty($sccp_defaults[$res_n]['systemdefault'])) {
|
if ($sccp_defaults[$res_n]['data'] != $res_v) {
|
||||||
// There is a system default, so add button to customise or reset
|
$usingSiteDefaults = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!empty($sccp_defaults[$res_n]['systemdefault'])) || ($defButton == 'site')) {
|
||||||
|
// There is a system default, or we are referencing site defaults, so add button to customise or reset
|
||||||
// the closing } is after the code to include the button at line ~427
|
// the closing } is after the code to include the button at line ~427
|
||||||
|
|
||||||
//-- Start include of defaults button --
|
//-- Start include of defaults button --
|
||||||
|
@ -403,16 +410,24 @@ class formcreate
|
||||||
$res_v = $sccp_defaults[$res_n]['systemdefault'];
|
$res_v = $sccp_defaults[$res_n]['systemdefault'];
|
||||||
// Setting a site specific value
|
// Setting a site specific value
|
||||||
echo " class=sccp-edit :checked ";
|
echo " class=sccp-edit :checked ";
|
||||||
|
} else if ($usingSiteDefaults) {
|
||||||
|
$res_v = $sccp_defaults[$res_n]['data'];
|
||||||
|
// Setting a site specific value
|
||||||
|
echo " class=sccp-edit :checked ";
|
||||||
} else {
|
} else {
|
||||||
// reverting to chan-sccp default values
|
// reverting to chan-sccp or site default values
|
||||||
echo " data-default={$sccp_defaults[$res_n]['systemdefault']} class=sccp-restore ";
|
if ($defButton == 'site') {
|
||||||
|
echo " data-default={$sccp_defaults[$res_n]['data']} class=sccp-restore ";
|
||||||
|
} else {
|
||||||
|
echo " data-default={$sccp_defaults[$res_n]['systemdefault']} class=sccp-restore ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
<?php
|
<?php
|
||||||
echo "for=usedefault_{$res_id} >";
|
echo "for=usedefault_{$res_id} >";
|
||||||
echo ($usingSysDefaults) ? "Customise" : "Use {$this->buttonDefLabel} defaults";
|
echo ($usingSysDefaults || $usingSiteDefaults) ? "Customise" : "Use {$this->buttonDefLabel} defaults";
|
||||||
?>
|
?>
|
||||||
</label>
|
</label>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -538,7 +538,7 @@ trait ajaxHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($db_field as $key) {
|
foreach ($db_field as $key) {
|
||||||
$value = "";
|
$value = '';
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
if (!empty($get_settings[$hdr_prefix . 'mac'])) {
|
if (!empty($get_settings[$hdr_prefix . 'mac'])) {
|
||||||
|
@ -553,10 +553,8 @@ trait ajaxHelper {
|
||||||
$name_dev = $value;
|
$name_dev = $value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'daysdisplaynotactive' :
|
case 'daysdisplaynotactive' :
|
||||||
$searchArr = ['daysdisplaynotactive_0', 'daysdisplaynotactive_1', 'daysdisplaynotactive_2', 'daysdisplaynotactive_3', 'daysdisplaynotactive_4', 'daysdisplaynotactive_5', 'daysdisplaynotactive_6'];
|
$searchArr = ['daysdisplaynotactive_0', 'daysdisplaynotactive_1', 'daysdisplaynotactive_2', 'daysdisplaynotactive_3', 'daysdisplaynotactive_4', 'daysdisplaynotactive_5', 'daysdisplaynotactive_6'];
|
||||||
$value = '';
|
|
||||||
foreach ($searchArr as $settingsVal) {
|
foreach ($searchArr as $settingsVal) {
|
||||||
$value .= (isset($get_settings["sccpdevice_${settingsVal}"])) ? $get_settings["sccpdevice_${settingsVal}"] . ',' : '';
|
$value .= (isset($get_settings["sccpdevice_${settingsVal}"])) ? $get_settings["sccpdevice_${settingsVal}"] . ',' : '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ if (!empty($def_val['type']['data'])) {
|
||||||
}
|
}
|
||||||
echo $this->showGroup('sccp_hw_dev2', 1, 'sccp_hw', $def_val);
|
echo $this->showGroup('sccp_hw_dev2', 1, 'sccp_hw', $def_val);
|
||||||
echo $this->showGroup('sccp_hw_dev_advance', 1, 'sccp_hw', $def_val);
|
echo $this->showGroup('sccp_hw_dev_advance', 1, 'sccp_hw', $def_val);
|
||||||
echo $this->showGroup('sccp_dev_vendor_display_conf', 1, 'sccpdevice', $def_val);
|
echo $this->showGroup('sccp_dev_vendor_display_conf', 1, 'sccpdevice', $def_val, 'site');
|
||||||
echo $this->showGroup('sccp_hw_dev_softkey', 1, 'sccp_hw', $def_val);
|
echo $this->showGroup('sccp_hw_dev_softkey', 1, 'sccp_hw', $def_val);
|
||||||
echo $this->showGroup('sccp_hw_dev_conference', 1, 'sccp_hw', $def_val);
|
echo $this->showGroup('sccp_hw_dev_conference', 1, 'sccp_hw', $def_val);
|
||||||
echo $this->showGroup('sccp_dev_vendor_conf', 1, 'vendorconfig', $def_val);
|
echo $this->showGroup('sccp_dev_vendor_conf', 1, 'vendorconfig', $def_val);
|
||||||
|
|
|
@ -28,7 +28,6 @@ if (empty($form_prefix)) {
|
||||||
// $npref = 'vendorconfig';
|
// $npref = 'vendorconfig';
|
||||||
// $napref = 'vendorconfig-ar';
|
// $napref = 'vendorconfig-ar';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($fvalues)) {
|
if (empty($fvalues)) {
|
||||||
$fvalues = $sccp_defaults;
|
$fvalues = $sccp_defaults;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +70,7 @@ foreach ($items as $child) {
|
||||||
$disabledButtons = array('off' => 'Off');
|
$disabledButtons = array('off' => 'Off');
|
||||||
}
|
}
|
||||||
case 'IS':
|
case 'IS':
|
||||||
$sccpManager->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons);
|
$sccpManager->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons, $defButton);
|
||||||
break;
|
break;
|
||||||
case 'SLD':
|
case 'SLD':
|
||||||
case 'SLM':
|
case 'SLM':
|
||||||
|
|
Loading…
Reference in a new issue