* Finish task #53655.
This commit is contained in:
@@ -695,6 +695,26 @@ class doc extends control
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update order.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updateOrder()
|
||||
{
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST')
|
||||
{
|
||||
foreach($_POST['orders'] as $id => $order)
|
||||
{
|
||||
$this->dao->update(TABLE_DOC)->set('`order`')->eq($order)->where('id')->eq($id)->exec();
|
||||
}
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
return $this->send(array('result' => 'success'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get modules by libID.
|
||||
*
|
||||
|
||||
@@ -93,6 +93,7 @@ $lang->doc->collector = 'Collector';
|
||||
$lang->doc->main = 'Main Document Library';
|
||||
$lang->doc->order = 'Order';
|
||||
$lang->doc->doc = 'Document';
|
||||
$lang->doc->updateOrder = 'Update Order';
|
||||
|
||||
$lang->doc->moduleDoc = 'By Module';
|
||||
$lang->doc->searchDoc = 'Search';
|
||||
|
||||
@@ -93,6 +93,7 @@ $lang->doc->collector = '收藏者';
|
||||
$lang->doc->main = '文档主库';
|
||||
$lang->doc->order = '排序';
|
||||
$lang->doc->doc = '文档';
|
||||
$lang->doc->updateOrder = '更新排序';
|
||||
|
||||
$lang->doc->moduleDoc = '按模块浏览';
|
||||
$lang->doc->searchDoc = '搜索';
|
||||
|
||||
+19
-11
@@ -2379,6 +2379,7 @@ EOT;
|
||||
$docs = $this->dao->select('*')->from(TABLE_DOC)
|
||||
->where('lib')->eq($rootID)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->orderBy('`order` asc')
|
||||
->fetchAll();
|
||||
$moduleDocs = array();
|
||||
foreach($docs as $doc)
|
||||
@@ -2410,7 +2411,8 @@ EOT;
|
||||
{
|
||||
if(!$docID and $currentMethod != 'tablecontents') $docID = $doc->id;
|
||||
|
||||
$treeMenu[0] .= '<li' . ($doc->id == $docID ? ' class="active"' : ' class="independent"') . " data-id=$doc->id>";
|
||||
$class = common::hasPriv('doc', 'updateOrder') ? ' sortDoc' : '';
|
||||
$treeMenu[0] .= '<li' . " class='" . ($doc->id == $docID ? 'active' : 'doc') . "$class'" . " data-id=$doc->id>";
|
||||
|
||||
if($currentMethod == 'tablecontents')
|
||||
{
|
||||
@@ -2418,11 +2420,13 @@ EOT;
|
||||
}
|
||||
if($currentMethod == 'objectlibs')
|
||||
{
|
||||
$treeMenu[0] .= "<div class='tree-group'><span class='module-name'>" . html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$rootID&docID={$doc->id}"), "<i class='icon icon-file-text text-muted'></i> " . $doc->title, '', "data-app='{$this->app->tab}' class='doc-title' title='{$doc->title}'") . '</span>';
|
||||
if(common::hasPriv('doc', 'edit'))
|
||||
$class = common::hasPriv('doc', 'updateOrder') ? 'sortDoc' : '';
|
||||
$treeMenu[0] .= "<div class='tree-group'><span class='module-name'>" . html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$rootID&docID={$doc->id}"), "<i class='icon icon-file-text text-muted'></i> " . $doc->title, '', "data-app='{$this->app->tab}' class='doc-title $class' title='{$doc->title}'") . '</span>';
|
||||
if(common::hasPriv('doc', 'edit') or common::hasPriv('doc', 'updateOrder'))
|
||||
{
|
||||
$treeMenu[0] .= "<div class='tree-actions'>";
|
||||
$treeMenu[0] .= html::a(helper::createLink('doc', 'edit', "docID={$doc->id}&comment=false&objectType=$type&objectID=$objectID&libID=$rootID"), "<i class='icon icon-edit'></i>", '', "title={$this->lang->doc->edit} data-app='{$this->app->tab}'");
|
||||
if(common::hasPriv('doc', 'edit')) $treeMenu[0] .= html::a(helper::createLink('doc', 'edit', "docID={$doc->id}&comment=false&objectType=$type&objectID=$objectID&libID=$rootID"), "<i class='icon icon-edit'></i>", '', "title={$this->lang->doc->edit} data-app='{$this->app->tab}'");
|
||||
if(common::hasPriv('doc', 'updateOrder')) $treeMenu[0] .= html::a('javascript:;', "<i class='icon icon-move sortDoc'></i>", '', "title='{$this->lang->doc->updateOrder}' class='sortDoc'");
|
||||
$treeMenu[0] .= '</div></div>';
|
||||
}
|
||||
}
|
||||
@@ -2477,7 +2481,8 @@ EOT;
|
||||
else
|
||||
{
|
||||
if(!$docID and $currentMethod != 'tablecontents') $docID = $doc->id;
|
||||
$treeMenu[$module->id] .= '<li' . ($doc->id == $docID ? ' class="active"' : ' class="doc"') . " data-id=$doc->id>";
|
||||
$class = common::hasPriv('doc', 'updateOrder') ? ' sortDoc' : '';
|
||||
$treeMenu[$module->id] .= '<li' . " class='" . ($doc->id == $docID ? 'active' : 'doc') . "$class'" . " data-id=$doc->id>";
|
||||
|
||||
if($currentMethod == 'tablecontents')
|
||||
{
|
||||
@@ -2486,11 +2491,13 @@ EOT;
|
||||
|
||||
if($currentMethod == 'objectlibs')
|
||||
{
|
||||
$treeMenu[$module->id] .= "<div class='tree-group'><span class='module-name'>" . html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$libID&docID={$doc->id}"), "<i class='icon icon-file-text text-muted'></i> " . $doc->title, '', "data-app='{$this->app->tab}' class='doc-title' title='{$doc->title}'") . '</span>';
|
||||
if(common::hasPriv('doc', 'edit'))
|
||||
$class = common::hasPriv('doc', 'updateOrder') ? 'sortDoc' : '';
|
||||
$treeMenu[$module->id] .= "<div class='tree-group'><span class='module-name'>" . html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$libID&docID={$doc->id}"), "<i class='icon icon-file-text text-muted'></i> " . $doc->title, '', "data-app='{$this->app->tab}' class='doc-title $class' title='{$doc->title}'") . '</span>';
|
||||
if(common::hasPriv('doc', 'edit') or common::hasPriv('doc', 'updateOrder'))
|
||||
{
|
||||
$treeMenu[$module->id] .= "<div class='tree-actions'>";
|
||||
$treeMenu[$module->id] .= html::a(helper::createLink('doc', 'edit', "docID={$doc->id}&comment=false&objectType=$type&objectID=$objectID&libID=$libID"), "<i class='icon icon-edit'></i>", '', "title={$this->lang->doc->edit} data-app={$this->app->tab}");
|
||||
if(common::hasPriv('doc', 'edit')) $treeMenu[$module->id] .= html::a(helper::createLink('doc', 'edit', "docID={$doc->id}&comment=false&objectType=$type&objectID=$objectID&libID=$libID"), "<i class='icon icon-edit'></i>", '', "title={$this->lang->doc->edit} data-app={$this->app->tab}");
|
||||
if(common::hasPriv('doc', 'updateOrder')) $treeMenu[$module->id] .= html::a('javascript:;', "<i class='icon icon-move sortDoc'></i>", '', "title='{$this->lang->doc->updateOrder}' class='sortDoc'");
|
||||
$treeMenu[$module->id] .= '</div>';
|
||||
}
|
||||
$treeMenu[$module->id] .= '</div>';
|
||||
@@ -2518,11 +2525,12 @@ EOT;
|
||||
else
|
||||
{
|
||||
$li = "<div class='tree-group'><span class='module-name'><a class='sort-module' title='{$module->name}'>" . $module->name . '</a></span>';
|
||||
if(common::hasPriv('tree', 'edit') or common::hasPriv('tree', 'browse'))
|
||||
if(common::hasPriv('tree', 'edit') or common::hasPriv('tree', 'browse') or common::hasPriv('tree', 'updateOrder'))
|
||||
{
|
||||
$li .= "<div class='tree-actions'>";
|
||||
if(common::hasPriv('tree', 'edit')) $li .= html::a(helper::createLink('tree', 'edit', "module=$module->id&type=doc"), "<i class='icon icon-edit'></i>", '', "data-toggle='modal' title={$this->lang->doc->editType}");
|
||||
if(common::hasPriv('tree', 'browse')) $li .= html::a(helper::createLink('tree', 'browse', "rootID=$libID&type=doc&module=$module->id", '', 1), "<i class='icon icon-split'></i>", '', "class='iframe' title={$this->lang->doc->editChildType}");
|
||||
if(common::hasPriv('tree', 'edit')) $li .= html::a(helper::createLink('tree', 'edit', "module=$module->id&type=doc"), "<i class='icon icon-edit'></i>", '', "data-toggle='modal' title='{$this->lang->doc->editType}'");
|
||||
if(common::hasPriv('tree', 'browse')) $li .= html::a(helper::createLink('tree', 'browse', "rootID=$libID&type=doc&module=$module->id", '', 1), "<i class='icon icon-split'></i>", '', "class='iframe' title='{$this->lang->doc->editChildType}'");
|
||||
if(common::hasPriv('tree', 'updateOrder')) $li .= html::a('javascript:;', "<i class='icon icon-move sortModule'></i>", '', "title='{$this->lang->doc->updateOrder}' class='sortModule'");
|
||||
$li .= '</div>';
|
||||
}
|
||||
$li .= '</div>';
|
||||
|
||||
@@ -79,7 +79,7 @@ $sideWidth = common::checkNotCN() ? '270' : '238';
|
||||
/* Make modules tree sortable */
|
||||
$('#modules').sortable(
|
||||
{
|
||||
trigger: '.module-name>a.sort-module',
|
||||
trigger: '.module-name>a.sort-module, .tree-actions>.sortModule>.icon-move, .module-name>a.sortDoc, .tree-actions>.sortDoc>.icon-move',
|
||||
dropToClass: 'sort-to',
|
||||
stopPropagation: true,
|
||||
nested: true,
|
||||
@@ -100,7 +100,15 @@ $sideWidth = common::checkNotCN() ? '270' : '238';
|
||||
{
|
||||
if($('#modules').hasClass('sortable-sorting')) $ul.addClass('is-sorting');
|
||||
}, 100);
|
||||
return $ul.children('li');
|
||||
|
||||
if($ele.hasClass('sortDoc'))
|
||||
{
|
||||
return $ul.children('li.sortDoc');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $ul.children('li.catalog');
|
||||
}
|
||||
},
|
||||
always: function()
|
||||
{
|
||||
@@ -110,16 +118,34 @@ $sideWidth = common::checkNotCN() ? '270' : '238';
|
||||
{
|
||||
if(!e.changed) return;
|
||||
|
||||
var orders = {};
|
||||
$('#modules').find('li.can-sort').each(function()
|
||||
var orders = {};
|
||||
var link = '';
|
||||
var elementClass = e.list.context.className;
|
||||
if(elementClass.indexOf('sortDoc') >= 0)
|
||||
{
|
||||
var $li = $(this);
|
||||
$('#modules').find('li.sortDoc').each(function()
|
||||
{
|
||||
var $li = $(this);
|
||||
|
||||
var item = $li.data();
|
||||
'<?php echo $type;?>' == 'book' ? orders['sort[' + item.id + ']'] = $li.attr('data-order') || item.order : orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order;
|
||||
});
|
||||
var item = $li.data();
|
||||
orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order;
|
||||
});
|
||||
|
||||
link = createLink('doc', 'updateOrder');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#modules').find('li.can-sort').each(function()
|
||||
{
|
||||
var $li = $(this);
|
||||
|
||||
var item = $li.data();
|
||||
'<?php echo $type;?>' == 'book' ? orders['sort[' + item.id + ']'] = $li.attr('data-order') || item.order : orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order;
|
||||
});
|
||||
|
||||
link = '<?php echo $type?>' == 'book' ? createLink('doc', 'sortBookOrder') : createLink('tree', 'updateOrder');
|
||||
}
|
||||
|
||||
var link = '<?php echo $type;?>' == 'book' ? createLink('doc', 'sortBookOrder') : createLink('tree', 'updateOrder');
|
||||
$.post(link, orders, function(data){}).error(function()
|
||||
{
|
||||
bootbox.alert(lang.timeout);
|
||||
|
||||
@@ -1215,6 +1215,7 @@ $lang->resource->doc->objectLibs = 'objectLibs';
|
||||
$lang->resource->doc->collect = 'collectAction';
|
||||
$lang->resource->doc->tableContents = 'tableContents';
|
||||
$lang->resource->doc->showFiles = 'showFiles';
|
||||
$lang->resource->doc->updateOrder = 'updateOrder';
|
||||
|
||||
$lang->doc->methodOrder[0] = 'index';
|
||||
$lang->doc->methodOrder[5] = 'browse';
|
||||
|
||||
Reference in New Issue
Block a user