From c300f8b87b3cde829beaa97b02054fb90e4857e4 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Wed, 9 Apr 2025 07:29:40 +0000 Subject: [PATCH] * [task#140912,done,2h] finish task. --- module/task/control.php | 16 +++++++++++++++- module/task/lang/de.php | 3 ++- module/task/lang/en.php | 3 ++- module/task/lang/fr.php | 3 ++- module/task/lang/zh-cn.php | 3 ++- module/task/lang/zh-tw.php | 3 ++- module/task/model.php | 2 +- module/task/ui/view.html.php | 6 ++++++ 8 files changed, 32 insertions(+), 7 deletions(-) diff --git a/module/task/control.php b/module/task/control.php index baf84dccf9..2db77e96fd 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -978,8 +978,22 @@ class task extends control public function delete(int $executionID, int $taskID, string $from = '') { $task = $this->task->getByID($taskID); - if($task->isParent) return $this->send(array('result' => 'fail', 'message' => $this->lang->task->cannotDeleteParent)); + /* 如果是父任务,先删除所有子任务 */ + if($task->isParent) + { + $childIdList = $this->task->getAllChildId($taskID); + $childTasks = $this->task->getByIdList($childIdList); + foreach($childTasks as $childID => $childTask) + { + if(strpos(",{$childTask->path},", ",$taskID,") === false) continue; + $this->task->delete(TABLE_TASK, $childID); + if($childTask->fromBug != 0) $this->dao->update(TABLE_BUG)->set('toTask')->eq(0)->where('id')->eq($childTask->fromBug)->exec(); + if($childTask->story) $this->loadModel('story')->setStage($childTask->story); + } + } + + /* 删除当前任务 */ $this->task->delete(TABLE_TASK, $taskID); if($task->parent > 0) { diff --git a/module/task/lang/de.php b/module/task/lang/de.php index 5711c857eb..a42a37c1a9 100644 --- a/module/task/lang/de.php +++ b/module/task/lang/de.php @@ -50,6 +50,7 @@ $lang->task->fromBugID = 'From Bug ID'; $lang->task->case = 'Fall'; $lang->task->process = 'Process Task'; $lang->task->confirmStoryChange = "Storyäanderung bestätigen"; +$lang->task->confirmDeleteParent = 'Das Löschen einer übergeordneten Aufgabe löscht auch alle untergeordneten Aufgaben. Möchten Sie diese Aufgabe wirklich löschen?'; $lang->task->storyChange = "Story Changed"; $lang->task->progress = 'Fortschritt'; $lang->task->progressAB = 'Fortschritt'; @@ -317,7 +318,7 @@ $lang->task->error->left = 'Bitte geben Sie die verbleibenden Stund $lang->task->error->work = '"Bemerkung" muss kleiner als %d Zeichen sein.'; $lang->task->error->teamMember = 'Team members must be at least 2 people'; $lang->task->error->teamCantOperate = 'Please activate the closed, suspended, and canceled tasks before setting the team.'; -$lang->task->error->skipClose = 'Aufgabe: %s ist nicht “Erledigt” oder “Abgebrochen”. Möchten Sie die Aufgabe jetzt schließen?'; +$lang->task->error->skipClose = 'Aufgabe: %s ist nicht "Erledigt" oder "Abgebrochen". Möchten Sie die Aufgabe jetzt schließen?'; $lang->task->error->closeParent = 'Task: %s is the Parent Task, which is automatically closed after all subtasks under the Parent Task are closed and cannot be closed manually.'; $lang->task->error->consumed = 'Aufgabe: %s Hour must be more than 0. Ignore changes to this Task.'; $lang->task->error->assignedTo = 'Mehere Tasks können nicht zugewisen werden, da die Benutzer nicht teil des Teams sind.'; diff --git a/module/task/lang/en.php b/module/task/lang/en.php index b3a39fcfb7..dedd54f463 100755 --- a/module/task/lang/en.php +++ b/module/task/lang/en.php @@ -50,6 +50,7 @@ $lang->task->fromBugID = 'From Bug ID'; $lang->task->case = 'Linked Case'; $lang->task->process = 'Process Task'; $lang->task->confirmStoryChange = "Confirm Change"; +$lang->task->confirmDeleteParent = 'Deleting a parent task will also delete all its child tasks. Are you sure you want to delete this task?'; $lang->task->storyChange = "Story Changed"; $lang->task->progress = 'Progress'; $lang->task->progressAB = 'Progress'; @@ -317,7 +318,7 @@ $lang->task->error->left = 'Please enter "Hours Left"'; $lang->task->error->work = '"Comment" must be < %d characters.'; $lang->task->error->teamMember = 'Team members must be at least 2 people'; $lang->task->error->teamCantOperate = 'Please activate the closed, suspended, and canceled tasks before setting the team.'; -$lang->task->error->skipClose = 'Task: %s is not “Finished” or “Cancelled”. Do you want to close it?'; +$lang->task->error->skipClose = 'Task: %s is not "Finished" or "Cancelled". Do you want to close it?'; $lang->task->error->closeParent = 'Task: %s is the Parent Task, which is automatically closed after all subtasks under the Parent Task are closed and cannot be closed manually.'; $lang->task->error->consumed = 'Task: %s hour must be < 0. Ignore changes to this task.'; $lang->task->error->assignedTo = 'Multi-user task in the current status cannot be assigned to a member who is not in the task team.'; diff --git a/module/task/lang/fr.php b/module/task/lang/fr.php index 797142f585..d03532614a 100644 --- a/module/task/lang/fr.php +++ b/module/task/lang/fr.php @@ -50,6 +50,7 @@ $lang->task->fromBugID = 'From Bug ID'; $lang->task->case = 'Associée CasTest'; $lang->task->process = 'Process Task'; $lang->task->confirmStoryChange = "Confirmer Changement"; +$lang->task->confirmDeleteParent = 'La suppression d\'une tâche parent supprimera également toutes ses tâches enfants. Êtes-vous sûr de vouloir supprimer cette tâche ?'; $lang->task->storyChange = "Story Changée"; $lang->task->progress = 'Progression'; $lang->task->progressAB = 'Progression'; @@ -317,7 +318,7 @@ $lang->task->error->left = 'Entrez les "Heures Restantes"'; $lang->task->error->work = '"Commentaire" doit être < %d caractères.'; $lang->task->error->teamMember = 'Team members must be at least 2 people'; $lang->task->error->teamCantOperate = 'Please activate the closed, suspended, and canceled tasks before setting the team.'; -$lang->task->error->skipClose = 'Tâche: %s non “Finie” ou “Annulée”. Voulez-vous la fermer malgré tout ?'; +$lang->task->error->skipClose = 'Tâche: %s non "Finie" ou "Annulée". Voulez-vous la fermer malgré tout ?'; $lang->task->error->closeParent = 'Task: %s is the Parent Task, which is automatically closed after all subtasks under the Parent Task are closed and cannot be closed manually.'; $lang->task->error->consumed = 'Tâche: %s heures doivent être < 0. Ignorer changements de cette tâche.'; $lang->task->error->assignedTo = "Tâche Multi-user dans le statut courant ne peut pas être assignée à un membre qui ne fait pas partie de l'équipe."; diff --git a/module/task/lang/zh-cn.php b/module/task/lang/zh-cn.php index c7fa3599a4..8297004f8f 100755 --- a/module/task/lang/zh-cn.php +++ b/module/task/lang/zh-cn.php @@ -50,6 +50,7 @@ $lang->task->fromBugID = '来源Bug编号'; $lang->task->case = '相关用例'; $lang->task->process = '处理任务'; $lang->task->confirmStoryChange = "确认{$lang->SRCommon}变动"; +$lang->task->confirmDeleteParent = '删除父任务将同时删除其所有子任务,您确定要删除这个任务吗?'; $lang->task->storyChange = "{$lang->SRCommon}变更"; $lang->task->progress = '进度'; $lang->task->progressAB = '进度'; @@ -317,7 +318,7 @@ $lang->task->error->left = '请填写"剩余"'; $lang->task->error->work = '"备注"必须小于%d个字符'; $lang->task->error->teamMember = '团队成员必须大于1人'; $lang->task->error->teamCantOperate = '已关闭、已暂停、已取消的任务请激活后再维护团队。'; -$lang->task->error->skipClose = '任务:%s 不是“已完成”或“已取消”状态,确定要关闭吗?'; +$lang->task->error->skipClose = '任务:%s 不是"已完成"或"已取消"状态,确定要关闭吗?'; $lang->task->error->closeParent = '任务:%s 是父任务,父任务在所有子任务关闭后会自动关闭,无法手动关闭。'; $lang->task->error->consumed = '任务:%s工时不能小于0,忽略该任务工时的改动'; $lang->task->error->assignedTo = '当前状态的多人任务不能指派给任务团队外的成员。'; diff --git a/module/task/lang/zh-tw.php b/module/task/lang/zh-tw.php index 5657e6ad45..e2a9e9693d 100644 --- a/module/task/lang/zh-tw.php +++ b/module/task/lang/zh-tw.php @@ -222,6 +222,7 @@ $lang->task->noTask = '暫時沒有任務。'; $lang->task->createDenied = '你不能在該項目添加任務'; $lang->task->cannotDeleteParent = '不能刪除父任務。'; $lang->task->addChildTask = '因該任務已經產生消耗,為保證數據一致性,我們會幫您創建一條同名子任務記錄該消耗。'; +$lang->task->confirmDeleteParent = '刪除父任務將同時刪除其所有子任務,您確定要刪除這個任務嗎?'; $lang->task->error = new stdclass(); $lang->task->error->totalNumber = '"總計消耗"必須為數字'; @@ -234,7 +235,7 @@ $lang->task->error->consumedSmall = '"總計消耗"必須大於之前消耗' $lang->task->error->consumedThisTime = '請填寫"工時"'; $lang->task->error->left = '請填寫"剩餘"'; $lang->task->error->work = '"備註"必須小於%d個字元'; -$lang->task->error->skipClose = '任務:%s 不是“已完成”或“已取消”狀態,確定要關閉嗎?'; +$lang->task->error->skipClose = '任務:%s 不是"已完成"或"已取消"狀態,確定要關閉嗎?'; $lang->task->error->consumed = '任務:%s工時不能小於0,忽略該任務工時的改動'; $lang->task->error->assignedTo = '當前狀態的多人任務不能指派給任務團隊外的成員。'; $lang->task->error->consumedEmpty = '"本次消耗"不能為0'; diff --git a/module/task/model.php b/module/task/model.php index 26539e1aa3..aebfab0534 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -2396,7 +2396,7 @@ class taskModel extends model if($action == 'totask') return true; /* 父任务只能编辑、创建子任务和指派。 Parent task only can edit task, create children and assign to somebody. */ - if((!empty($task->isParent)) && !in_array($action, array('edit', 'batchcreate', 'cancel', 'assignto', 'pause', 'close', 'restart', 'confirmstorychange'))) return false; + if((!empty($task->isParent)) && !in_array($action, array('edit', 'batchcreate', 'cancel', 'assignto', 'pause', 'close', 'restart', 'confirmstorychange', 'delete'))) return false; /* 子任务、多人任务、已取消已关闭的任务不能创建子任务。Multi task and child task and canceled/closed task cannot create children. */ if($action == 'batchcreate' && (!empty($task->team) || !empty($task->mode) || !empty($task->rawParent) || in_array($task->status, array('closed', 'cancel')))) return false; diff --git a/module/task/ui/view.html.php b/module/task/ui/view.html.php index f969c02cad..940a16c482 100644 --- a/module/task/ui/view.html.php +++ b/module/task/ui/view.html.php @@ -76,6 +76,12 @@ foreach($actions as $key => $action) $actions[$key]['data-size'] = 'lg'; } if(isset($actions[$key]['url'])) $actions[$key]['url'] = str_replace(array('{rawStory}', '{module}', '{parent}', '{execution}'), array($task->story, $task->module, $task->parent, $task->execution), $action['url']); + + // 如果是删除按钮且是父任务,修改提示语 + if(isset($action['url']) && strpos($action['url'], 'delete') !== false && $task->isParent) + { + $actions[$key]['data-confirm'] = array('message' => $lang->task->confirmDeleteParent, 'icon' => 'icon-exclamation-sign', 'iconClass' => 'warning-pale rounded-full icon-2x'); + } } /* 初始化主栏内容。Init sections in main column. */