From ef66f1418ce635611bf00b2337226fe49886a33f Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 17 Jan 2022 12:23:21 +0800 Subject: [PATCH] * Filter out cards from other swimlanes when updating cards. --- module/execution/js/kanban.js | 2 +- module/execution/model.php | 10 ++++++---- module/kanban/model.php | 27 ++++++++++++++++++++------- module/task/control.php | 20 ++++++++++++-------- module/task/model.php | 10 +++++++--- module/task/view/create.html.php | 2 ++ 6 files changed, 48 insertions(+), 23 deletions(-) diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index 7cd0b16307..e68c54ab01 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -192,7 +192,7 @@ function createColumnCreateMenu(options) else if(col.type == 'wait') { if(priv.canCreateTask) items.push({label: taskLang.create, url: $.createLink('task', 'create', 'executionID=' + executionID + "&storyID=0&moduleID=0&taskID=0&todoID=0&extra=laneID=" + laneID + ",columnID=" + col.id, '', true), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); - if(priv.canBatchCreateTask) items.push({label: taskLang.batchCreate, url: $.createLink('task', 'batchcreate', 'executionID=' + executionID, '', true), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + if(priv.canBatchCreateTask) items.push({label: taskLang.batchCreate, url: $.createLink('task', 'batchcreate', 'executionID=' + executionID + "&storyID=0&moduleID=0&taskID=0&iframe=0&extra=laneID=" + laneID + ",columnID=" + col.id, '', true), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); } return items; } diff --git a/module/execution/model.php b/module/execution/model.php index 937402ee6b..8aba257beb 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3230,13 +3230,14 @@ class executionModel extends model /** * Get Kanban tasks * - * @param int $executionID - * @param string $orderBy - * @param object $pager + * @param int $executionID + * @param string $orderBy + * @param object $pager + * @param array|string $excludeTasks * @access public * @return void */ - public function getKanbanTasks($executionID, $orderBy = 'status_asc, id_desc', $pager = null) + public function getKanbanTasks($executionID, $orderBy = 'status_asc, id_desc', $pager = null, $excludeTasks = '') { $tasks = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName') ->from(TABLE_TASK)->alias('t1') @@ -3245,6 +3246,7 @@ class executionModel extends model ->where('t1.execution')->eq((int)$executionID) ->andWhere('t1.deleted')->eq(0) ->andWhere('t1.parent')->ge(0) + ->beginIF($excludeTasks)->andWhere('t1.id')->notIN($excludeTasks)->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); diff --git a/module/kanban/model.php b/module/kanban/model.php index f2cf659958..0908c3bd9c 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -1912,7 +1912,7 @@ class kanbanModel extends model } else { - $cell->cards = $cell->cards ? $cell->cards . "$cardID," : ",$cardID,"; + $cell->cards = $cell->cards ? ",$cardID" . $cell->cards : ",$cardID,"; $this->dao->update(TABLE_KANBANCELL)->set('cards')->eq($cell->cards)->where('id')->eq($cell->id)->exec(); } } @@ -2093,9 +2093,22 @@ class kanbanModel extends model */ public function refreshCards($lane) { - $laneType = $lane->type; - $executionID = $lane->execution; - $cardPairs = $this->dao->select('t2.type, t1.cards')->from(TABLE_KANBANCELL)->alias('t1') + $laneType = $lane->type; + $executionID = $lane->execution; + $otherCardList = ''; + $lanes = $this->dao->select('t2.id, t2.cards')->from(TABLE_KANBANLANE)->alias('t1') + ->leftJoin(TABLE_KANBANCELL)->alias('t2')->on('t1.id=t2.lane') + ->where('t1.deleted')->eq(0) + ->andWhere('t1.id')->ne($lane->id) + ->andWhere('t1.execution')->eq($executionID) + ->andWhere('t2.`type`')->eq($lane->type) + ->fetchPairs(); + foreach($lanes as $cardIDList) + { + if(!empty($cardIDList)) $otherCardList .= $cardIDList; + } + + $cardPairs = $this->dao->select('t2.type, t1.cards')->from(TABLE_KANBANCELL)->alias('t1') ->leftJoin(TABLE_KANBANCOLUMN)->alias('t2')->on('t1.`column` = t2.id') ->where('t1.kanban')->eq($executionID) ->andWhere('t1.lane')->eq($lane->id) @@ -2105,7 +2118,7 @@ class kanbanModel extends model if($laneType == 'story') { - $stories = $this->loadModel('story')->getExecutionStories($executionID); + $stories = $this->loadModel('story')->getExecutionStories($executionID, 0, 0, 't1.`order`_desc', 'byModule', 0, 'story', $otherCardList); foreach($stories as $storyID => $story) { foreach($this->config->kanban->storyColumnStageList as $colType => $stage) @@ -2132,7 +2145,7 @@ class kanbanModel extends model } elseif($laneType == 'bug') { - $bugs = $this->loadModel('bug')->getExecutionBugs($executionID); + $bugs = $this->loadModel('bug')->getExecutionBugs($executionID, 0, 0, '', 0, 'id_desc', $otherCardList); foreach($bugs as $bugID => $bug) { foreach($this->config->kanban->bugColumnStatusList as $colType => $status) @@ -2175,7 +2188,7 @@ class kanbanModel extends model } elseif($laneType == 'task') { - $tasks = $this->loadModel('execution')->getKanbanTasks($executionID); + $tasks = $this->loadModel('execution')->getKanbanTasks($executionID, 'status_asc, id_desc', null, $otherCardList); foreach($tasks as $taskID => $task) { foreach($this->config->kanban->taskColumnStatusList as $colType => $status) diff --git a/module/task/control.php b/module/task/control.php index 956dd1a83b..1b07f2f0d3 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -106,8 +106,6 @@ class task extends control return $this->send($response); } - if(isset($output['laneID']) and isset($output['columnID'])) $this->loadModel('kanban')->addKanbanCell($executionID, $output['laneID'], $output['columnID'], 'task', $taskID); - /* if the count of tasksID is 1 then check exists. */ if(count($tasksID) == 1) { @@ -131,6 +129,11 @@ class task extends control $this->action->create('task', $taskID, 'Opened', ''); } + $this->loadModel('kanban'); + $kanbanID = $execution->type == 'kanban' ? $executionID : $_POST['execution']; + if(isset($output['laneID']) and isset($output['columnID'])) $this->kanban->addKanbanCell($kanbanID, $output['laneID'], $output['columnID'], 'task', $taskID); + if(!isset($output['laneID']) or !isset($output['columnID'])) $this->kanban->updateLane($kanbanID, 'task'); + if($todoID > 0) { $this->dao->update(TABLE_TODO)->set('status')->eq('done')->where('id')->eq($todoID)->exec(); @@ -248,15 +251,16 @@ class task extends control /** * Batch create task. * - * @param int $executionID - * @param int $storyID - * @param int $iframe - * @param int $taskID + * @param int $executionID + * @param int $storyID + * @param int $iframe + * @param int $taskID + * @param string $extra * * @access public * @return void */ - public function batchCreate($executionID = 0, $storyID = 0, $moduleID = 0, $taskID = 0, $iframe = 0) + public function batchCreate($executionID = 0, $storyID = 0, $moduleID = 0, $taskID = 0, $iframe = 0, $extra = '') { $this->execution->getLimitedExecution(); $limitedExecutions = !empty($_SESSION['limitedExecutions']) ? $_SESSION['limitedExecutions'] : ''; @@ -295,7 +299,7 @@ class task extends control if(!empty($_POST)) { - $mails = $this->task->batchCreate($executionID); + $mails = $this->task->batchCreate($executionID, $extra); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $taskIDList = array(); diff --git a/module/task/model.php b/module/task/model.php index e1116c3b5a..2a4e287f98 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -137,8 +137,6 @@ class taskModel extends model $this->dao->insert(TABLE_TASKSPEC)->data($taskSpec)->autoCheck()->exec(); if(dao::isError()) return false; - $this->loadModel('kanban')->updateLane($executionID, 'task'); - if($this->post->story) $this->loadModel('story')->setStage($this->post->story); if($this->post->selectTestStory) { @@ -233,10 +231,11 @@ class taskModel extends model * Create a batch task. * * @param int $executionID + * @param string $extra * @access public * @return void */ - public function batchCreate($executionID) + public function batchCreate($executionID, $extra = '') { /* Load module and init vars. */ $this->loadModel('action'); @@ -247,6 +246,9 @@ class taskModel extends model $preStory = 0; $tasks = fixer::input('post')->get(); + $extra = str_replace(array(',', ' '), array('&', ''), $extra); + parse_str($extra, $output); + /* Judge whether the current task is a parent. */ $parentID = !empty($this->post->parent[0]) ? $this->post->parent[0] : 0; @@ -401,6 +403,8 @@ class taskModel extends model $this->executeHooks($taskID); + if(isset($output['laneID']) and isset($output['columnID'])) $this->loadModel('kanban')->addKanbanCell($executionID, $output['laneID'], $output['columnID'], 'task', $taskID); + $actionID = $this->action->create('task', $taskID, 'Opened', ''); if(!dao::isError()) $this->loadModel('score')->create('task', 'create', $taskID); diff --git a/module/task/view/create.html.php b/module/task/view/create.html.php index c8d56862f1..d161c2f6f0 100644 --- a/module/task/view/create.html.php +++ b/module/task/view/create.html.php @@ -35,10 +35,12 @@ ?>
+ type != 'kanban'):?> +
task->execution;?> id, "class='form-control chosen' onchange='loadAll(this.value)' required");?>
task->type;?> task->typeList, $task->type, "class='form-control chosen' onchange='setOwners(this.value)' required");?>