From 6327b37eae84deb9a1bb4084df7049111c12fd56 Mon Sep 17 00:00:00 2001 From: zhangzilong Date: Wed, 9 Mar 2022 10:41:46 +0800 Subject: [PATCH] * Code for task #49888. --- module/bug/js/create.js | 2 +- module/task/control.php | 45 +++++++++++++++----------------- module/task/js/create.js | 21 +++++++++++++++ module/task/model.php | 2 +- module/task/view/create.html.php | 10 +++++-- 5 files changed, 52 insertions(+), 28 deletions(-) diff --git a/module/bug/js/create.js b/module/bug/js/create.js index ee36f4b1d5..2ef4daab45 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -67,7 +67,7 @@ function setLane(regionID) laneLink = createLink('kanban', 'ajaxGetLanes', 'regionID=' + regionID + '&type=bug&field=lane'); $.get(laneLink, function(lane) { - if(!lane) lane = ""; $('#lane').replaceWith(lane); $("#lane" + "_chosen").remove(); $("#lane").next('.picker').remove(); diff --git a/module/task/control.php b/module/task/control.php index e3897f7cad..da5e3954fe 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -86,30 +86,19 @@ class task extends control $execution = $this->execution->getById($executionID); $taskLink = $this->createLink('execution', 'browse', "executionID=$executionID&tab=task"); + $this->loadModel('kanban'); if($execution->type == 'kanban') { - $this->loadModel('kanban'); + $regionPairs = $this->kanban->getRegionPairs($execution->id, 0, 'execution'); + $regionID = isset($output['regionID']) ? $output['regionID'] : key($regionPairs); + $lanePairs = $this->kanban->getLanePairsByRegion($regionID, 'task'); + $laneID = isset($output['laneID']) ? $output['laneID'] : key($lanePairs); - $cardPositions = $this->kanban->getCardPositions($executionID, 'task', 'wait'); - - $kanbanLanePairs = array(); - if($output) - { - $lane = $this->kanban->getLaneByID($output['laneID']); - $kanbanLanePairs = $this->kanban->getLanePairsByRegion($lane->region, 'task'); - } - else - { - foreach($cardPositions as $cardPosition) $kanbanLanePairs[$cardPosition->laneID] = $cardPosition->name . ' / ' . $cardPosition->laneName; - } - - if($this->post->kanbanLane) - { - $output['laneID'] = $this->post->kanbanLane; - $output['columnID'] =$cardPositions[$this->post->kanbanLane]->columnID; - } - - $this->view->kanbanLanePairs = $kanbanLanePairs; + $this->view->executionType = $execution->type; + $this->view->regionID = $regionID; + $this->view->laneID = $laneID; + $this->view->regionPairs = $regionPairs; + $this->view->lanePairs = $lanePairs; } /* Set menu. */ @@ -155,10 +144,18 @@ 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'); + $laneID = isset($output['laneID']) ? $output['laneID'] : 0; + if(isset($_POST['lane'])) $laneID = $_POST['lane']; + + $columnID = isset($output['columnID']) ? $output['columnID'] : 0; + if(!empty($laneID)) + { + $columnIDByLaneID = $this->kanban->getColumnIDByLaneID($laneID, 'wait'); + $columnID = empty($columnIDByLaneID) ? $columnID : $columnIDByLaneID; + } + if(!empty($laneID) and !empty($columnID)) $this->kanban->addKanbanCell($kanbanID, $laneID, $columnID, 'task', $taskID); + if(empty($laneID) or empty($columnID)) $this->kanban->updateLane($kanbanID, 'task'); if($todoID > 0) { diff --git a/module/task/js/create.js b/module/task/js/create.js index 691e4817e5..a57b05ef15 100644 --- a/module/task/js/create.js +++ b/module/task/js/create.js @@ -270,6 +270,27 @@ function loadModuleRelated() setStories(moduleID, executionID); } +/** + * Set lane. + * + * @param int $regionID + * @access public + * @return void + */ +function setLane(regionID) +{ + console.log(regionID); + laneLink = createLink('kanban', 'ajaxGetLanes', 'regionID=' + regionID + '&type=task&field=lane'); + $.get(laneLink, function(lane) + { + if(!lane) lane = ""; + $('#lane').replaceWith(lane); + $("#lane" + "_chosen").remove(); + $("#lane").next('.picker').remove(); + $("#lane").chosen(); + }); +} + /* Get select of stories.*/ function setStories(moduleID, executionID) { diff --git a/module/task/model.php b/module/task/model.php index 8ce70b8948..d02a80f40b 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -64,7 +64,7 @@ class taskModel extends model ->cleanINT('execution,story,module') ->stripTags($this->config->task->editor->create['id'], $this->config->allowedTags) ->join('mailto', ',') - ->remove('after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate,sync,otherLane,region,kanbanLane') + ->remove('after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate,sync,otherLane,region,lane') ->add('version', 1) ->get(); diff --git a/module/task/view/create.html.php b/module/task/view/create.html.php index f8adfe04f6..b9e19c65dd 100644 --- a/module/task/view/create.html.php +++ b/module/task/view/create.html.php @@ -139,11 +139,17 @@ - + + + kanbancard->region;?> + +
+ + kanbancard->lane;?> -
+