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
|
||||
*/
|
||||
|
||||
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.
|
||||
// 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,
|
||||
'installedLangs' => $this->findInstLangs(),
|
||||
'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.
|
||||
$(".sccp-restore").click(function() {
|
||||
//input is sent by data-for where for is an attribute
|
||||
console.log('have click');
|
||||
var id = $(this).data("for"), input = $("#" + id);
|
||||
console.log('id ' + id);
|
||||
console.log('input ' + input);
|
||||
var edit_style = document.getElementById("edit_" + id).style;
|
||||
console.log('edit style ' + edit_style);
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
@ -1236,7 +1245,7 @@ $(".sccp-restore").click(function() {
|
|||
var defaultVal = $(this).data("default");
|
||||
if ($(this).data("type") === 'radio') {
|
||||
// simulate read only for checkboxes except default
|
||||
input.forEach(
|
||||
input.each(
|
||||
function(radioElement) {
|
||||
radioElement.setAttribute('disabled', true);
|
||||
if (radioElement.value === defaultVal){
|
||||
|
|
|
@ -337,11 +337,14 @@ class formcreate
|
|||
<?php
|
||||
}
|
||||
|
||||
function addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons) {
|
||||
function addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons, $defButton = '') {
|
||||
if ($npref == 'sccp_hw_') {
|
||||
$this->buttonDefLabel = 'site';
|
||||
$this->buttonHelpLabel = 'device';
|
||||
}
|
||||
if ($defButton == 'site'){
|
||||
$this->buttonDefLabel = 'site';
|
||||
}
|
||||
$res_n = (string)$child->name;
|
||||
$res_id = $npref.$res_n;
|
||||
$res_ext = str_replace($npref,'',$res_n);
|
||||
|
@ -384,8 +387,12 @@ class formcreate
|
|||
if ($sccp_defaults[$res_n]['systemdefault'] != $res_v) {
|
||||
$usingSysDefaults = false;
|
||||
}
|
||||
if (!empty($sccp_defaults[$res_n]['systemdefault'])) {
|
||||
// There is a system default, so add button to customise or reset
|
||||
if ($sccp_defaults[$res_n]['data'] != $res_v) {
|
||||
$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
|
||||
|
||||
//-- Start include of defaults button --
|
||||
|
@ -403,16 +410,24 @@ class formcreate
|
|||
$res_v = $sccp_defaults[$res_n]['systemdefault'];
|
||||
// Setting a site specific value
|
||||
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 {
|
||||
// reverting to chan-sccp or site default values
|
||||
if ($defButton == 'site') {
|
||||
echo " data-default={$sccp_defaults[$res_n]['data']} class=sccp-restore ";
|
||||
} else {
|
||||
// reverting to chan-sccp default values
|
||||
echo " data-default={$sccp_defaults[$res_n]['systemdefault']} class=sccp-restore ";
|
||||
}
|
||||
}
|
||||
?>
|
||||
>
|
||||
<label
|
||||
<?php
|
||||
echo "for=usedefault_{$res_id} >";
|
||||
echo ($usingSysDefaults) ? "Customise" : "Use {$this->buttonDefLabel} defaults";
|
||||
echo ($usingSysDefaults || $usingSiteDefaults) ? "Customise" : "Use {$this->buttonDefLabel} defaults";
|
||||
?>
|
||||
</label>
|
||||
</span>
|
||||
|
|
|
@ -538,7 +538,7 @@ trait ajaxHelper {
|
|||
}
|
||||
}
|
||||
foreach ($db_field as $key) {
|
||||
$value = "";
|
||||
$value = '';
|
||||
switch ($key) {
|
||||
case 'name':
|
||||
if (!empty($get_settings[$hdr_prefix . 'mac'])) {
|
||||
|
@ -553,10 +553,8 @@ trait ajaxHelper {
|
|||
$name_dev = $value;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'daysdisplaynotactive' :
|
||||
$searchArr = ['daysdisplaynotactive_0', 'daysdisplaynotactive_1', 'daysdisplaynotactive_2', 'daysdisplaynotactive_3', 'daysdisplaynotactive_4', 'daysdisplaynotactive_5', 'daysdisplaynotactive_6'];
|
||||
$value = '';
|
||||
foreach ($searchArr as $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_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_conference', 1, 'sccp_hw', $def_val);
|
||||
echo $this->showGroup('sccp_dev_vendor_conf', 1, 'vendorconfig', $def_val);
|
||||
|
|
|
@ -28,7 +28,6 @@ if (empty($form_prefix)) {
|
|||
// $npref = 'vendorconfig';
|
||||
// $napref = 'vendorconfig-ar';
|
||||
}
|
||||
|
||||
if (empty($fvalues)) {
|
||||
$fvalues = $sccp_defaults;
|
||||
}
|
||||
|
@ -71,7 +70,7 @@ foreach ($items as $child) {
|
|||
$disabledButtons = array('off' => 'Off');
|
||||
}
|
||||
case 'IS':
|
||||
$sccpManager->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons);
|
||||
$sccpManager->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons, $defButton);
|
||||
break;
|
||||
case 'SLD':
|
||||
case 'SLM':
|
||||
|
|
Loading…
Reference in a new issue