From 6035a7f700dfbbd22a9cbbb2fbb9b6e5dacc49eb Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 28 Oct 2021 17:24:20 +0800 Subject: [PATCH] * Add data to the Kanban lane table. --- db/update15.7.sql | 1 + db/zentao.sql | 1 + module/execution/control.php | 7 +-- module/kanban/lang/zh-cn.php | 2 + module/kanban/model.php | 90 ++++++++++++++++++++++++++++++++---- 5 files changed, 88 insertions(+), 13 deletions(-) diff --git a/db/update15.7.sql b/db/update15.7.sql index e901955fb3..6f0f50c608 100644 --- a/db/update15.7.sql +++ b/db/update15.7.sql @@ -3,6 +3,7 @@ CREATE TABLE IF NOT EXISTS `zt_kanbanlane` ( `id` int(8) NOT NULL AUTO_INCREMENT, `execution` mediumint(8) NOT NULL DEFAULT '0', `type` char(30) NOT NULL, + `extra` char(30) NOT NULL, `name` varchar(255) NOT NULL DEFAULT '', `color` char(30) NOT NULL, `order` smallint(6) NOT NULL DEFAULT '0', diff --git a/db/zentao.sql b/db/zentao.sql index 925ff437a2..91efb3fcce 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -600,6 +600,7 @@ CREATE TABLE IF NOT EXISTS `zt_kanbanlane` ( `id` int(8) NOT NULL AUTO_INCREMENT, `execution` mediumint(8) NOT NULL DEFAULT '0', `type` char(30) NOT NULL, + `extra` char(30) NOT NULL, `name` varchar(255) NOT NULL DEFAULT '', `color` char(30) NOT NULL, `order` smallint(6) NOT NULL DEFAULT '0', diff --git a/module/execution/control.php b/module/execution/control.php index f67a3d3376..0b9252c8e0 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1827,10 +1827,11 @@ class execution extends control * @param int $executionID * @param string $type * @param string $orderBy + * @param string $groupBy * @access public * @return void */ - public function kanban($executionID, $type = 'story', $orderBy = 'order_asc') + public function kanban($executionID, $type = 'story', $orderBy = 'order_asc', $groupBy = 'default') { /* Save to session. */ $uri = $this->app->getURI(true); @@ -1840,10 +1841,10 @@ class execution extends control /* Compatibility IE8. */ if(strpos($this->server->http_user_agent, 'MSIE 8.0') !== false) header("X-UA-Compatible: IE=EmulateIE7"); - $kanbanGroup = $this->loadModel('kanban')->getExecutionKanban($executionID); + $kanbanGroup = $this->loadModel('kanban')->getExecutionKanban($executionID, $type, $groupBy); if(empty($kanbanGroup)) { - $this->kanban->createLanes($executionID); + $this->kanban->createLanes($executionID, $type, $groupBy); $kanbanGroup = $this->kanban->getExecutionKanban($executionID); } diff --git a/module/kanban/lang/zh-cn.php b/module/kanban/lang/zh-cn.php index 6d17acc1c3..6510c7d83a 100644 --- a/module/kanban/lang/zh-cn.php +++ b/module/kanban/lang/zh-cn.php @@ -53,6 +53,8 @@ $lang->kanban->taskColumn['pause'] = '已暂停'; $lang->kanban->taskColumn['canceled'] = '已取消'; $lang->kanban->taskColumn['closed'] = '已关闭'; +$lang->kanban->noGroup = '无'; + $lang->kanbancolumn = new stdclass(); $lang->kanbancolumn->limit = $lang->kanban->WIPCount; diff --git a/module/kanban/model.php b/module/kanban/model.php index 0e624bc1b1..0732d3f508 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -18,15 +18,17 @@ class kanbanModel extends model * * @param int $executionID * @param string $objectType all|story|bug|task + * @param string $groupBy * @access public * @return array */ - public function getExecutionKanban($executionID, $objectType = 'all') + public function getExecutionKanban($executionID, $objectType = 'all', $groupBy = 'default') { $lanes = $this->dao->select('*')->from(TABLE_KANBANLANE) ->where('execution')->eq($executionID) ->andWhere('deleted')->eq(0) ->beginIF($objectType != 'all')->andWhere('type')->eq($objectType) + ->beginIF($groupBy != 'default')->andWhere('extra')->eq($groupBy) ->fetchAll('id'); if(empty($lanes)) return array(); @@ -116,19 +118,87 @@ class kanbanModel extends model * Add execution Kanban lanes and columns. * * @param int $executionID + * @param string $type all|story|bug|task + * @param string $groupBy default * @access public * @return void */ - public function createLanes($executionID) + public function createLanes($executionID, $type = 'all', $groupBy = 'default') { - foreach($this->config->kanban->default as $type => $lane) + if($groupBy == 'default') { - $lane->type = $type; - $lane->execution = $executionID; - $this->dao->insert(TABLE_KANBANLANE)->data($lane)->exec(); + foreach($this->config->kanban->default as $type => $lane) + { + $lane->type = $type; + $lane->execution = $executionID; + $this->dao->insert(TABLE_KANBANLANE)->data($lane)->exec(); - $laneID = $this->dao->lastInsertId(); - $this->createColumns($laneID, $type, $executionID); + $laneID = $this->dao->lastInsertId(); + $this->createColumns($laneID, $type, $executionID); + } + } + else + { + $this->loadModel($type); + + $groupList = array(); + $table = zget($this->config->objectTables, $type); + + if($groupBy == 'story' or $type == 'story') + { + $selectField = $groupBy == 'story' ? "t1.$groupBy" : "t2.$groupBy"; + $groupList = $this->dao->select($selectField)->from(TABLE_PROJECTSTORY)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id') + ->where('t1.project')->eq($executionID) + ->andWhere('t2.deleted')->eq(0) + ->orderBy($groupBy . '_desc') + ->fetchPairs(); + } + else + { + $groupList = $this->dao->select($groupBy)->from($table) + ->where('execution')->eq($executionID) + ->beginIF($type == 'task')->andWhere('parent')->ge(0)->fi() + ->andWhere('deleted')->eq(0) + ->orderBy($groupBy . '_desc') + ->fetchPairs(); + } + + $modulePairs = $this->dao->select('id,name')->from(TABLE_MODULE)->where('type')->eq($type)->andWhere('deleted')->eq('0')->fetchPairs(); + $storyPairs = $this->dao->select('id,title')->from(TABLE_STORY)->where('deleted')->eq(0)->fetchPairs(); + $assignedToPairs = $this->loadModel('user')->getPairs('noletter'); + + $laneName = ''; + $laneOrder = 5; + foreach($groupList as $groupKey) + { + if($groupKey) + { + if(strpos('module,story,assignedTo', $groupBy) !== false) + { + $laneName = zget(${$groupBy . 'Pairs'}, $groupKey); + } + else + { + $laneName = zget($this->lang->$type->{$groupBy . 'List'}, $groupKey); + } + } + else + { + $laneName = $this->lang->kanban->noGroup; + } + + $lane = new stdClass(); + $lane->execution = $executionID; + $lane->type = $type; + $lane->extra = $groupBy; + $lane->name = $laneName; + $lane->color = '#7ec5ff'; + $lane->order = $laneOrder; + + $laneOrder += 5; + $this->dao->insert(TABLE_KANBANLANE)->data($lane)->exec(); + } } } @@ -411,7 +481,7 @@ class kanbanModel extends model return dao::isError(); } - + /** * Update lane column. @@ -428,5 +498,5 @@ class kanbanModel extends model ->where('id')->eq($columnID) ->exec(); } - + }