修复插件基类Controller被调用两次的BUG

添加插件初始化的行为
修复表格始终显示排序按钮的BUG
优化部分视图的权限判断
优化本地上传插件的提示
pull/9/head
Karson 2017-08-17 14:19:56 +08:00
parent 3b295553a6
commit 6b4cb9c52a
11 changed files with 38 additions and 29 deletions

View File

@ -89,7 +89,7 @@ function build_category_select($name, $type, $selected = null, $attr = [], $head
function build_toolbar($btns = NULL, $attr = [])
{
$auth = \app\admin\library\Auth::instance();
$controller = strtolower(think\Request::instance()->controller());
$controller = str_replace('.','/',strtolower(think\Request::instance()->controller()));
$btns = $btns ? $btns : ['refresh', 'add', 'edit', 'del'];
$btns = is_array($btns) ? $btns : explode(',', $btns);
$index = array_search('delete', $btns);

View File

@ -196,6 +196,8 @@ class Addon extends Backend
*/
public function local()
{
Config::set('default_return_type', 'json');
$file = $this->request->file('file');
$addonTmpDir = RUNTIME_PATH . 'addons' . DS;
if (!is_dir($addonTmpDir))

View File

@ -8,11 +8,11 @@
<div id="toolbar" class="toolbar">
{:build_toolbar('refresh,add,delete')}
</div>
<table id="table" class="table table-striped table-bordered table-hover" width="100%">
<table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('auth/admin/edit')}"
data-operate-del="{:$auth->check('auth/admin/del')}"
width="100%">
</table>
</div>
</div>

View File

@ -8,11 +8,11 @@
<div id="toolbar" class="toolbar">
{:build_toolbar('refresh,delete')}
</div>
<table id="table" class="table table-striped table-bordered table-hover" width="100%">
<table id="table" class="table table-striped table-bordered table-hover"
data-operate-detail="{:$auth->check('auth/adminlog/index')}"
data-operate-del="{:$auth->check('auth/adminlog/del')}"
width="100%">
</table>
</div>
</div>

View File

@ -8,8 +8,10 @@
<div id="toolbar" class="toolbar">
{:build_toolbar('refresh,add,delete')}
</div>
<table id="table" class="table table-striped table-bordered table-hover" width="100%">
<table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('auth/group/edit')}"
data-operate-del="{:$auth->check('auth/group/del')}"
width="100%">
</table>
</div>
</div>

View File

@ -9,8 +9,10 @@
{:build_toolbar()}
<a href="javascript:;" class="btn btn-danger btn-toggle-all"><i class="fa fa-plus"></i> {:__('Toggle all')}</a>
</div>
<table id="table" class="table table-bordered table-hover" width="100%">
<table id="table" class="table table-bordered table-hover"
data-operate-edit="{:$auth->check('auth/rule/edit')}"
data-operate-del="{:$auth->check('auth/rule/del')}"
width="100%">
</table>
</div>
</div>

View File

@ -7,7 +7,7 @@
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
{:build_toolbar()}
<div class="dropdown btn-group">
<div class="dropdown btn-group {:$auth->check('category/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
@ -15,7 +15,10 @@
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover" width="100%">
<table id="table" class="table table-striped table-bordered table-hover"
data-operate-edit="{:$auth->check('category/edit')}"
data-operate-del="{:$auth->check('category/del')}"
width="100%">
</table>
</div>
</div>

View File

@ -13,7 +13,7 @@
<!-- Bootstrap Core CSS -->
<link href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/css/index.css" rel="stylesheet">
<link href="__CDN__/assets/css/index.css" rel="stylesheet">
<!-- Plugin CSS -->
<link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
@ -34,7 +34,7 @@
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-menu">
<span class="sr-only">Toggle navigation</span><i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top"><img src="/assets/img/logo.png" style="width:200px;" alt=""></a>
<a class="navbar-brand page-scroll" href="#page-top"><img src="__CDN__/assets/img/logo.png" style="width:200px;" alt=""></a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-menu">

View File

@ -19,6 +19,10 @@ return [
'module_init' => [
'app\\common\\behavior\\Common',
],
// 模块初始化
'addons_init' => [
'app\\common\\behavior\\Common',
],
// 操作开始执行
'action_begin' => [],
// 视图内容过滤

View File

@ -7992,11 +7992,6 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
}
}
},
auth: {
check: function (name) {
}
},
// 单元格数据格式化
formatter: {
icon: function (value, row, index) {
@ -8087,8 +8082,11 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
buttons.push({name: 'del', icon: 'fa fa-trash', classname: 'btn btn-xs btn-danger btn-delone'});
var html = [];
$.each(buttons, function (i, j) {
if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
return true;
}
var attr = table.data("operate-" + j.name);
if ((typeof attr === 'undefined' || attr) || (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] == 'undefined')) {
if (typeof attr === 'undefined' || attr) {
if (['add', 'edit', 'del', 'multi'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
return true;
}

View File

@ -287,11 +287,6 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
}
}
},
auth: {
check: function (name) {
}
},
// 单元格数据格式化
formatter: {
icon: function (value, row, index) {
@ -382,8 +377,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
buttons.push({name: 'del', icon: 'fa fa-trash', classname: 'btn btn-xs btn-danger btn-delone'});
var html = [];
$.each(buttons, function (i, j) {
if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
return true;
}
var attr = table.data("operate-" + j.name);
if ((typeof attr === 'undefined' || attr) || (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] == 'undefined')) {
if (typeof attr === 'undefined' || attr) {
if (['add', 'edit', 'del', 'multi'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
return true;
}