From ea890d584d31e0a3dcd191326475f51ef1e77aa5 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Mon, 28 Dec 2020 13:32:44 +0800 Subject: [PATCH 1/6] * Add left doc menu. --- module/common/lang/zh-cn.php | 3 ++- module/doc/control.php | 4 +++- module/doc/model.php | 24 +++++++----------------- module/product/model.php | 9 ++++++--- module/project/control.php | 2 +- module/project/model.php | 16 ++++++++-------- 6 files changed, 27 insertions(+), 31 deletions(-) diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 7469bf1b5f..6a8645c4ab 100755 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -134,11 +134,12 @@ $lang->mainNav->program = ' 项目集|pro $lang->mainNav->product = ' 产品|product|index|'; $lang->mainNav->project = ' 项目|program|prjbrowse|'; $lang->mainNav->repo = ' 代码|repo|browse|'; +$lang->mainNav->doc = ' 文档|doc|index|'; $lang->mainNav->system = ' 组织|subject|browse|'; $lang->mainNav->admin = ' 后台|admin|index|'; $lang->reporting = new stdclass(); -$lang->dividerMenu = ',admin,project,repo,'; +$lang->dividerMenu = ',admin,project,doc,'; /* Program set menu. */ $lang->program = new stdclass(); diff --git a/module/doc/control.php b/module/doc/control.php index dea7e65e23..5aaea8446f 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -27,6 +27,8 @@ class doc extends control $this->loadModel('project'); $this->from = $this->cookie->from ? $this->cookie->from : 'doc'; $this->productID = $this->cookie->product ? $this->cookie->product : '0'; + $this->projectID = $this->session->PRJ; + if(!$this->projectID) $this->lang->navGroup->doc = 'doc'; } /** @@ -60,7 +62,7 @@ class doc extends control $this->view->myDocs = $this->doc->getDocsByBrowseType(0, 'openedbyme', 0, 0, 'addedDate_desc', $pager); $this->view->statisticInfo = $this->doc->getStatisticInfo(); $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->doingProjects = $this->loadModel('project')->getExecutionsByProject($this->session->PRJ, 'undone', 5); + $this->view->doingProjects = $this->loadModel('project')->getExecutionsByProject($this->projectID, 'undone', 5); $this->display(); } diff --git a/module/doc/model.php b/module/doc/model.php index 5b7fd9a36f..147bed3fcd 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -524,13 +524,13 @@ class docModel extends model * @access public * @return void */ - public function getPrivDocs($libID = 0, $module = 0, $mode = 'normal') + public function getPrivDocs($libIdList = array(), $module = 0, $mode = 'normal') { $stmt = $this->dao->select('*')->from(TABLE_DOC) ->where('1=1') ->beginIF($mode == 'normal')->andWhere('deleted')->eq(0)->fi() ->beginIF($this->config->doc->notArticleType)->andWhere('type')->notIN($this->config->doc->notArticleType)->fi() - ->beginIF($libID)->andWhere('lib')->in($libID)->fi() + ->beginIF($libIdList)->andWhere('lib')->in($libIdList)->fi() ->beginIF(strpos($this->config->doc->custom->showLibs, 'children') === false)->andWhere('module')->in($module)->fi() ->beginIF(!empty($module) and strpos($this->config->doc->custom->showLibs, 'children') !== false)->andWhere('module')->in($module)->fi() ->query(); @@ -621,7 +621,6 @@ class docModel extends model ->add('editedDate', $now) ->add('version', 1) ->setDefault('product,project,module', 0) - ->setDefault('PRJ', $this->session->PRJ) ->stripTags($this->config->doc->editor->create['id'], $this->config->allowedTags) ->cleanInt('product,project,module,lib') ->join('groups', ',') @@ -999,7 +998,7 @@ class docModel extends model if($type == 'project') { $project = $this->loadModel('program')->getPRJByID($this->session->PRJ); - $orderBy = $project->model == 'waterfall' ? 'begin_asc,id_asc' : 'begin_desc,id_desc'; + $orderBy = (isset($project->model) and $project->model) == 'waterfall' ? 'begin_asc,id_asc' : 'begin_desc,id_desc'; } $table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT; @@ -1137,16 +1136,7 @@ class docModel extends model ->where('deleted')->eq(0) ->andWhere("$type")->in(array_keys($objectList)) ->orderBy("`order` asc, id asc") - ->fetchAll('project'); - - if($type == 'project') - { - foreach(array_keys($objectList) as $objectID) - { - $docLibs[] = $docLibs[$objectID]; - unset($docLibs[$objectID]); - } - } + ->fetchAll(); } else { @@ -1532,9 +1522,9 @@ class docModel extends model */ public function getStatisticInfo() { - $libID = 0; - if($this->session->PRJ) $libID = $this->getLibIdListByProject($this->session->PRJ); - $docIdList = $this->getPrivDocs($libID); + $libIdList = array(); + $libIdList = $this->getLibIdListByProject($this->session->PRJ); + $docIdList = $this->getPrivDocs($libIdList); $today = date('Y-m-d'); $lately = date('Y-m-d', strtotime('-3 day')); diff --git a/module/product/model.php b/module/product/model.php index 0810279b68..71240a2c9c 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -337,9 +337,9 @@ class productModel extends model ->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2') ->on('t1.product = t2.id') - ->where('t1.project')->eq($projectID) + ->where('t2.deleted')->eq(0) + ->beginIF($projectID)->andWhere('t1.project')->eq($projectID)->fi() ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() - ->andWhere('t2.deleted')->eq(0) ->orderBy('t2.order desc') ->fetchAll('id'); } @@ -354,7 +354,10 @@ class productModel extends model */ public function getProductIDByProject($projectID, $isFirst = true) { - $products = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs(); + $products = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT) + ->beginIF($projectID)->where('project')->eq($projectID)->fi() + ->fetchPairs(); + if($isFirst === false) return $products; return empty($products) ? 0 : current($products); } diff --git a/module/project/control.php b/module/project/control.php index 31892ce0c2..c998a7a4fa 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -21,7 +21,7 @@ class project extends control public function __construct($moduleName = '', $methodName = '') { parent::__construct($moduleName, $methodName); - if(!in_array($this->methodName, array('computeburn', 'ajaxgetrecentexecutions')) && $this->session->PRJ) + if(!in_array($this->methodName, array('computeburn', 'ajaxgetrecentexecutions'))) { $this->projects = $this->project->getExecutionPairs($this->session->PRJ, 'all', 'nocode'); if(!$this->projects and $this->methodName != 'index' and $this->methodName != 'create' and $this->app->getViewType() != 'mhtml') $this->locate($this->createLink('project', 'create')); diff --git a/module/project/model.php b/module/project/model.php index c03e4df448..dcba2891c3 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1005,10 +1005,11 @@ class projectModel extends model public function getExecutionIdList($projectID, $status = 'all') { return $this->dao->select('id')->from(TABLE_EXECUTION) - ->where('project')->eq($projectID) + ->where('deleted')->eq('0') + ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() ->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi() ->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi() - ->andWhere('deleted')->eq('0') + ->andWhere('type')->in('sprint,stage') ->fetchPairs('id', 'id'); } @@ -1024,22 +1025,21 @@ class projectModel extends model */ public function getExecutionsByProject($projectID, $status = 'all', $limit = 0, $pairs = false) { - if(!$projectID) return array(); - $project = $this->loadModel('program')->getPRJByID($projectID); - $orderBy = $project->model == 'waterfall' ? 'begin_asc,id_asc' : 'begin_desc,id_desc'; + $orderBy = (isset($project->model) and $project->model == 'waterfall') ? 'begin_asc,id_asc' : 'begin_desc,id_desc'; $executions = $this->dao->select('*')->from(TABLE_EXECUTION) - ->where('project')->eq((int)$projectID) + ->where('deleted')->eq('0') + ->beginIF($projectID)->andWhere('project')->eq((int)$projectID)->fi() ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi() ->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi() ->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi() - ->andWhere('deleted')->eq('0') + ->andWhere('type')->in('stage,sprint') ->orderBy($orderBy) ->beginIF($limit)->limit($limit)->fi() ->fetchAll('id'); - if($project->model == 'waterfall') + if(isset($project->model) and $project->model == 'waterfall') { $executionList = array(); $executionProducts = $this->dao->select('t1.project,t1.product')->from(TABLE_PROJECTPRODUCT)->alias('t1') From 4661eda8693ee70cf2e1a7fcc83a6d220fb81a5c Mon Sep 17 00:00:00 2001 From: hufangzhou <746775970@qq.com> Date: Mon, 28 Dec 2020 13:35:26 +0800 Subject: [PATCH 2/6] * Adjust the comment. --- module/my/control.php | 1 + module/stakeholder/model.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/module/my/control.php b/module/my/control.php index 0631f85551..afb645f1d8 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -268,6 +268,7 @@ class my extends control * My tasks * * @param string $type + * @param string $orderBy * @param int $recTotal * @param int $recPerPage * @param int $pageID diff --git a/module/stakeholder/model.php b/module/stakeholder/model.php index cee7827f57..a13f97368e 100644 --- a/module/stakeholder/model.php +++ b/module/stakeholder/model.php @@ -102,18 +102,18 @@ class stakeholderModel extends model return false; } - /** + /** * Batch create stakeholders for a project. * * @access public * @return void */ public function batchCreate() - { + { $this->loadModel('action'); $data = (array)fixer::input('post')->get(); - $members = $this->loadModel('project')->getTeamMemberPairs($this->session->PRJ); + $members = $this->loadModel('project')->getTeamMemberPairs($this->session->PRJ); $accounts = array_unique($data['accounts']); $oldJoin = $this->dao->select('`user`, createdDate')->from(TABLE_STAKEHOLDER)->where('objectID')->eq((int)$this->session->PRJ)->andWhere('objectType')->eq('project')->fetchPairs(); $this->dao->delete()->from(TABLE_STAKEHOLDER)->where('objectID')->eq((int)$this->session->PRJ)->andWhere('objectType')->eq('project')->exec(); From 5b1bccd027c8670c266fd6642629958d5d8690a7 Mon Sep 17 00:00:00 2001 From: Catouse Date: Mon, 28 Dec 2020 13:42:15 +0800 Subject: [PATCH 3/6] * fix UI of index page. --- module/index/js/index.js | 31 ++++++++++++++++++++++++++++++- www/js/zui/min.js | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/module/index/js/index.js b/module/index/js/index.js index ea37e07025..b79947b6d9 100644 --- a/module/index/js/index.js +++ b/module/index/js/index.js @@ -120,7 +120,11 @@ /* Update tab state */ tab.show = true; - lastOpenedGroup = group; + if(lastOpenedGroup !== group) + { + lastOpenedGroup = group; + updateTabUrl(group); + } } /** @@ -225,6 +229,30 @@ } } + /** + * Update browser url and title for the given tab + * @param {string} group The group of target tab to update url + * @param {string|boolean} [url] The new url of the tab + * @param {string|boolean} [title] The new title of the tab + * @return {void} + */ + function updateTabUrl(group, url, title) + { + var tab = openedTabs[group]; + if(!tab) return; + + if(url) tab.pageUrl = url; + else url = tab.pageUrl; + if(title) tab.pageTitle = title; + else title = tab.pageTitle || tab.text; + + if(lastOpenedGroup === group) + { + if(location.url !== url) history.replaceState({}, title, url); + document.title = title; + } + } + /* Bind helper methods to global object "$.tabs" */ $.tabs = window.tabs = { @@ -234,6 +262,7 @@ toggle: toggleTab, close: closeTab, reload: reloadTab, + updateUrl: updateTabUrl, openedTabs: openedTabs, groupsMap: groupsMap }; diff --git a/www/js/zui/min.js b/www/js/zui/min.js index 24f7739cd5..6abf988e02 100644 --- a/www/js/zui/min.js +++ b/www/js/zui/min.js @@ -76,4 +76,4 @@ function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"= */ function(t){function e(e){if("string"==typeof e.data){var i=e.handler,n=e.data.toLowerCase().split(" ");e.handler=function(e){if(this===e.target||!/textarea|select/i.test(e.target.nodeName)&&"text"!==e.target.type){var o="keypress"!==e.type&&t.hotkeys.specialKeys[e.which],a=String.fromCharCode(e.which).toLowerCase(),s="",r={};e.altKey&&"alt"!==o&&(s+="alt+"),e.ctrlKey&&"ctrl"!==o&&(s+="ctrl+"),e.metaKey&&!e.ctrlKey&&"meta"!==o&&(s+="meta+"),e.shiftKey&&"shift"!==o&&(s+="shift+"),o?r[s+o]=!0:(r[s+a]=!0,r[s+t.hotkeys.shiftNums[a]]=!0,"shift+"===s&&(r[t.hotkeys.shiftNums[a]]=!0));for(var l=0,h=n.length;l","/":"?","\\":"|"}},t.each(["keydown","keyup","keypress"],function(){t.event.special[this]={add:e}})}(jQuery),function(t){"use strict";function e(e,i){if(e===!1)return e;if(!e)return i;e===!0?e={add:!0,"delete":!0,edit:!0,sort:!0}:"string"==typeof e&&(e=e.split(","));var n;return Array.isArray(e)&&(n={},t.each(e,function(e,i){t.isPlainObject(i)?n[i.action]=i:n[i]=!0}),e=n),t.isPlainObject(e)&&(n={},t.each(e,function(e,i){i?n[e]=t.extend({type:e},s[e],t.isPlainObject(i)?i:null):n[e]=!1}),e=n),i?t.extend(!0,{},i,e):e}function i(e,i,n){return i=i||e.type,t(n||e.template).addClass("tree-action").attr(t.extend({"data-type":i,title:e.title||""},e.attr)).data("action",e)}var n="zui.tree",o=0,a=function(e,i){this.name=n,this.$=t(e),this.getOptions(i),this._init()},s={sort:{template:''},add:{template:''},edit:{template:''},"delete":{template:''}};a.DEFAULTS={animate:null,initialState:"normal",toggleTemplate:''},a.prototype.add=function(e,i,n,o,a){var s,r=t(e),l=this.options;if(r.is("li")?(s=r.children("ul"),s.length||(s=t("