First test of new interface to manage defaults hierarchy
WIP Need to better manage display of system defaults when customising Need to override XML defaults
This commit is contained in:
parent
063556f898
commit
b7766fcf64
|
@ -158,15 +158,27 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
|
|
||||||
if ((array) $this->xml_data) {
|
if ((array) $this->xml_data) {
|
||||||
foreach ($this->xml_data->xpath('//page_group[@name="' . $group_name . '"]') as $item) {
|
foreach ($this->xml_data->xpath('//page_group[@name="' . $group_name . '"]') as $item) {
|
||||||
$htmlret = load_view(__DIR__ . '/views/formShow.php', array(
|
// TODO: Clean up below after debug
|
||||||
'itm' => $item,
|
if ($group_name == 'sccp_general') {
|
||||||
'h_show' => $show_Header,
|
$htmlret = load_view(__DIR__ . '/views/formShowSysDefs.php', array(
|
||||||
'form_prefix' => $form_prefix,
|
'itm' => $item,
|
||||||
'fvalues' => $form_values,
|
'h_show' => $show_Header,
|
||||||
'tftp_lang' => $this->tftpLang,
|
'form_prefix' => $form_prefix,
|
||||||
'metainfo' => $this->sccp_metainfo
|
'fvalues' => $form_values,
|
||||||
)
|
'tftp_lang' => $this->tftpLang,
|
||||||
);
|
'metainfo' => $this->sccp_metainfo
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$htmlret = load_view(__DIR__ . '/views/formShow.php', array(
|
||||||
|
'itm' => $item,
|
||||||
|
'h_show' => $show_Header,
|
||||||
|
'form_prefix' => $form_prefix,
|
||||||
|
'fvalues' => $form_values,
|
||||||
|
'tftp_lang' => $this->tftpLang,
|
||||||
|
'metainfo' => $this->sccp_metainfo
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$htmlret = load_view(__DIR__ . '/views/formShowError.php');
|
$htmlret = load_view(__DIR__ . '/views/formShowError.php');
|
||||||
|
@ -198,12 +210,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
$action = !empty($request['action']) ? $request['action'] : '';
|
$action = !empty($request['action']) ? $request['action'] : '';
|
||||||
|
|
||||||
$this->pagedata = array(
|
$this->pagedata = array(
|
||||||
"siteConfig" => array(
|
|
||||||
'name' => _('Site Default Values'),
|
|
||||||
'page' => 'views/siteDefaults.php'
|
|
||||||
),
|
|
||||||
"general" => array(
|
"general" => array(
|
||||||
"name" => _("General SCCP Settings"),
|
"name" => _("Site Default Settings"),
|
||||||
"page" => 'views/server.setting.php'
|
"page" => 'views/server.setting.php'
|
||||||
),
|
),
|
||||||
"sccpdevice" => array(
|
"sccpdevice" => array(
|
||||||
|
|
|
@ -1055,3 +1055,24 @@ function sleep(milliseconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(".custom").click(function() {
|
||||||
|
$(this).parents(".element-container").removeClass("has-error");
|
||||||
|
var id = $(this).data("for"), input = $("#" + id);
|
||||||
|
var edit_style = document.getElementById("edit_" + id).style;
|
||||||
|
console.log(id);
|
||||||
|
if (input.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($(this).is(":checked")) {
|
||||||
|
edit_style.display = 'block';
|
||||||
|
input.prop("readonly", false);
|
||||||
|
input.val(input.data("custom"));
|
||||||
|
input.focus();
|
||||||
|
} else {
|
||||||
|
edit_style.display = 'none';
|
||||||
|
input.data("custom", input.val());
|
||||||
|
input.prop("readonly", true);
|
||||||
|
input.val(input.data("default"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -70,12 +70,11 @@ and open the template in the editor. Base Version before all crash :-)
|
||||||
|
|
||||||
<page_group name="sccp_general">
|
<page_group name="sccp_general">
|
||||||
<label>SCCP Server config</label>
|
<label>SCCP Server config</label>
|
||||||
|
|
||||||
<item type="IE" id="2">
|
<item type="IE" id="2">
|
||||||
<label>SCCP Server Name</label>
|
<label>SCCP Server Name</label>
|
||||||
<input>
|
<input>
|
||||||
<name>servername</name>
|
<name>servername</name>
|
||||||
<default>Vt</default>
|
<default>Asterisk XML</default>
|
||||||
</input>
|
</input>
|
||||||
<help>Servername: This is the type of server - usually, it will be Asterisk.</help>
|
<help>Servername: This is the type of server - usually, it will be Asterisk.</help>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -72,8 +72,11 @@ trait helperfunctions {
|
||||||
private function getTableDefaults($table, $trim_underscore = true) {
|
private function getTableDefaults($table, $trim_underscore = true) {
|
||||||
$def_val = array();
|
$def_val = array();
|
||||||
// TODO: This is ugly and overkill - needs to be cleaned up in dbinterface
|
// TODO: This is ugly and overkill - needs to be cleaned up in dbinterface
|
||||||
|
if ($table == 'sccpsettings') {
|
||||||
|
// sccpsettings has a different structure and already have values in $sccpvalues
|
||||||
|
return $this->sccpvalues;
|
||||||
|
}
|
||||||
$sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}");
|
$sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}");
|
||||||
|
|
||||||
foreach ($sccpTableDesc as $data) {
|
foreach ($sccpTableDesc as $data) {
|
||||||
$key = (string) $data['Field'];
|
$key = (string) $data['Field'];
|
||||||
// function has 2 roles: return actual table keys (trim_underscore = false)
|
// function has 2 roles: return actual table keys (trim_underscore = false)
|
||||||
|
|
1027
views/formShowSysDefs.php
Normal file
1027
views/formShowSysDefs.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,83 +0,0 @@
|
||||||
|
|
||||||
<?php
|
|
||||||
$modules = array('test module 1 key' => array('title' => 'First Block of Defaults',
|
|
||||||
'items' => array('item1' => array('code' => 'This is the value to edit', 'title' => 'variable1'))));
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
<div class='col-md-12'>
|
|
||||||
<div class='fpbx-container'>
|
|
||||||
<form autocomplete="off "class="fpbx-submit" name="frmAdmin" action="config.php?display=featurecodeadmin" method="post">
|
|
||||||
<input type="hidden" name="action" value="save">
|
|
||||||
<div class="display no-border">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<h1><?php echo _("SCCP Site Defaults Administration"); ?></h1>
|
|
||||||
<div>
|
|
||||||
<?php echo "These default settings from chan-sccp can be overridden here. <br>If they are changed, they will not be updated by future changes in chan-sccp "?>
|
|
||||||
</div>
|
|
||||||
<!--Generated-->
|
|
||||||
<?php //echo $modlines ?>
|
|
||||||
<?php foreach($modules as $rawname => $data) { ?>
|
|
||||||
<div class="section-title" data-for="<?php echo $rawname?>">
|
|
||||||
<h2><i class="fa fa-minus"></i> <?php echo $data['title']?></h2>
|
|
||||||
</div>
|
|
||||||
<div class="section" data-id="<?php echo $rawname?>">
|
|
||||||
<div class="element-container hidden-xs">
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h4><?php echo _("Description")?></h4>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
<h4><?php echo _("chan-sccp default")?></h4>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<h4><?php echo _("Actions")?></h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php foreach($data['items'] as $item) {?>
|
|
||||||
<div class="element-container <?php echo !empty($exten_conflict_arr[$item['code']]) ? 'has-error' : ''?>">
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label class="control-label" for="<?php echo $item['feature']?>"><?php echo $item['title']?></label>
|
|
||||||
<?php if(!empty($item['help'])) {?>
|
|
||||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $item['feature']?>"></i>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
<input type="text" name="fc[<?php echo $item['module']?>][<?php echo $item['feature']?>][code]" value="<?php echo $item['code']?>" id="custom_<?php echo $item['id']?>" data-default="<?php echo $item['default']?>" placeholder="<?php echo $item['default']?>" data-custom="<?php echo $item['custom']?>" class="form-control extdisplay" <?php echo (!$item['iscustom']) ? 'readonly' : ''?> required pattern="[0-9A-D\*#]*">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<span class="radioset">
|
|
||||||
<input type="checkbox" data-for="custom_<?php echo $item['id']?>" name="fc[<?php echo $item['module']?>][<?php echo $item['feature']?>][customize]" class="custom" id="usedefault_<?php echo $item['id']?>" <?php echo ($item['iscustom']) ? 'checked' : ''?>>
|
|
||||||
<label for="usedefault_<?php echo $item['id']?>"><?php echo _("Customize")?></label>
|
|
||||||
</span>
|
|
||||||
<span class="radioset">
|
|
||||||
<input type="checkbox" class="enabled" name="fc[<?php echo $item['module']?>][<?php echo $item['feature']?>][enable]" id="ena_<?php echo $item['id']?>" <?php echo ($item['isenabled']) ? 'checked' : ''?>>
|
|
||||||
<label for="ena_<?php echo $item['id']?>"><?php echo _("Enabled")?></label>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<span id="<?php echo $item['feature']?>-help" class="help-block fpbx-help-block"><?php echo $item['help']?></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
<?php } ?>
|
|
||||||
<!--END Generated-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
Loading…
Reference in a new issue