From e8f2b39833661b23b20cb5cecf998ae2e59983d2 Mon Sep 17 00:00:00 2001 From: liyuchun Date: Mon, 8 Nov 2021 13:15:17 +0800 Subject: [PATCH 1/2] * Finish task #43929. --- module/kanban/model.php | 137 +++++++++++++++++++++++++--------------- 1 file changed, 85 insertions(+), 52 deletions(-) diff --git a/module/kanban/model.php b/module/kanban/model.php index b5dbd0465b..7d12d49779 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -486,7 +486,7 @@ class kanbanModel extends model if($groupBy == 'story') $objectPairs = $this->dao->select('id,title')->from(TABLE_STORY)->where('deleted')->eq(0)->fetchPairs(); if($groupBy == 'assignedTo') $objectPairs = $this->loadModel('user')->getPairs('noletter'); - $laneOrder = $colorIndex = 0; + $colorIndex = 0; foreach($lanes as $laneID => $lane) { @@ -506,14 +506,11 @@ class kanbanModel extends model $laneName = zget($namePairs, $lane->extra); } - $data = new stdClass(); - $data->name = $laneName; - $data->order = $laneOrder; - $laneOrder += 5; - $colorIndex += 1; - - $this->dao->update(TABLE_KANBANLANE)->data($lane)->where('id')->eq($laneID)->exec(); + $this->dao->update(TABLE_KANBANLANE)->set('name')->eq($laneName)->where('id')->eq($laneID)->exec(); $this->updateCards($lane); + + $colorIndex += 1; + if($colorIndex == count($this->config->kanban->laneColorList)) $colorIndex = 0; } } @@ -534,16 +531,68 @@ class kanbanModel extends model $lane->extra = $groupKey; $lane->name = $laneName; $lane->color = $this->config->kanban->laneColorList[$colorIndex]; - $lane->order = $laneOrder; - $laneOrder += 5; $colorIndex += 1; - if($colorIndex == count($this->config->kanban->laneColorList) + 1) $colorIndex = 0; + if($colorIndex == count($this->config->kanban->laneColorList)) $colorIndex = 0; $this->dao->insert(TABLE_KANBANLANE)->data($lane)->exec(); $laneID = $this->dao->lastInsertId(); $this->createColumns($laneID, $type, $executionID, $groupBy, $groupKey); } + + $this->resetLaneOrder($executionID, $type, $groupBy); + } + + /** + * Update lane column. + * + * @param int $columnID + * @param object $column + * @access public + * @return array + */ + public function updateLaneColumn($columnID, $column) + { + $data = fixer::input('post')->get(); + + $this->dao->update(TABLE_KANBANCOLUMN)->data($data) + ->autoCheck() + ->batchcheck($this->config->kanban->setlaneColumn->requiredFields, 'notempty') + ->where('id')->eq($columnID) + ->exec(); + + if(dao::isError()) return; + + $changes = common::createChanges($column, $data); + return $changes; + } + + /** + * Change the order through the lane move up and down. + * + * @param int $executionID + * @param string $currentType + * @param string $targetType + * @access public + * @return void + */ + public function updateLaneOrder($executionID, $currentType, $targetType) + { + $orderList = $this->dao->select('id,type,`order`')->from(TABLE_KANBANLANE) + ->where('execution')->eq($executionID) + ->andWhere('type')->in(array($currentType, $targetType)) + ->andWhere('groupby')->eq('') + ->fetchAll('type'); + + $this->dao->update(TABLE_KANBANLANE)->set('`order`')->eq($orderList[$targetType]->order) + ->where('id')->eq($orderList[$currentType]->id) + ->andWhere('groupby')->eq('') + ->exec(); + + $this->dao->update(TABLE_KANBANLANE)->set('`order`')->eq($orderList[$currentType]->order) + ->where('id')->eq($orderList[$targetType]->id) + ->andWhere('groupby')->eq('') + ->exec(); } /** @@ -636,55 +685,39 @@ class kanbanModel extends model } /** - * Update lane column. + * Reset order of lane. * - * @param int $columnID - * @param object $column - * @access public - * @return array - */ - public function updateLaneColumn($columnID, $column) - { - $data = fixer::input('post')->get(); - - $this->dao->update(TABLE_KANBANCOLUMN)->data($data) - ->autoCheck() - ->batchcheck($this->config->kanban->setlaneColumn->requiredFields, 'notempty') - ->where('id')->eq($columnID) - ->exec(); - - if(dao::isError()) return; - - $changes = common::createChanges($column, $data); - return $changes; - } - - /** - * Change the order through the lane move up and down. - * - * @param int $executionID - * @param string $currentType - * @param string $targetType + * @param int $executionID + * @param int $type + * @param int $groupBy * @access public * @return void */ - public function updateLaneOrder($executionID, $currentType, $targetType) + public function resetLaneOrder($executionID, $type, $groupBy) { - $orderList = $this->dao->select('id,type,`order`')->from(TABLE_KANBANLANE) + $lanes = $this->dao->select('id,extra')->from(TABLE_KANBANLANE) ->where('execution')->eq($executionID) - ->andWhere('type')->in(array($currentType, $targetType)) - ->andWhere('groupby')->eq('') - ->fetchAll('type'); + ->andWhere('type')->eq($type) + ->andWhere('groupBy')->eq($groupBy) + ->orderBy('extra_asc') + ->fetchPairs(); - $this->dao->update(TABLE_KANBANLANE)->set('`order`')->eq($orderList[$targetType]->order) - ->where('id')->eq($orderList[$currentType]->id) - ->andWhere('groupby')->eq('') - ->exec(); + $laneOrder = 5; + $emptyLaneID = 0; - $this->dao->update(TABLE_KANBANLANE)->set('`order`')->eq($orderList[$currentType]->order) - ->where('id')->eq($orderList[$targetType]->id) - ->andWhere('groupby')->eq('') - ->exec(); + foreach($lanes as $laneID => $extra) + { + if(!$extra) + { + $emptyLaneID = $laneID; + continue; + } + + $this->dao->update(TABLE_KANBANLANE)->set('order')->eq($laneOrder)->where('id')->eq($laneID)->exec(); + $laneOrder += 5; + } + + if($emptyLaneID) $this->dao->update(TABLE_KANBANLANE)->set('order')->eq($laneOrder)->where('id')->eq($emptyLaneID)->exec(); } /** From 743f03c2cf30d388ae0417eb46b7bcdca9303042 Mon Sep 17 00:00:00 2001 From: liyuchun Date: Mon, 8 Nov 2021 13:35:49 +0800 Subject: [PATCH 2/2] * Finish task #43929. --- module/kanban/model.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module/kanban/model.php b/module/kanban/model.php index 7d12d49779..919e542c62 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -702,14 +702,14 @@ class kanbanModel extends model ->orderBy('extra_asc') ->fetchPairs(); - $laneOrder = 5; - $emptyLaneID = 0; + $laneOrder = 5; + $noExtra = 0; foreach($lanes as $laneID => $extra) { if(!$extra) { - $emptyLaneID = $laneID; + $noExtra = $laneID; continue; } @@ -717,7 +717,7 @@ class kanbanModel extends model $laneOrder += 5; } - if($emptyLaneID) $this->dao->update(TABLE_KANBANLANE)->set('order')->eq($laneOrder)->where('id')->eq($emptyLaneID)->exec(); + if($noExtra) $this->dao->update(TABLE_KANBANLANE)->set('order')->eq($laneOrder)->where('id')->eq($noExtra)->exec(); } /**