From d6969808e98478985eadedb2eca833ef9b51e060 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Thu, 11 May 2023 15:50:15 +0800 Subject: [PATCH] * Remove the updateParentAfterSplit function that its code has been implemented in method updateParentStatus. --- module/task/config.php | 2 +- module/task/model.php | 14 ++++++-------- module/task/tao.php | 19 ------------------- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/module/task/config.php b/module/task/config.php index 5b35bda10f..8b7c5de0c8 100644 --- a/module/task/config.php +++ b/module/task/config.php @@ -110,7 +110,7 @@ $config->task->datatable->fieldList['deadline']['title'] = 'deadlineAB'; $config->task->datatable->fieldList['deadline']['fixed'] = 'no'; $config->task->datatable->fieldList['deadline']['width'] = '70'; $config->task->datatable->fieldList['deadline']['required'] = 'no'; -$config->task->datatable->fieldList['deadline']['control'] = 'date'; +$config->task->datatable->fieldList['deadline']['control'] = 'date'; $config->task->datatable->fieldList['estimate']['title'] = 'estimateAB'; $config->task->datatable->fieldList['estimate']['fixed'] = 'no'; diff --git a/module/task/model.php b/module/task/model.php index 7d1a4f4e95..c10555ab28 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -184,7 +184,7 @@ class taskModel extends model /* 拆分任务后更新其他数据。 Process other data after split task. */ $children = !empty($parentID) ? implode(',', $taskIdList) : ''; - if($parentID) $this->afterSplitTask($oldParentTask, $children); + if($parentID && $taskID) $this->afterSplitTask($oldParentTask, $children); /* 更新当前执行下的任务泳道。 Update the task lane under current execution. */ if(!isset($output['laneID']) or !isset($output['columnID'])) $this->kanban->updateLane($execution->id, 'task'); @@ -3780,22 +3780,20 @@ class taskModel extends model */ public function afterSplitTask(object $oldParentTask, string $children = ''): bool { - $parentID = (int)$oldParentTask->id; + $parentID = (int)$oldParentTask->id; + $oneOfChildren = current(explode(',', $children)); /* 当一个普通任务有消耗时,拆分子任务并更新父任务状态。 */ /* When a normal task is consumed, create the subtask and update the parent task status. */ if($oldParentTask->parent == 0 && $oldParentTask->consumed > 0) { - $taskID = $this->taskTao->splitConsumedTask($oldParentTask); - if(!$taskID) return false; - - $this->updateParentStatus($taskID); + $inheritTask = $this->taskTao->splitConsumedTask($oldParentTask); + if(!$inheritTask) return false; } + $this->updateParentStatus($oneOfChildren); $this->computeBeginAndEnd($parentID); - $this->taskTao->updateParentAfterSplit($parentID); - /* 记录父任务日志。 */ $newParentTask = $this->dao->findById($parentID)->from(TABLE_TASK)->fetch(); $changes = common::createChanges($oldParentTask, $newParentTask); $actionID = $this->action->create('task', $parentID, 'createChildren', '', trim($children, ',')); diff --git a/module/task/tao.php b/module/task/tao.php index 08017be2dd..4e870cace6 100644 --- a/module/task/tao.php +++ b/module/task/tao.php @@ -495,25 +495,6 @@ class taskTao extends taskModel return (int)$childTaskID; } - /** - * 拆分之后更新父任务的parent、lastEditedBy、lastEditedDate字段。 - * Update the parent's parent, lastEditedBy, and lastEditedDate fields after split. - * - * @param int $parentID - * @access protected - * @return bool - */ - protected function updateParentAfterSplit(int $parentID): bool - { - $task = new stdclass(); - $task->parent = '-1'; - $task->lastEditedBy = $this->app->user->account; - $task->lastEditedDate = helper::now(); - $this->dao->update(TABLE_TASK)->data($task)->where('id')->eq($parentID)->exec(); - - return !dao::isError(); - } - /** * 将任务的层级改为父子结构。 * Change the hierarchy of tasks to a parent-child structure.