Merge branch 'sprint/189_tianshujie_task53655' into 'master'
Sprint/189 tianshujie task53655 See merge request easycorp/zentaopms!3332
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.
|
||||
*
|
||||
|
||||
@@ -20,3 +20,21 @@ span.dotted-line+a {display: block;}
|
||||
.tree li.has-list.open:before {content: unset;}
|
||||
#modules i.icon-file-text {color: #D0D2D6; font-size: 14px;}
|
||||
.tree li>a {max-width: 80%;}
|
||||
|
||||
.sortable-sorting .module-name > a {cursor: move;}
|
||||
.sortable-sorting li >.tree-group {opacity: .5;}
|
||||
.sortable-sorting .drop-here .tree-group {background-color: #fff3e0;}
|
||||
.sortable-sorting .drop-here .tree-group > * {opacity: .1;}
|
||||
.sortable-sorting .drag-shadow .tree-group {opacity: 1!important;}
|
||||
.sortable-sorting .drag-shadow .tree-actions {visibility: hidden;}
|
||||
.is-sorting > li > .tree-group {opacity: 1; border-radius: 4px;}
|
||||
.is-sorting > li ul {display: none!important;}
|
||||
|
||||
.tree-group {position: relative;}
|
||||
.tree-group > .module-name {white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; display: block;}
|
||||
.tree-group .tree-actions {display: none; position: absolute; right: 0; top: 0; background-color: #fff; white-space: nowrap;}
|
||||
.tree-group:hover > .module-name {width: calc(100% - 20px);}
|
||||
.tree-group:hover .tree-actions {display: block}
|
||||
.tree li.has-list.open:before {left: 6px;}
|
||||
.sortDoc>.tail-info{right: 20px;}
|
||||
.sortDoc>.tree-actions{position: absolute; right: 0px; background: #fff;}
|
||||
|
||||
@@ -18,4 +18,81 @@ $(function()
|
||||
})
|
||||
|
||||
$('.menu-actions > a').blur(function() {$(this).css('background', 'none');})
|
||||
|
||||
/* Make modules tree sortable. */
|
||||
$('#modules').sortable(
|
||||
{
|
||||
trigger: '.module-name>a.sort-module, .tree-actions>.sortModule>.icon-move, a.sortDoc, .tree-actions>.sortDoc>.icon-move',
|
||||
dropToClass: 'sort-to',
|
||||
stopPropagation: true,
|
||||
nested: true,
|
||||
selector: 'li',
|
||||
dragCssClass: 'drop-here',
|
||||
canMoveHere: function($ele, $target)
|
||||
{
|
||||
var maxTop = $('.side-col > .cell > ul').height() - $ele.height();
|
||||
if(parseFloat($('.drag-shadow').css('top')) < 0) $('.drag-shadow').css('top', '0');
|
||||
if(parseFloat($('.drag-shadow').css('left')) != 0) $('.drag-shadow').css('left', '0');
|
||||
if(parseFloat($('.drag-shadow').css('top')) > maxTop) $('.drag-shadow').css('top', maxTop + 'px');
|
||||
return true;
|
||||
},
|
||||
targetSelector: function($ele, $root)
|
||||
{
|
||||
var $ul = $ele.closest('ul');
|
||||
setTimeout(function()
|
||||
{
|
||||
if($('#modules').hasClass('sortable-sorting')) $ul.addClass('is-sorting');
|
||||
}, 100);
|
||||
|
||||
if($ele.hasClass('sortDoc'))
|
||||
{
|
||||
return $ul.children('li.sortDoc');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $ul.children('li.catalog');
|
||||
}
|
||||
},
|
||||
always: function()
|
||||
{
|
||||
$('#modules,#modules .is-sorting').removeClass('is-sorting');
|
||||
},
|
||||
finish: function(e)
|
||||
{
|
||||
if(!e.changed) return;
|
||||
|
||||
var orders = {};
|
||||
var link = '';
|
||||
var elementClass = e.list.context.className;
|
||||
if(elementClass.indexOf('sortDoc') >= 0)
|
||||
{
|
||||
$('#modules').find('li.sortDoc').each(function()
|
||||
{
|
||||
var $li = $(this);
|
||||
|
||||
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 = createLink('tree', 'updateOrder');
|
||||
}
|
||||
|
||||
$.post(link, orders, function(data){}).error(function()
|
||||
{
|
||||
bootbox.alert(lang.timeout);
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -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 = '搜索';
|
||||
|
||||
+45
-19
@@ -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,25 +2411,36 @@ 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')
|
||||
{
|
||||
$treeMenu[0] .= '<span class="tail-info">' . zget($users, $doc->editedBy) . ' ' . $doc->editedDate . '</span>';
|
||||
$treeMenu[0] .= '<div class="tree-group"><span class="tail-info">' . zget($users, $doc->editedBy) . ' ' . $doc->editedDate . '</span>';
|
||||
if(common::hasPriv('doc', 'updateOrder'))
|
||||
{
|
||||
$treeMenu[0] .= "<div class='tree-actions'>";
|
||||
$treeMenu[0] .= html::a('javascript:;', "<i class='icon icon-move sortDoc'></i>", '', "title='{$this->lang->doc->updateOrder}' class='sortDoc'");
|
||||
$treeMenu[0] .= '</div>';
|
||||
}
|
||||
}
|
||||
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>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$treeMenu[0] .= 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}'");
|
||||
$class = common::hasPriv('doc', 'updateOrder') ? 'sortDoc' : '';
|
||||
$treeMenu[0] .= 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}'");
|
||||
$treeMenu[0] .= '</div>';
|
||||
}
|
||||
|
||||
$treeMenu[0] .= '</li>';
|
||||
@@ -2477,27 +2489,38 @@ 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')
|
||||
{
|
||||
$treeMenu[$module->id] .= '<span class="tail-info">' . zget($users, $doc->editedBy) . ' ' . $doc->editedDate . '</span>';
|
||||
$treeMenu[$module->id] .= '<div class="tree-group"><span class="tail-info">' . zget($users, $doc->editedBy) . ' ' . $doc->editedDate . '</span>';
|
||||
if(common::hasPriv('doc', 'updateOrder'))
|
||||
{
|
||||
$treeMenu[$module->id] .= "<div class='tree-actions'>";
|
||||
$treeMenu[$module->id] .= html::a('javascript:;', "<i class='icon icon-move sortDoc'></i>", '', "title='{$this->lang->doc->updateOrder}' class='sortDoc'");
|
||||
$treeMenu[$module->id] .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
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>';
|
||||
}
|
||||
elseif($currentMethod == 'tablecontents')
|
||||
{
|
||||
$treeMenu[$module->id] .= 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}'");
|
||||
$class = common::hasPriv('doc', 'updateOrder') ? 'sortDoc' : '';
|
||||
$treeMenu[$module->id] .= 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}'");
|
||||
$treeMenu[$module->id] .= '</div>';
|
||||
}
|
||||
|
||||
$treeMenu[$module->id] .= '</li>';
|
||||
@@ -2511,22 +2534,25 @@ EOT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($currentMethod == 'tablecontents')
|
||||
$li = "<div class='tree-group'><span class='module-name'><a class='sort-module' title='{$module->name}'>" . $module->name . '</a></span>';
|
||||
if($currentMethod == 'tablecontents' and common::hasPriv('tree', 'updateOrder'))
|
||||
{
|
||||
$li = "<a title='{$module->name}'>" . $module->name . '</a>';
|
||||
$li .= "<div class='tree-actions'>";
|
||||
$li .= html::a('javascript:;', "<i class='icon icon-move sortModule'></i>", '', "title='{$this->lang->doc->updateOrder}' class='sortModule'");
|
||||
$li .= '</div>';
|
||||
}
|
||||
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', '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>';
|
||||
}
|
||||
$li .= '</div>';
|
||||
}
|
||||
if($treeMenu[$module->id])
|
||||
{
|
||||
|
||||
@@ -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