Finish task#3247 管理员可以自定义所有人用的列表的默认布局。,cost:5 left:0
This commit is contained in:
@@ -9,17 +9,19 @@
|
||||
<script>
|
||||
$(function()
|
||||
{
|
||||
var table = $('#wrap > .outer > .main > form > table').first();
|
||||
if($(table).length > 0)
|
||||
var $table = $('#wrap > .outer > .main > form > table').first();
|
||||
if($table.length > 0)
|
||||
{
|
||||
var $dropdown = $("<div class='datatable-menu-wrapper'><div class='dropdown datatable-menu'><button type='button' class='btn btn-link' data-toggle='dropdown'><i class='icon-cogs'></i> <span class='caret'></span></button></div></div>");
|
||||
var $dropmenu = $("<ul class='dropdown-menu pull-right'></ul>");
|
||||
$dropmenu.append("<li><a id='tableCustomBtn' href='<?php echo $this->createLink('datatable', 'ajaxCustom', 'id=' . $this->moduleName . '&method=' . $this->methodName)?>' data-toggle='modal' data-type='ajax'><?php echo $lang->datatable->custom?></a></li>");
|
||||
$dropmenu.append("<li><a href='javascript:;' id='switchToDatatable'><?php echo $lang->datatable->switchToDatatable?></a></li>");
|
||||
$dropdown.children('.dropdown').append($dropmenu);
|
||||
$(table).before($dropdown);
|
||||
$table.before($dropdown);
|
||||
<?php if(!empty($setShowModule)):?>
|
||||
$('.side .side-body .panel-body .tree').parent().append("<div class='text-right'><a href='javascript:;' data-toggle='showModuleModal'><?php echo $lang->datatable->showModule?></a></div>");
|
||||
<?php endif;?>
|
||||
$('#tableCustomBtn').modalTrigger();
|
||||
$("a[data-toggle='showModuleModal']").click(function(){$('#showModuleModal').modal('show')});
|
||||
}
|
||||
|
||||
@@ -33,20 +35,22 @@ $(function()
|
||||
saveDatatableConfig('showModule', $('#showModuleModal input[name="showModule"]:checked').val(), true)
|
||||
});
|
||||
|
||||
function saveDatatableConfig(name, value, reload)
|
||||
function saveDatatableConfig(name, value, reload, global)
|
||||
{
|
||||
if('<?php echo $this->app->user->account?>' == 'guest') return;
|
||||
datatableId = '<?php echo $datatableId?>';
|
||||
if(typeof value === 'object') value = JSON.stringify(value);
|
||||
if(typeof global === 'undefined') global = 0;
|
||||
$.ajax(
|
||||
{
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
data: {target: datatableId, name: name, value: value},
|
||||
data: {target: datatableId, name: name, value: value, global: global},
|
||||
success:function(){if(reload) window.location.reload();},
|
||||
url: '<?php echo $this->createLink('datatable', 'ajaxSave')?>'
|
||||
});
|
||||
};
|
||||
window.saveDatatableConfig = saveDatatableConfig;
|
||||
});
|
||||
</script>
|
||||
<div class="modal fade" id="showModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
|
||||
@@ -84,16 +84,17 @@ $(document).ready(function()
|
||||
}
|
||||
});
|
||||
|
||||
window.saveDatatableConfig = function(name, value, reload)
|
||||
window.saveDatatableConfig = function(name, value, reload, global)
|
||||
{
|
||||
if('<?php echo $this->app->user->account?>' == 'guest') return;
|
||||
var datatableId = '<?php echo $datatableId;?>';
|
||||
if(typeof value === 'object') value = JSON.stringify(value);
|
||||
if('<?php echo $this->app->user->account?>' == 'guest') return;
|
||||
if(typeof global === 'undefined') global = 0;
|
||||
$.ajax(
|
||||
{
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
data: {target: datatableId, name: name, value: value},
|
||||
data: {target: datatableId, name: name, value: value, global: global},
|
||||
success:function(e){if(reload) window.location.reload();},
|
||||
url: '<?php echo $this->createLink('datatable', 'ajaxSave')?>'
|
||||
});
|
||||
|
||||
@@ -33,6 +33,7 @@ class datatable extends control
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$account = $this->app->user->account;
|
||||
if($this->post->global) $account = 'system';
|
||||
if($account == 'guest') $this->send(array('result' => 'fail', 'target' => $target, 'message' => 'guest.'));
|
||||
|
||||
$name = $account . '.datatable.' . $this->post->target . '.' . $this->post->name;
|
||||
@@ -52,11 +53,9 @@ class datatable extends control
|
||||
*/
|
||||
public function ajaxCustom($module, $method)
|
||||
{
|
||||
$account = $this->app->user->account;
|
||||
$target = $module . ucfirst($method);
|
||||
$mode = isset($this->config->datatable->$target->mode) ? $this->config->datatable->$target->mode : 'table';
|
||||
$key = $mode == 'datatable' ? 'cols' : 'tablecols';
|
||||
$name = "owner=$account&module=datatable§ion=$target&key=$key";
|
||||
$target = $module . ucfirst($method);
|
||||
$mode = isset($this->config->datatable->$target->mode) ? $this->config->datatable->$target->mode : 'table';
|
||||
$key = $mode == 'datatable' ? 'cols' : 'tablecols';
|
||||
|
||||
if($module == 'testtask')
|
||||
{
|
||||
@@ -72,12 +71,19 @@ class datatable extends control
|
||||
|
||||
$this->view->module = $module;
|
||||
$this->view->method = $method;
|
||||
$this->view->mode = $mode;
|
||||
|
||||
$module = zget($this->config->datatable->moduleAlias, $module, $module);
|
||||
$setting = '';
|
||||
if(isset($this->config->datatable->$target->$key)) $setting = $this->config->datatable->$target->$key;
|
||||
if(empty($setting))
|
||||
{
|
||||
$this->loadModel($module);
|
||||
$setting = json_encode($this->config->$module->datatable->defaultField);
|
||||
}
|
||||
|
||||
$module = zget($this->config->datatable->moduleAlias, $module, $module);
|
||||
$this->view->cols = $this->datatable->getFieldList($module);
|
||||
$this->view->setting = $this->loadModel('setting')->getItem($name);
|
||||
if(empty($this->view->setting)) $this->view->setting = json_encode($this->config->$module->datatable->defaultField);
|
||||
|
||||
$this->view->setting = $setting;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -90,14 +96,15 @@ class datatable extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxReset($module, $method, $confirm = 'no')
|
||||
public function ajaxReset($module, $method, $system = 0, $confirm = 'no')
|
||||
{
|
||||
if($confirm == 'no') die(js::confirm($this->lang->datatable->confirmReset, inlink('ajaxReset', "module=$module&method=$method&confirm=yes")));
|
||||
if($confirm == 'no') die(js::confirm($this->lang->datatable->confirmReset, inlink('ajaxReset', "module=$module&method=$method&system=$system&confirm=yes")));
|
||||
|
||||
$account = $this->app->user->account;
|
||||
$target = $module . ucfirst($method);
|
||||
$mode = isset($this->config->datatable->$target->mode) ? $this->config->datatable->$target->mode : 'table';
|
||||
$key = $mode == 'datatable' ? 'cols' : 'tablecols';
|
||||
if($system) $account = 'system';
|
||||
|
||||
$this->loadModel('setting')->deleteItems("owner=$account&module=datatable§ion=$target&key=$key");
|
||||
die(js::reload('parent'));
|
||||
|
||||
@@ -4,12 +4,16 @@ $lang->datatable->common = 'Data Table';
|
||||
$lang->datatable->width = 'Width';
|
||||
$lang->datatable->show = 'Show';
|
||||
$lang->datatable->hide = 'Hide';
|
||||
$lang->datatable->reset = 'Reset';
|
||||
|
||||
$lang->datatable->custom = 'Custom Columns';
|
||||
$lang->datatable->customTip = 'Check Columns to Display';
|
||||
$lang->datatable->switchToTable = 'Switch to Table';
|
||||
$lang->datatable->switchToDatatable = 'Switch to Datatable';
|
||||
$lang->datatable->required = 'Required';
|
||||
$lang->datatable->confirmReset = 'Do you want to restore the default settings?';
|
||||
$lang->datatable->setGlobal = 'Global';
|
||||
$lang->datatable->resetGlobal = 'Reset Global Default';
|
||||
|
||||
$lang->datatable->branch = 'Branch';
|
||||
$lang->datatable->platform = 'Platform';
|
||||
|
||||
@@ -12,6 +12,8 @@ $lang->datatable->switchToTable = '切换到简单表格';
|
||||
$lang->datatable->switchToDatatable = '切换到高级表格';
|
||||
$lang->datatable->required = '必选';
|
||||
$lang->datatable->confirmReset = '是否恢复默认设置?';
|
||||
$lang->datatable->setGlobal = '全局';
|
||||
$lang->datatable->resetGlobal = '全局恢复默认';
|
||||
|
||||
$lang->datatable->branch = '分支';
|
||||
$lang->datatable->platform = '平台';
|
||||
|
||||
@@ -49,9 +49,12 @@ class datatableModel extends model
|
||||
{
|
||||
$datatableId = $module . ucfirst($this->app->getMethodName());
|
||||
|
||||
$mode = isset($this->config->datatable->$datatableId->mode) ? $this->config->datatable->$datatableId->mode : 'table';
|
||||
$key = $mode == 'datatable' ? 'cols' : 'tablecols';
|
||||
|
||||
$module = zget($this->config->datatable->moduleAlias, $module, $module);
|
||||
if(!isset($this->config->$module)) $this->loadModel($module);
|
||||
if(isset($this->config->datatable->$datatableId->cols)) $setting = json_decode($this->config->datatable->$datatableId->cols);
|
||||
if(isset($this->config->datatable->$datatableId->$key)) $setting = json_decode($this->config->datatable->$datatableId->$key);
|
||||
|
||||
$fieldList = $this->getFieldList($module);
|
||||
if(empty($setting))
|
||||
@@ -120,7 +123,7 @@ class datatableModel extends model
|
||||
$id = $col->id;
|
||||
if($col->show)
|
||||
{
|
||||
echo "<th data-flex='" . ($col->fixed == 'no' ? 'true': 'false') . "' data-width='{$col->width}' class='w-$id'>";
|
||||
echo "<th data-flex='" . ($col->fixed == 'no' ? 'true': 'false') . "' data-width='{$col->width}' style='width:" . (is_numeric($col->width) ? "{$col->width}px" : $col->width) . "' class='w-$id'>";
|
||||
if($id == 'actions')
|
||||
{
|
||||
echo $this->lang->actions;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
?>
|
||||
<style>
|
||||
.cols-list {margin-bottom: 10px;}
|
||||
.cols-list .col {border: 1px solid #ddd; height: 30px; line-height: 29px; padding: 0 10px; border-bottom: none; background: #fff}
|
||||
.cols-list .col {border: 1px solid #ddd; height: 30px; line-height: 29px; padding: 0 10px; border-bottom: none; background: #fff; float:none}
|
||||
.cols-list .col.drag-shadow {border: 1px solid #ddd;}
|
||||
.cols-list {border-bottom: 1px solid #ddd}
|
||||
.cols-list .col:hover {background: #edf3fe}
|
||||
@@ -62,20 +62,25 @@
|
||||
<div class='clearfix col<?php echo ($required ? ' require' : '') . (' fixed-' . $fixed) ?>' data-key='<?php echo $key?>' data-fixed='<?php echo $fixed?>' data-width='<?php echo $col['width']?>'>
|
||||
<i class='icon-ok'></i> <span class='title'><span class='title-bar'><strong><?php echo $col['title']?></strong><i class='icon-move'></i></span></span> <?php if($required) echo "<span class='text-muted'>({$lang->datatable->required})</span>"?>
|
||||
<div class='actions pull-right'>
|
||||
<span><span class='text-muted'><?php echo $lang->datatable->width?></span> <input type='text' class='form-control' <?php echo $autoWidth ? "disabled='disabled'" : '' ?>value='<?php echo $col['width']?>'><?php echo $autoWidth ? ' ' : 'px' ?></span>
|
||||
<span><span class='text-muted'><?php echo $lang->datatable->width?></span> <input type='text' class='form-control' value='<?php echo $col['width']?>'><?php echo $autoWidth ? ' ' : 'px' ?></span>
|
||||
<button type='button' class='btn btn-link show-hide<?php echo $required ? ' disabled' : '' ?>'><span class='label-show'><?php echo $lang->datatable->show?></span><span class='text-muted'>/</span><span class='label-hide'><?php echo $lang->datatable->hide?></span></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
<div class='actions text-center'>
|
||||
<button type='button' class='btn btn-primary btn-save' id='btnSaveCustom'><?php echo $lang->save ?></button>
|
||||
<div class='actions text-left'>
|
||||
<?php if(common::hasPriv('datatable', 'setGlobal')) echo html::checkbox('global', array(1 => $lang->datatable->setGlobal));?>
|
||||
<button type='button' class='btn btn-primary btn-save' id='btnSaveCustom'><?php echo $lang->save ?></button>
|
||||
<button type='button' class='btn btn-default' data-dismiss='modal'><?php echo $lang->close ?></button>
|
||||
<?php echo html::a(inlink('ajaxReset', "module=$module&method=$method"), $lang->datatable->reset, 'hiddenwin', "class='btn btn-default'");?>
|
||||
<button type='button' class='btn btn-default' id='resetBtn'><?php echo $lang->datatable->reset ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
js::set('resetText', $lang->datatable->reset);
|
||||
js::set('resetGlobalText', $lang->datatable->resetGlobal);
|
||||
?>
|
||||
<script>
|
||||
$(function()
|
||||
{
|
||||
@@ -133,7 +138,6 @@ $(function()
|
||||
if($cols.length < 2)
|
||||
{
|
||||
$list.addClass('sort-disabled');
|
||||
$cols.find('input').val('auto').attr('disabled', 'disabled');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -180,7 +184,21 @@ $(function()
|
||||
return sets;
|
||||
}).get();
|
||||
|
||||
window.saveDatatableConfig('cols', setting, true);
|
||||
window.saveDatatableConfig('<?php echo $mode == 'table' ? 'tablecols' : 'cols';?>', setting, true, $('#global1').prop('checked') ? 1 : 0);
|
||||
});
|
||||
|
||||
$('#resetBtn').on("click", function()
|
||||
{
|
||||
var system = $('#global1').prop('checked') ? 1 : 0;
|
||||
var param = "<?php echo "module=$module&method=$method"?>&system=" + system;
|
||||
hiddenwin.location.href = createLink('datatable', 'ajaxReset', param);
|
||||
})
|
||||
|
||||
$('#global1').change(function()
|
||||
{
|
||||
if($(this).prop('checked'))$('#resetBtn').text(resetGlobalText);
|
||||
if(!$(this).prop('checked'))$('#resetBtn').text(resetText);
|
||||
})
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user