From 0e5072054f426ca56ecc4506fc7043812a3a73eb Mon Sep 17 00:00:00 2001 From: tianshujie Date: Sat, 8 Jul 2023 10:29:17 +0800 Subject: [PATCH] * Refact delete task. --- module/task/config.php | 10 ++++++---- module/task/control.php | 42 ++++++++++------------------------------- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/module/task/config.php b/module/task/config.php index fc3599605f..7025a1948e 100644 --- a/module/task/config.php +++ b/module/task/config.php @@ -137,10 +137,12 @@ $config->task->actionList['create']['hint'] = $lang->task->children; $config->task->actionList['create']['text'] = $lang->task->children; $config->task->actionList['create']['url'] = helper::createLink('task', 'create', 'projctID={execution}&storyID=0&moduleID=0&taskID={id}'); -$config->task->actionList['delete']['icon'] = 'trash'; -$config->task->actionList['delete']['hint'] = $lang->task->delete; -$config->task->actionList['delete']['text'] = $lang->task->delete; -$config->task->actionList['delete']['url'] = helper::createLink('task', 'delete', 'executionID={execution}&taskID={id}'); +$config->task->actionList['delete']['icon'] = 'trash'; +$config->task->actionList['delete']['hint'] = $lang->task->delete; +$config->task->actionList['delete']['text'] = $lang->task->delete; +$config->task->actionList['delete']['url'] = helper::createLink('task', 'delete', 'executionID={execution}&taskID={id}'); +$config->task->actionList['delete']['data-confirm'] = $lang->task->confirmDelete; +$config->task->actionList['delete']['class'] = 'ajax-submit'; $config->task->actionList['view']['icon'] = 'chevron-double-up'; $config->task->actionList['view']['hint'] = $lang->task->parent; diff --git a/module/task/control.php b/module/task/control.php index 6466282108..1346f5c803 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -913,48 +913,26 @@ class task extends control * @param int $executionID * @param int $taskID * @param string $confirm yes|no - * @param string $from taskkanban * @access public * @return void */ - public function delete($executionID, $taskID, $confirm = 'no', $from = '') + public function delete($executionID, $taskID, $confirm = 'no') { $task = $this->task->getById($taskID); - if($task->parent < 0) return print(js::alert($this->lang->task->cannotDeleteParent)); + if($task->parent == 0) return $this->send(array('result' => 'fail', 'message' => $this->lang->task->cannotDeleteParent)); - if($confirm == 'no') + $this->task->delete(TABLE_TASK, $taskID); + if($task->parent > 0) { - return print(js::confirm($this->lang->task->confirmDelete, inlink('delete', "executionID=$executionID&taskID=$taskID&confirm=yes&from=$from"))); + $this->task->updateParentStatus($task->id); + $this->loadModel('action')->create('task', $task->parent, 'deleteChildrenTask', '', $taskID); } - else - { - $this->task->delete(TABLE_TASK, $taskID); - if($task->parent > 0) - { - $this->task->updateParentStatus($task->id); - $this->loadModel('action')->create('task', $task->parent, 'deleteChildrenTask', '', $taskID); - } - if($task->fromBug != 0) $this->dao->update(TABLE_BUG)->set('toTask')->eq(0)->where('id')->eq($task->fromBug)->exec(); - if($task->story) $this->loadModel('story')->setStage($task->story); + if($task->fromBug != 0) $this->dao->update(TABLE_BUG)->set('toTask')->eq(0)->where('id')->eq($task->fromBug)->exec(); + if($task->story) $this->loadModel('story')->setStage($task->story); - $this->executeHooks($taskID); + $this->executeHooks($taskID); - if(isonlybody()) return print(js::reload('parent.parent')); - if($from == 'taskkanban') - { - $executionLaneType = $this->session->executionLaneType ? $this->session->executionLaneType : 'all'; - $executionGroupBy = $this->session->executionGroupBy ? $this->session->executionGroupBy : 'default'; - $taskSearchValue = $this->session->taskSearchValue ? $this->session->taskSearchValue : ''; - $kanbanData = $this->loadModel('kanban')->getExecutionKanban($this->session->execution, $executionLaneType, $executionGroupBy, $taskSearchValue); - $kanbanType = $executionLaneType == 'all' ? 'task' : key($kanbanData); - $kanbanData = $kanbanData[$kanbanType]; - $kanbanData = json_encode($kanbanData); - return print(js::closeModal('parent', '', "parent.updateKanban(\"task\", $kanbanData)")); - } - - $locateLink = $this->session->taskList ? $this->session->taskList : $this->createLink('execution', 'task', "executionID={$task->execution}"); - return print(js::locate($locateLink, 'parent')); - } + return $this->send(array('result' => 'success', 'load' => true)); } /**