From 67a0272d9655441cbd40794e04e9e45219151d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=8D=8E=E4=BC=9F?= Date: Tue, 8 Mar 2022 14:41:51 +0800 Subject: [PATCH] *Story #31107. --- module/execution/control.php | 7 ------- module/execution/js/kanban.js | 34 ++++++++++++++++++++++++++++++++-- module/kanban/control.php | 21 +++++++++++++++++++++ 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 6a3f0e2e42..ec7ffd8eab 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2502,13 +2502,6 @@ class execution extends control return print(js::reload('parent')); } } - //public function deleteBug($bugID, $confirm = 'no') - //{ - // if($confirm == 'no') - // { - // return print(); - // } - //} /** * Manage products. diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index 891a18a29e..87157ae846 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -969,6 +969,35 @@ function changeCardColType(cardID, fromColID, toColID, fromLaneID, toLaneID, car modalTrigger.show(); } } +/** + * Delete a card. + * + * @param string objectType + * @param int objectID + * @param int regionID + * @access public + * @return void + */ +function deleteCard(objectType, objectID, regionID) +{ + var objectLang = objectType + 'Lang'; + var result = confirm(window[objectLang].confirmDelete) ? true : false; + + if(!result) return false; + if(!objectID) return false; + + var url = createLink('kanban', 'deleteObjectCard', 'objectType=' + objectType + '&objectID=' + objectID + '®ionID=' + regionID); + return $.ajax( + { + method: 'post', + dataType: 'json', + url: url, + success: function(data) + { + updateRegion(regionID, data[regionID]); + } + }); +} /** * Close modal and update kanban data. @@ -1070,7 +1099,7 @@ function createStoryMenu(options) if(priv.canBatchCreateTask && showAction) 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.canDeleteStory) items.push({label: storyLang.delete, icon: 'trash', url: createLink('story','delete','storyID=' + story.id, '', '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; } @@ -1090,7 +1119,7 @@ function createTaskMenu(options) if(priv.canActivateTask && (task.$col.type == 'developed' || task.$col.type == 'canceled' || task.$col.type == 'closed')) items.push({label: executionLang.activate, icon: 'magic', url: createLink('task', 'activate', 'taskID=' + task.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); if(priv.canCreateTask) items.push({label: taskLang.copy, icon: 'copy', url: createLink('task', 'create', 'executionID=' + executionID + '&storyID=' + '0' + '&moduleID=' + '0' + '&taskID=' + task.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); if(priv.canCancelTask && (task.$col.type == 'wait' || task.$col.type == 'developing' || task.$col.type == 'pause')) items.push({label: taskLang.cancel, icon: 'cancel', url: createLink('task', 'cancel', 'taskID=' + task.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); - if(priv.canDeleteTask) items.push({label: taskLang.delete, icon: 'trash', url: createLink('task', 'delete', 'executionID=' + executionID + '&bugID=' + task.id, '', 'false'), attrs: {'target': 'hiddenwin'}}); + if(priv.canDeleteTask) items.push({label: taskLang.delete, icon: 'trash', onClick: function(){deleteCard('task', task.id, task.$lane.region)}}); return items; } @@ -1111,6 +1140,7 @@ function createBugMenu(options) if(priv.canToStoryBug && (bug.$col.type != 'closed')) items.push({label: bugLang.toStory, icon: 'lightbulb', url: createLink('story', 'create', 'product=' + productID + '&branch=' + '0' + '&module=' + '0' + '&story=' + '0' + '&execution=' + '0' + '&bugID=' + bug.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); if(priv.canActivateBug && (bug.$col.type == 'fixed') || bug.$col.type == 'testing' || bug.$col.type == 'tested' || bug.$col.type == 'closed') items.push({label: bugLang.activate, icon: 'magic', url: createLink('bug', 'activate', 'bugID=' + bug.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); if(priv.canDeleteBug) items.push({label: bugLang.delete, icon: 'trash', url: createLink('bug', 'delete', 'bugID=' + bug.id, '', 'false'), attrs: {'target': 'hiddenwin'}}); + if(priv.canDeleteBug) items.push({label: bugLang.delete, icon: 'trash', onClick: function(){deleteCard('bug', bug.id, bug.$lane.region)}}); return items; } diff --git a/module/kanban/control.php b/module/kanban/control.php index b5b36d6dff..81f51cc468 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -933,6 +933,27 @@ class kanban extends control return print(json_encode($kanbanGroup)); } + /** + * Delete a card. + * + * @param string $objectType story|task|bug + * @param int $objectID + * @param int $regionID + * @access public + * @return void + */ + public function deleteObjectCard($objectType, $objectID, $regionID) + { + $table = 'TABLE_' . strtoupper($objectType); + $this->loadModel($objectType)->delete(constant($table), $objectID); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + $kanbanID = $this->dao->select('kanban')->from(TABLE_KANBANREGION)->where('id')->eq($regionID)->fetch('kanban'); + + $kanbanGroup = $this->kanban->getRDKanban($kanbanID); + return print(json_encode($kanbanGroup)); + } + /** * View a card. *