diff --git a/module/custom/control.php b/module/custom/control.php
index 6ec5899d47..56f5683645 100644
--- a/module/custom/control.php
+++ b/module/custom/control.php
@@ -460,6 +460,23 @@ class custom extends control
die(js::reload('parent.parent'));
}
+ /**
+ * Ajax set doc setting.
+ *
+ * @access public
+ * @return void
+ */
+ public function ajaxSetDoc()
+ {
+ if($this->server->request_method == 'POST')
+ {
+ $data = fixer::input('post')->join('showLibs', ',')->get();
+ if(isset($data->showLibs)) $data = $data->showLibs;
+ $this->loadModel('setting')->setItem("{$this->app->user->account}.doc.custom.showLibs", $data);
+ die(js::reload('parent.parent'));
+ }
+ }
+
/**
* Reset required.
*
diff --git a/module/doc/config.php b/module/doc/config.php
index 888bc9bfb6..980fa20661 100644
--- a/module/doc/config.php
+++ b/module/doc/config.php
@@ -16,6 +16,7 @@ $config->doc->customObjectLibs = 'files,customFiles';
$config->doc->custom = new stdclass();
$config->doc->custom->objectLibs = $config->doc->customObjectLibs;
+$config->doc->custom->showLibs = 'zero,unclosed';
$config->doc->editor = new stdclass();
$config->doc->editor->create = array('id' => 'content', 'tools' => 'fullTools');
diff --git a/module/doc/control.php b/module/doc/control.php
index f566d451e0..49a4da3b3a 100644
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -104,8 +104,6 @@ class doc extends control
$this->lang->doc->menuOrder = $this->lang->product->menuOrder;
$this->product->setMenu($this->product->getPairs(), $lib->product);
$this->lang->set('menugroup.doc', 'product');
-
- if(common::hasPriv('doc', 'create')) $this->lang->modulePageActions .= html::a(helper::createLink('doc', 'create', "libID=$libID"), " " . $this->lang->doc->create, '', "class='btn btn-primary'");
}
elseif($from == 'project')
{
@@ -113,11 +111,10 @@ class doc extends control
$this->lang->doc->menuOrder = $this->lang->project->menuOrder;
$this->project->setMenu($this->project->getPairs('nocode'), $lib->project);
$this->lang->set('menugroup.doc', 'project');
-
- if(common::hasPriv('doc', 'create')) $this->lang->modulePageActions .= html::a(helper::createLink('doc', 'create', "libID=$libID"), " " . $this->lang->doc->create, '', "class='btn btn-primary'");
}
- $menuType = (!$type && in_array($browseType, array_keys($this->lang->doc->fastMenuList))) ? $browseType : $type;
- $this->doc->setMenu($menuType, $libID, $moduleID, $productID, $projectID);
+
+ $menuType = (!$type && in_array($browseType, array_keys($this->lang->doc->fastMenuList))) ? $browseType : $type;
+ $this->doc->setMenu($menuType, $libID, $moduleID, $productID, $projectID);
$this->session->set('docList', $this->app->getURI(true));
/* Set header and position. */
diff --git a/module/doc/css/common.css b/module/doc/css/common.css
index 09bf1ad22d..32daee4258 100644
--- a/module/doc/css/common.css
+++ b/module/doc/css/common.css
@@ -19,6 +19,8 @@
.split-row > .main-col {width: 100%!important;}
}
+.side-col .cell .nav a.setting {padding:8px;}
+.side-footer{padding:8px; background:#fff;}
.col-sm-size .col-sm-5,
.col-sm-size .col-sm-7 {width: 100%;}
.col-sm-size .table .c-user,
@@ -63,8 +65,8 @@
.side-col > .cell {overflow: hidden auto; padding: 0; position: relative;}
.side-col > .cell > header {position: absolute; top: 10px; right: 10px; left: 10px;}
.side-col > .cell > header > .c-sm {padding-right: 20px; width: 60px;;}
-.side-col #docsTree {position: absolute; top: 53px; left: 0; right: 0; bottom: 0; overflow: auto; padding: 0 10px 10px;}
-.main-col .block-files > .panel-body {position: absolute; top: 45px; left: 0; right: 0; bottom: 0; overflow: auto;}
+.side-col .docsTree {position: absolute; top: 53px; left: 0; right: 0; bottom: 0; overflow: auto; padding: 0 10px 10px;}
+.main-col .block-files > .panel-body {top: 45px; left: 0; right: 0; bottom: 0; overflow: auto;}
td.c-name a{color: #0c60e1}
td.c-name a:visited{color: #082999}
diff --git a/module/doc/js/common.js b/module/doc/js/common.js
index 4404f5bdb9..b5603a84e4 100644
--- a/module/doc/js/common.js
+++ b/module/doc/js/common.js
@@ -131,9 +131,9 @@ $(document).ready(function()
};
var resizeCols = function() {
- var cellHeight = $(window).height() - $('#footer').outerHeight() - $('#header').outerHeight() - 40;
- $cols.children('.panel').height(cellHeight).css('maxHeight', cellHeight);
- $cols.find('.tab-content').height(cellHeight - $cols.find('.nav-tabs').height()).css('maxHeight', cellHeight - $cols.find('.nav-tabs').height()).css('overflow-y', 'auto');
+ var cellHeight = $(window).height() - $('#footer').outerHeight() - $('#header').outerHeight() - 42;
+ $cols.children('.panel').height(cellHeight).css('maxHeight', cellHeight).find('.panel-body').css('position', 'absolute');
+ $cols.find('.tab-content').height(cellHeight - $cols.find('.nav-tabs').height() - 35).css('maxHeight', cellHeight - $cols.find('.nav-tabs').height() - 35).css('overflow-y', 'auto');
};
$(window).on('resize', resizeCols);
diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php
index d864de3c53..e8f5bb0475 100644
--- a/module/doc/lang/en.php
+++ b/module/doc/lang/en.php
@@ -136,6 +136,10 @@ $lang->doc->fastMenuIconList['collectedbyme'] = 'icon-folder-star';
$lang->doc->customObjectLibs['files'] = 'Show File Library';
$lang->doc->customObjectLibs['customFiles'] = 'Show Custom Library';
+$lang->doc->customShowLibs = 'Library display settings';
+$lang->doc->customShowLibsList['zero'] = 'Display zero document library';
+$lang->doc->customShowLibsList['unclosed'] = 'Show only projects that are not closed.';
+
$lang->doc->confirmDelete = "Do you want to delete this document?";
$lang->doc->confirmDeleteLib = "Do you want to delete this Doc Lib?";
$lang->doc->errorEditSystemDoc = "Ssytem document library doesn't have to be changed.";
diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php
index dc5d8f1c40..e4b2885743 100644
--- a/module/doc/lang/zh-cn.php
+++ b/module/doc/lang/zh-cn.php
@@ -136,6 +136,10 @@ $lang->doc->fastMenuIconList['collectedbyme'] = 'icon-folder-star';
$lang->doc->customObjectLibs['files'] = '显示附件库';
$lang->doc->customObjectLibs['customFiles'] = '显示自定义文档库';
+$lang->doc->customShowLibs = '文档库显示设置';
+$lang->doc->customShowLibsList['zero'] = '显示零文档的库';
+$lang->doc->customShowLibsList['unclosed'] = '只显示未关闭的项目';
+
$lang->doc->confirmDelete = "您确定删除该文档吗?";
$lang->doc->confirmDeleteLib = "您确定删除该文档库吗?";
$lang->doc->errorEditSystemDoc = "系统文档库无需修改。";
diff --git a/module/doc/model.php b/module/doc/model.php
index 1e256f99d6..cd15d2f027 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -148,7 +148,14 @@ class docModel extends model
}
}
$products = $productIdList ? $this->dao->select('id,name')->from(TABLE_PRODUCT)->where('id')->in($productIdList)->fetchPairs('id', 'name') : array();
- $projects = $projectIdList ? $this->dao->select('id,name')->from(TABLE_PROJECT)->where('id')->in($projectIdList)->fetchPairs('id', 'name') : array();
+ $projects = array();
+ if($projectIdList)
+ {
+ $projects = $this->dao->select('id,name')->from(TABLE_PROJECT)
+ ->where('id')->in($projectIdList)
+ ->beginIF(strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('status')->notin('done,closed')->fi()
+ ->fetchPairs('id', 'name');
+ }
foreach($menuLibIdList as $i => $menuLibID)
{
$lib = $libs[$menuLibID];
@@ -205,6 +212,7 @@ class docModel extends model
$stmt = $this->dao->select('t1.*')->from(TABLE_DOCLIB)->alias('t1')
->leftJoin($table)->alias('t2')->on("t1.$type=t2.id")
->where("t1.$type")->ne(0)
+ ->beginIF($type == 'project' and strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi()
->andWhere('t1.deleted')->eq(0)
->orderBy("t2.order desc, t1.order, t1.id")
->query();
@@ -967,7 +975,12 @@ class docModel extends model
{
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
$fields = $type == 'product' ? "createdBy, createdDate" : "openedBy AS createdBy, openedDate AS createdDate";
- $libs = $this->dao->select("id, name, `order`, {$fields}")->from($table)->where('id')->in($idList)->orderBy('`order` desc, id desc')->page($pager, 'id')->fetchAll('id');
+ $libs = $this->dao->select("id, name, `order`, {$fields}")->from($table)
+ ->where('id')->in($idList)
+ ->beginIF($type == 'project' and strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('status')->notin('done,closed')->fi()
+ ->orderBy('`order` desc, id desc')
+ ->page($pager, 'id')
+ ->fetchAll('id');
}
else
{
@@ -1021,6 +1034,7 @@ class docModel extends model
$hasProject = $this->dao->select('DISTINCT product')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.product')->in($productIdList)
+ ->beginIF(strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi()
->andWhere('t2.deleted')->eq(0)
->fetchPairs('product', 'product');
}
@@ -1042,7 +1056,12 @@ class docModel extends model
if($hasFilesPriv) $productOrderLibs[$productID]['libs']['files'] = $this->lang->doclib->files;
}
}
- $projects = $this->dao->select('id,name,status')->from(TABLE_PROJECT)->where('id')->in(array_keys($projectLibs))->andWhere('deleted')->eq('0')->orderBy('`order`_desc')->fetchAll();
+ $projects = $this->dao->select('id,name,status')->from(TABLE_PROJECT)
+ ->where('id')->in(array_keys($projectLibs))
+ ->beginIF(strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('status')->notin('done,closed')->fi()
+ ->andWhere('deleted')->eq('0')
+ ->orderBy('`order`_desc')
+ ->fetchAll();
$projectOrderLibs = array();
foreach($projects as $project)
{
@@ -1076,10 +1095,18 @@ class docModel extends model
if($type == 'product' or $type == 'project')
{
+ $nonzeroLibs = array();
+ if(strpos($this->config->doc->custom->showLibs, 'zero') === false)
+ {
+ $nonzeroLibs = $this->dao->select('lib,count(*) as count')->from(TABLE_DOC)->where('deleted')->eq('0')->groupBy('lib')->having('count')->ne(0)->fetchPairs('lib', 'lib');
+ }
+
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
$stmt = $this->dao->select('t1.*')->from(TABLE_DOCLIB)->alias('t1')
->leftJoin($table)->alias('t2')->on("t1.$type=t2.id")
->where('t1.deleted')->eq(0)->andWhere("t1.$type")->ne(0)
+ ->beginIF($type == 'project' and strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi()
+ ->beginIF(strpos($this->config->doc->custom->showLibs, 'zero') === false)->andWhere('t1.id')->in($nonzeroLibs)->fi()
->orderBy("t2.`order` desc, t1.`order` asc, id desc")
->query();
}
@@ -1118,7 +1145,7 @@ class docModel extends model
public function getSubLibGroups($type, $idList)
{
if($type != 'product' and $type != 'project') return false;
- $libGroups = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->in($idList)->orderBy('`order`, id')->fetchGroup($type, 'id');
+ $libGroups = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->in($idList)->orderBy('`order`, id')->fetchGroup($type, 'id');
if($type == 'product')
{
if($this->config->global->flow == 'onlyStory' or $this->config->global->flow == 'onlyTest')
@@ -1130,6 +1157,7 @@ class docModel extends model
$hasProject = $this->dao->select('DISTINCT product')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.product')->in($idList)
+ ->beginIF(strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi()
->andWhere('t2.deleted')->eq(0)
->fetchPairs('product', 'product');
}
@@ -1172,6 +1200,7 @@ class docModel extends model
$hasProject = $this->dao->select('DISTINCT product, count(project) as projectCount')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.product')->eq($objectID)
+ ->beginIF(strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi()
->andWhere('t2.deleted')->eq(0)
->groupBy('product')
->fetchPairs('product', 'projectCount');
@@ -1489,6 +1518,7 @@ class docModel extends model
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t1.root=t2.project')
->leftJoin(TABLE_PROJECT)->alias('t3')->on('t1.root=t3.id')
->where('t2.product')->eq($objectID)
+ ->beginIF(strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t3.status')->notin('done,closed')->fi()
->andWhere('t1.type')->eq('project')
->andWhere('t3.deleted')->eq('0')
->fetchPairs('account', 'account');
diff --git a/module/doc/view/side.html.php b/module/doc/view/side.html.php
index 908248a0a1..c01089fd16 100644
--- a/module/doc/view/side.html.php
+++ b/module/doc/view/side.html.php
@@ -15,7 +15,7 @@ if($this->methodName != 'browse')
}
if(!isset($type)) $type = 'product';
?>
-
+
doclib->tabList as $tabValue => $tabName):?>
@@ -34,23 +34,27 @@ if(!isset($type)) $type = 'product';
- - methodName == 'objectlibs' && $type == $tabValue && $object->id == $tabMenu->id) echo "class='active'";?>>
- id]))
- {
- foreach($sideSubLibs[$tabValue][$tabMenu->id] as $subLibID => $subLibName)
- {
- if(is_numeric($subLibID) and !empty($mainLibID)) $customLibCount += 1;
- if(is_numeric($subLibID) and empty($mainLibID)) $mainLibID = $subLibID;
- }
- }
- ?>
+ id]))
+ {
+ foreach($sideSubLibs[$tabValue][$tabMenu->id] as $subLibID => $subLibName)
+ {
+ if(is_numeric($subLibID) and !empty($mainLibID)) $customLibCount += 1;
+ if(is_numeric($subLibID) and empty($mainLibID)) $mainLibID = $subLibID;
+ }
+ }
+
+ $icon = $tabValue == 'product' ? " " : " ";
+ $activeClass = ($this->methodName == 'objectlibs' && $type == $tabValue && $object->id == $tabMenu->id) ? 'active' : '';
+ $activeClass = ($this->methodName == 'browse' && isset($currentLib) && $currentLib->id == $mainLibID) ? 'active' : $activeClass;
+ ?>
+
- >
0):?>
- createLink('doc', 'objectLibs', "type=$tabValue&objectID=$tabMenu->id"), " " . $tabMenu->name, '', "class='text-ellipsis' title='{$tabMenu->name}'");?>
+ createLink('doc', 'objectLibs', "type=$tabValue&objectID=$tabMenu->id"), $icon . $tabMenu->name, '', "class='text-ellipsis' title='{$tabMenu->name}'");?>
- createLink('doc', 'browse', "libID=$mainLibID"), " " . $tabMenu->name, '', "class='text-ellipsis' title='{$tabMenu->name}'");?>
+ createLink('doc', 'browse', "libID=$mainLibID"), $icon . $tabMenu->name, '', "class='text-ellipsis' title='{$tabMenu->name}'");?>
id])):?>
@@ -109,8 +113,12 @@ if(!isset($type)) $type = 'product';
$sideLibName):?>
- - methodName == 'objectlibs' && $type == $tabValue && $object->id == $sideLibID) echo "class='active'";?>>
- createLink('doc', 'browse', "libID=$sideLibID"), " " . $sideLibName, '', "class='text-ellipsis' title='{$sideLibName}'");?>
+ methodName == 'objectlibs' && $type == $tabValue && $object->id == $sideLibID) ? 'active' : '';
+ $activeClass = ($this->methodName == 'browse' && isset($currentLib) && $currentLib->id == $sideLibID) ? 'active' : $activeClass;
+ ?>
+
- >
+ createLink('doc', 'browse', "libID=$sideLibID"), " " . $sideLibName, '', "class='text-ellipsis' title='{$sideLibName}'");?>
parent != 0) continue;?>
@@ -128,4 +136,27 @@ if(!isset($type)) $type = 'product';
+
+