From d53024dba97456c21ef34b3f36f3cce4ea5131a5 Mon Sep 17 00:00:00 2001 From: liuyongkai Date: Thu, 3 Nov 2022 14:26:48 +0800 Subject: [PATCH] * Resolve feedback #1335. --- module/execution/control.php | 8 ++++---- module/execution/js/kanban.js | 2 +- module/execution/model.php | 21 ++++++++++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 090a89861d..9d65a7bbcb 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -3289,23 +3289,23 @@ class execution extends control * @access public * @return void */ - public function unlinkStory($executionID, $storyID, $confirm = 'no', $from = '') + public function unlinkStory($executionID, $storyID, $confirm = 'no', $from = '', $laneID = 0, $columnID = 0) { if($confirm == 'no') { $tip = $this->app->rawModule == 'projectstory' ? $this->lang->execution->confirmUnlinkExecutionStory : $this->lang->execution->confirmUnlinkStory; - return print(js::confirm($tip, $this->createLink('execution', 'unlinkstory', "executionID=$executionID&storyID=$storyID&confirm=yes&from=$from"))); + return print(js::confirm($tip, $this->createLink('execution', 'unlinkstory', "executionID=$executionID&storyID=$storyID&confirm=yes&from=$from&laneID=$laneID&columnID=$columnID"))); } else { $execution = $this->execution->getByID($executionID); - $this->execution->unlinkStory($executionID, $storyID); + $this->execution->unlinkStory($executionID, $storyID, $laneID, $columnID); if($execution->type == 'kanban') { /* Fix bug #29171. */ $executions = $this->dao->select('*')->from(TABLE_EXECUTION)->where('parent')->eq($execution->parent)->fetchAll('id'); $executionStories = $this->dao->select('project,story')->from(TABLE_PROJECTSTORY)->where('story')->eq($storyID)->andWhere('project')->in(array_keys($executions))->fetchAll(); - if(empty($executionStories)) $this->execution->unlinkStory($execution->parent, $storyID); + if(empty($executionStories)) $this->execution->unlinkStory($execution->parent, $storyID, $laneID, $columnID); } /* if kanban then reload and if ajax request then send result. */ diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index b93d8eb53d..9332709f9a 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -1328,7 +1328,7 @@ function createStoryMenu(options) if(priv.canCreateTask && showAction && story.status == 'active') items.push({label: executionLang.wbs, icon: 'plus', url: createLink('task', 'create', 'executionID=' + execution.id + '&storyID=' + story.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); if(priv.canBatchCreateTask && showAction && story.status == 'active') items.push({label: executionLang.batchWBS, icon: 'pluses', url: createLink('task', 'batchCreate', 'executionID=' + execution.id + '&storyID=' + story.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); if(priv.canActivateStory && story.$col.type == 'closed') items.push({label: executionLang.activate, icon: 'magic', url: createLink('story', 'activate', 'storyID=' + story.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); - if(priv.canUnlinkStory) items.push({label: executionLang.unlinkStory, icon: 'unlink', url: createLink('execution', 'unlinkStory', 'executionID=' + execution.id + '&storyID=' + story.id, '', 'false'), attrs: {target: 'hiddenwin'}}); + if(priv.canUnlinkStory) items.push({label: executionLang.unlinkStory, icon: 'unlink', url: createLink('execution', 'unlinkStory', 'executionID=' + execution.id + '&storyID=' + story.id + '&confirm=no&from=' + '&laneID=' + story.lane + '&columnID=' + story.column, '', 'false'), attrs: {target: 'hiddenwin'}}); if(priv.canDeleteStory) items.push({label: storyLang.delete, icon: 'trash', onClick: function(){deleteCard('story', story.id, story.$lane.region)}}); return items; } diff --git a/module/execution/model.php b/module/execution/model.php index e4f7f21905..a72665fc0c 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2866,7 +2866,7 @@ class executionModel extends model * @access public * @return void */ - public function unlinkStory($executionID, $storyID) + public function unlinkStory($executionID, $storyID, $laneID = 0, $columnID = 0) { $execution = $this->dao->findById($executionID)->from(TABLE_EXECUTION)->fetch(); if($execution->type == 'project') @@ -2877,6 +2877,25 @@ class executionModel extends model } $this->dao->delete()->from(TABLE_PROJECTSTORY)->where('project')->eq($executionID)->andWhere('story')->eq($storyID)->limit(1)->exec(); + /* Resolve TABLE_KANBANCELL's field cards. */ + if($execution->type == 'kanban') + { + $cell = $this->dao->select('*')->from(TABLE_KANBANCELL) + ->where('kanban')->eq($executionID) + ->andWhere('`column`')->eq($columnID) + ->andWhere('lane')->eq($laneID) + ->fetch(); + /* Resolve signal ','. */ + $cell->cards = str_replace(",$storyID", '', $cell->cards); + if(strlen($cell->cards) == 1) $cell->cards = ''; + $this->dao->update(TABLE_KANBANCELL)->data($cell) + ->where('kanban')->eq($executionID) + ->andWhere('`column`')->eq($columnID) + ->andWhere('lane')->eq($laneID) + ->exec(); + } + + $order = 1; $stories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($executionID)->orderBy('order')->fetchAll(); foreach($stories as $executionstory)