From ad78d2688067d76250025046c23bd9178e4e17e4 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Wed, 20 Dec 2023 09:47:46 +0800 Subject: [PATCH] * kanban: refactor getSpaceById(). --- module/kanban/control.php | 2 +- module/kanban/model.php | 46 +++-------------------- module/kanban/test/model/getspacebyid.php | 38 +++++++++++++++---- 3 files changed, 37 insertions(+), 49 deletions(-) diff --git a/module/kanban/control.php b/module/kanban/control.php index 8442df57c7..1eb02f1f76 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -373,7 +373,7 @@ class kanban extends control $this->view->regions = $regions; $this->view->kanbanList = $this->kanban->getKanbanData($kanbanID, $regionID == 'all' ? '' : array($regionID)); $this->view->regionID = $regionID; - $this->view->pageToolbar = $this->kanban->getHeaderActions($kanban); + $this->view->pageToolbar = $this->kanban->getPageToolBar($kanban); $this->display(); } diff --git a/module/kanban/model.php b/module/kanban/model.php index f3cb8eb22d..f107ae3353 100755 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -2874,13 +2874,14 @@ class kanbanModel extends model } /** - * Get kanban headerActions. + * 获取看板右上角的工具栏。 + * Get kanban pageToolBar. * * @param object $kanban * @access public - * @return void + * @return string */ - public function getHeaderActions($kanban) + public function getPageToolBar(object $kanban) { $actions = ''; $actions .= " {$this->lang->kanban->fullScreen}"; @@ -3027,42 +3028,6 @@ class kanbanModel extends model $this->dao->update(TABLE_KANBANCARD)->set('`color`')->eq('#' . $color)->where('id')->eq($cardID)->exec(); } - /** - * Reset order of lane. - * - * @param int $executionID - * @param int $type - * @param int $groupBy - * @access public - * @return void - */ - public function resetLaneOrder($executionID, $type, $groupBy) - { - $lanes = $this->dao->select('id,extra')->from(TABLE_KANBANLANE) - ->where('execution')->eq($executionID) - ->andWhere('type')->eq($type) - ->andWhere('groupBy')->eq($groupBy) - ->orderBy('extra_asc') - ->fetchPairs(); - - $laneOrder = 5; - $noExtra = 0; - - foreach($lanes as $laneID => $extra) - { - if(!$extra) - { - $noExtra = $laneID; - continue; - } - - $this->dao->update(TABLE_KANBANLANE)->set('order')->eq($laneOrder)->where('id')->eq($laneID)->exec(); - $laneOrder += 5; - } - - if($noExtra) $this->dao->update(TABLE_KANBANLANE)->set('order')->eq($laneOrder)->where('id')->eq($noExtra)->exec(); - } - /** * 归档看板列。 * Archive a column. @@ -3254,13 +3219,14 @@ class kanbanModel extends model } /** + * 获取看板空间。 * Get space by id. * * @param int $spaceID * @access public * @return object */ - public function getSpaceById($spaceID): object + public function getSpaceById(int $spaceID) { $space = $this->dao->findById($spaceID)->from(TABLE_KANBANSPACE)->fetch(); if($space) $space = $this->loadModel('file')->replaceImgURL($space, 'desc'); diff --git a/module/kanban/test/model/getspacebyid.php b/module/kanban/test/model/getspacebyid.php index 28cb3dc8ef..78344664cd 100755 --- a/module/kanban/test/model/getspacebyid.php +++ b/module/kanban/test/model/getspacebyid.php @@ -4,18 +4,40 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/kanban.class.php'; su('admin'); +zdTable('kanbanspace')->gen(5); + /** title=测试 kanbanModel->getSpaceById(); +timeout=0 cid=1 -pid=1 -测试查询空间1信息 >> 协作空间1,cooperation,po15,active -测试查询空间2信息 >> 私有空间2,private,po16,active -测试查询空间3信息 >> 公共空间3,public,po17,active -测试查询空间4信息 >> 协作空间4,cooperation,po18,active -测试查询空间5信息 >> 私有空间5,private,po19,active -测试查询不存在的空间信息 >> 0 +- 测试查询空间1信息 + - 属性name @协作空间1 + - 属性type @cooperation + - 属性owner @po15 + - 属性status @active +- 测试查询空间2信息 + - 属性name @私有空间2 + - 属性type @private + - 属性owner @po16 + - 属性status @active +- 测试查询空间3信息 + - 属性name @公共空间3 + - 属性type @public + - 属性owner @po17 + - 属性status @active +- 测试查询空间4信息 + - 属性name @协作空间4 + - 属性type @cooperation + - 属性owner @po18 + - 属性status @active +- 测试查询空间5信息 + - 属性name @私有空间5 + - 属性type @private + - 属性owner @po19 + - 属性status @active +- 测试查询不存在的空间信息 @0 */ $spaceIDList = array('1', '2', '3', '4', '5', '10001'); @@ -27,4 +49,4 @@ r($kanban->getSpaceByIdTest($spaceIDList[1])) && p('name,type,owner,status') && r($kanban->getSpaceByIdTest($spaceIDList[2])) && p('name,type,owner,status') && e('公共空间3,public,po17,active'); // 测试查询空间3信息 r($kanban->getSpaceByIdTest($spaceIDList[3])) && p('name,type,owner,status') && e('协作空间4,cooperation,po18,active'); // 测试查询空间4信息 r($kanban->getSpaceByIdTest($spaceIDList[4])) && p('name,type,owner,status') && e('私有空间5,private,po19,active'); // 测试查询空间5信息 -r($kanban->getSpaceByIdTest($spaceIDList[5])) && p('name,type,owner,status') && e('0'); // 测试查询不存在的空间信息 \ No newline at end of file +r($kanban->getSpaceByIdTest($spaceIDList[5])) && p('') && e('0'); // 测试查询不存在的空间信息 \ No newline at end of file