From 9f7eecf9c6b6fcbb64f0557bb0ce6139827ff6d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Fri, 17 Dec 2021 15:25:59 +0800 Subject: [PATCH] * Finish task #46164. --- module/execution/js/kanban.js | 74 ++++++++++++++++++++++++--- module/execution/view/kanban.html.php | 3 +- module/kanban/control.php | 28 ++++++++++ module/kanban/model.php | 2 +- 4 files changed, 97 insertions(+), 10 deletions(-) diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index 4e36f55965..6806b46d68 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -453,14 +453,33 @@ if(!window.kanbanDropRules) { story: { - blacklog: true, - ready: ['blacklog', 'dev-doing'], - 'dev-doing': ['dev-done'], - 'dev-done': ['test-doing'], - 'test-doing': ['test-done'], - 'test-done': ['accepted'], - 'accepted': ['published'], - 'published': false, + backlog: true, + ready: ['backlog', 'doing'], + 'doing': ['developed'], + 'developed': ['doing', 'testing'], + 'testing': ['tested'], + 'tested': ['verified'], + 'verified': ['released'], + 'released': false, + }, + bug: + { + 'unconfirmed': ['confirmed'], + 'confirmed': ['fixing'], + 'fixing': ['fixed'], + 'fixed': ['testing'], + 'testing': ['tested'], + 'tested': ['closed'], + 'closed': ['fixing'], + }, + task: + { + 'wait': ['developing', 'developed', 'canceled', 'closed'], + 'developing': ['developed', 'pause'], + 'developed': ['canceled', 'closed'], + 'pause': ['developing'], + 'canceled': ['developing'], + 'closed': ['developing'], } } } @@ -511,6 +530,7 @@ function changeCardColType(card, fromColType, toColType, kanbanID) var objectID = card.id; var showIframe = false; + /* Task lane. */ if(kanbanID == 'task') { if(toColType == 'developed') @@ -560,6 +580,44 @@ function changeCardColType(card, fromColType, toColType, kanbanID) } } + /* Bug lane. */ + if(kanbanID == 'bug') + { + if(toColType == 'confirmed') + { + if(fromColType == 'unconfirmed' && priv.canConfirmBug) + { + var link = createLink('bug', 'confirmBug', 'bugID=' + objectID, '', true); + showIframe = true; + } + } + } + + /* Story lane. */ + if(kanbanID == 'story') + { + if(toColType == 'ready' || toColType == 'backlog') + { + var colID = card.$col.columnID; + var link = createLink('kanban', 'ajaxMoveCard', 'cardID=' + objectID + '&colID=' + colID + '&toColType=' + toColType + '&execitionID=' + executionID + '&browseType=' + browseType + '&groupBy=' + groupBy); + $.get(link, function(data) + { + if(data) + { + kanbanGroup = $.parseJSON(data); + if(groupBy == 'default') + { + updateKanban('story', kanbanGroup.story); + } + else + { + updateKanban(browseType, kanbanGroup[groupBy]); + } + } + }) + } + } + if(showIframe) { var modalTrigger = new $.zui.ModalTrigger({type: 'iframe', width: '80%', url: link}); diff --git a/module/execution/view/kanban.html.php b/module/execution/view/kanban.html.php index 13c0e6b116..e31c0fef02 100644 --- a/module/execution/view/kanban.html.php +++ b/module/execution/view/kanban.html.php @@ -154,7 +154,8 @@ js::set('priv', 'canCancelTask' => common::hasPriv('task', 'cancel'), 'canCloseTask' => common::hasPriv('task', 'close'), 'canActivateTask' => common::hasPriv('task', 'activate'), - 'canStartTask' => common::hasPriv('task', 'start') + 'canStartTask' => common::hasPriv('task', 'start'), + 'canConfirmBug' => common::hasPriv('bug', 'confirm') ) ); ?> diff --git a/module/kanban/control.php b/module/kanban/control.php index 65b9b7a5e4..fdb8d18a3a 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -712,6 +712,34 @@ class kanban extends control echo true; } + /** + * Ajax move card. + * + * @param int $cardID + * @param int $fromColID + * @param string $toColType + * @param int $executionID + * @param string $browseType + * @param string $browseType + * @access public + * @return void + */ + public function ajaxMoveCard($cardID, $fromColID, $toColType = 'ready', $executionID, $browseType, $groupBy) + { + $fromColumn = $this->dao->select('*')->from(TABLE_KANBANCOLUMN)->where('id')->eq($fromColID)->fetch(); + $toColumn = $this->dao->select('*')->from(TABLE_KANBANCOLUMN)->where('type')->eq($toColType)->andWhere('lane')->eq($fromColumn->lane)->fetch(); + + $fromCards = str_replace(",$cardID,", ',', $fromColumn->cards); + $fromCards = $fromCards == ',' ? '' : $fromCards; + $toCards = ",$cardID," . ltrim($toColumn->cards, ','); + + $this->dao->update(TABLE_KANBANCOLUMN)->set('cards')->eq($fromCards)->where('id')->eq($fromColumn->id)->exec(); + $this->dao->update(TABLE_KANBANCOLUMN)->set('cards')->eq($toCards)->where('id')->eq($toColumn->id)->exec(); + + $kanbanGroup = $this->kanban->getExecutionKanban($executionID, $browseType, $groupBy); + die(json_encode($kanbanGroup)); + } + /** * Change the order through the lane move up and down. * diff --git a/module/kanban/model.php b/module/kanban/model.php index 68801de276..2d123c66df 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -1405,7 +1405,7 @@ class kanbanModel extends model { $cardPairs['backlog'] = empty($cardPairs['backlog']) ? ",$storyID," : ",$storyID" . $cardPairs['backlog']; } - elseif($story->stage == $stage and strpos($cardPairs[$colType], ",$storyID,") === false) + elseif($story->stage == $stage and strpos($cardPairs[$colType], ",$storyID,") === false and $colType != 'backlog') { $cardPairs[$colType] = empty($cardPairs[$colType]) ? ",$storyID," : ",$storyID" . $cardPairs[$colType]; }