From e6500c082842108d7aedb8fdbd40bc92de35750a Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 10 May 2023 20:11:00 +0800 Subject: [PATCH] * Add English comments for task-batchCreate. --- module/task/control.php | 16 +++++----- module/task/model.php | 20 ++++++------- module/task/tao.php | 18 +++++++----- module/task/zen.php | 65 ++++++++++++++++++----------------------- 4 files changed, 57 insertions(+), 62 deletions(-) diff --git a/module/task/control.php b/module/task/control.php index b29c872743..5b6b1d7274 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -114,7 +114,7 @@ class task extends control $extra = str_replace(array(',', ' '), array('&', ''), $extra); parse_str($extra, $output); - /* 判断不能访问的执行。 TODO: 提示语应改为执行。 */ + /* 判断不能访问的执行。 Judge execution without access. */ if($this->taskZen->isLimitedInExecution($executionID)) { echo js::alert($this->lang->task->createDenied); @@ -125,20 +125,21 @@ class task extends control if(!empty($_POST)) { - /* 批量创建任务。 */ + /* 批量创建任务。 Batch create tasks. */ $postData = form::data($this->config->task->form->batchCreate); $tasks = $this->taskZen->prepareTasks4BatchCreate($execution, $postData->rawdata); $taskIdList = $this->task->batchCreate($execution, $tasks, $output); if(dao::isError()) return print(js::error(dao::getError())); - /* Return task id list when call the API. */ + /* 接口调用返回任务编号列表。 Return task id list when call the API. */ if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $taskIdList)); - /* 生成链接。 TODO: 写配置项。 */ - $redirectedLink = $this->taskZen->getRedirectedLink($execution); - if(!isonlybody()) return print(js::locate($redirectedLink, 'parent')); + /* 生成跳转链接。 Generate jump link. */ + $jumpLink = $this->taskZen->getJumpLink($execution); + if(!isonlybody()) return print(js::locate($jumpLink, 'parent')); - /* If link from no head then reload. */ + /* 执行应用下或者在运营管理界面下更新看板数据。 */ + /* Update kanban data under the execution application or under the operation management interface. */ if($this->app->tab == 'execution' or $this->config->vision == 'lite') { $kanbanData = $this->taskZen->getKanbanData($execution); @@ -148,7 +149,6 @@ class task extends control return print(js::reload('parent.parent')); } - /* Set menu. */ $this->taskZen->setMenuByTab($executionID, $execution->project); $this->taskZen->buildBatchCreateForm($execution, $storyID, $moduleID, $taskID, $output); diff --git a/module/task/model.php b/module/task/model.php index cd8c96744a..ebb925f247 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -144,32 +144,32 @@ class taskModel extends model */ public function batchCreate(object $execution, array $tasks, array $output): array|false { - /* 检查必填项。 */ + /* 检查必填项。 Check required fields. */ $tasks = $this->checkRequired4BatchCreate($execution, $tasks); if(!$tasks) return false; - /* Load module and init vars. */ + /* 加载模块。 Load module. */ $this->loadModel('story'); $this->loadModel('score'); $this->loadModel('action'); - /* Judge whether the current task is a parent. */ + /* 判断创建的任务是不是由任务拆分而来。 Judge whether the created task is split from the task. */ $parentID = !empty($tasks[1]->parent) ? $tasks[1]->parent : 0; $oldParentTask = $this->dao->findById((int)$parentID)->from(TABLE_TASK)->fetch(); $taskIdList = array(); foreach($tasks as $task) { - /* 获取当前任务所属泳道并移除laneID属性。 */ + /* 获取当前任务所属泳道并移除laneID属性。 Get the current laneID and remove the laneID from task object. */ $laneID = isset($output['laneID']) ? $output['laneID'] : 0; $laneID = isset($task->laneID) ? $task->laneID : $laneID; if(isset($task->laneID)) unset($task->laneID); - /* 将数据插入到任务表中。 */ + /* 将数据插入到任务表中。 Insert the tasks. */ $taskID = $this->taskTao->doCreate($task); if(!$taskID) return false; - /* 更新任务相关信息。 */ + /* 更新任务相关对象信息。 Update the related objects' info, such as story, kanban and so on. */ if($task->story) $this->story->setStage($task->story); $columnID = isset($output['columnID']) ? $output['columnID'] : 0; $this->updateKanban4BatchCreate($taskID, $execution->id, $laneID, $columnID); @@ -178,16 +178,15 @@ class taskModel extends model $this->action->create('task', $taskID, 'Opened', ''); if(!dao::isError()) $this->score->create('task', 'create', $taskID); - /* 将taskID存入数组中。 */ $taskIdList[$taskID] = $taskID; } - if(!dao::isError()) $this->score->create('ajax', 'batchCreate'); + if(!dao::isError()) $this->score->create('ajax', 'batchCreate'); // Updating scores for the first batch creation operation. - /* 处理任务拆分的情况。 */ + /* 拆分任务后更新其他数据。 Process other data after split task. */ $childTasks = !empty($parentID) ? implode(',', $taskIdList) : ''; if($parentID) $this->afterSplitTask($oldParentTask, $childTasks); - /* 更新当前执行下的任务泳道。 */ + /* 更新当前执行下的任务泳道。 Update the task lane under current execution. */ if(!isset($output['laneID']) or !isset($output['columnID'])) $this->kanban->updateLane($execution->id, 'task'); return $taskIdList; } @@ -3820,7 +3819,6 @@ class taskModel extends model { $this->loadModel('kanban'); - /* 更新看板数据。 */ if($this->config->vision == 'lite') { $this->kanban->addKanbanCell($executionID, $laneID, $columnID, 'task', $taskID); diff --git a/module/task/tao.php b/module/task/tao.php index 33f0116695..9c645d25d5 100644 --- a/module/task/tao.php +++ b/module/task/tao.php @@ -474,21 +474,25 @@ class taskTao extends taskModel */ protected function splitConsumedTask(object $parentTask): false|int { - $clonedTask = clone $parentTask; - $clonedTask->parent = $parentTask->id; - unset($clonedTask->id); + /* 复制当前任务信息。 */ + /* Copy the current task to child task, and change the parent field value. */ + $childTask = clone $parentTask; + $childTask->parent = $parentTask->id; + unset($childTask->id); - $this->dao->insert(TABLE_TASK)->data($clonedTask)->autoCheck()->exec(); + $this->dao->insert(TABLE_TASK)->data($childTask)->autoCheck()->exec(); if(dao::isError()) return false; - $clonedTaskID = $this->dao->lastInsertID(); - $this->dao->update(TABLE_EFFORT)->set('objectID')->eq($clonedTaskID) + /* 将父任务的日志记录更新到子任务下。 */ + /* Update the logs of the parent task under the subtask. */ + $childTaskID = $this->dao->lastInsertID(); + $this->dao->update(TABLE_EFFORT)->set('objectID')->eq($childTaskID) ->where('objectID')->eq($parentTask->id) ->andWhere('objectType')->eq('task') ->exec(); if(dao::isError()) return false; - return (int)$clonedTaskID; + return (int)$childTaskID; } /** diff --git a/module/task/zen.php b/module/task/zen.php index 12afde1794..ba1dfb1938 100644 --- a/module/task/zen.php +++ b/module/task/zen.php @@ -426,7 +426,7 @@ class taskZen extends task */ protected function prepareTasks4BatchCreate(object $execution, object $formData): array|false { - /* 去除重复数据。 */ + /* 去除重复数据。 Deduplicated data. */ $tasks = $this->removeDuplicate4BatchCreate($execution, $formData); if(!$tasks) return false; @@ -444,7 +444,7 @@ class taskZen extends task $data = array(); foreach($formData->name as $i => $name) { - /* 给同上的变量赋值。 */ + /* 给同上的变量赋值。 Assign values to ditto fields. */ $story = !isset($tasks->story[$i]) || $tasks->story[$i] == 'ditto' ? $story : $tasks->story[$i]; $module = !isset($tasks->module[$i]) || $tasks->module[$i] == 'ditto' ? $module : $tasks->module[$i]; $type = !isset($tasks->type[$i]) || $tasks->type[$i] == 'ditto' ? $type : $tasks->type[$i]; @@ -452,7 +452,7 @@ class taskZen extends task $estStarted = !isset($tasks->estStarted[$i]) || isset($tasks->estStartedDitto[$i]) ? $estStarted : $tasks->estStarted[$i]; $deadline = !isset($tasks->deadline[$i]) || isset($tasks->deadlineDitto[$i]) ? $deadline : $tasks->deadline[$i]; - /* 检查任务名称为空的数据。 */ + /* 检查任务名称为空的数据。 Check the data whick task's name. */ if(empty($tasks->name[$i])) { if($this->common->checkValidRow('task', $tasks, $i)) @@ -463,9 +463,8 @@ class taskZen extends task continue; } - /* 构建任务数据。 */ $dittoFields = array('story' => $story, 'module' => $module, 'type' => $type, 'assignedTo' => $assignedTo, 'estStarted' => $estStarted, 'deadline' => $deadline); - $data[$i] = $this->constructData4BatchCreate($execution, $tasks, $i, $dittoFields, $extendFields); + $data[$i] = $this->buildData4BatchCreate($execution, $tasks, $i, $dittoFields, $extendFields); } return $data; @@ -488,7 +487,7 @@ class taskZen extends task foreach($tasks->story as $key => $storyID) { - /* 过滤事务型和任务名称为空的数据。 */ + /* 过滤事务型和任务名称为空的数据。 Filter affair type tasks and empty task name data. */ if(empty($tasks->name[$key])) continue; if($tasks->type[$key] == 'affair') continue; if($tasks->type[$key] == 'ditto' && isset($tasks->type[$key - 1]) && $tasks->type[$key - 1] == 'affair') continue; @@ -502,7 +501,7 @@ class taskZen extends task $taskNames[] = $tasks->name[$key - 1]; } - /* 判断Post传过来的任务有没有重复数据。 */ + /* 检查Post传过来的任务有没有重复数据。 Check whether the task passed by Post has duplicate data. */ $hasExistsName = in_array($tasks->name[$key], $taskNames); if($hasExistsName && in_array($storyID, $storyIdList)) { @@ -514,7 +513,6 @@ class taskZen extends task $taskNames[] = $tasks->name[$key]; } - /* 去重并赋值。 */ $querySQL = "execution={$execution->id} and story " . helper::dbIN($storyIdList); $result = $this->loadModel('common')->removeDuplicate('task', $tasks, $querySQL); return $result['data']; @@ -522,7 +520,7 @@ class taskZen extends task /** * 批量创建任务之前构造数据。 - * Construct data before batch create tasks. + * Build data before batch create tasks. * * @param object $execution * @param object $tasks @@ -532,7 +530,7 @@ class taskZen extends task * @access protected * @return object */ - protected function constructData4BatchCreate(object $execution, object $tasks, int $index, array $dittoFields, array $extendFields): object + protected function buildData4BatchCreate(object $execution, object $tasks, int $index, array $dittoFields, array $extendFields): object { extract($dittoFields); $now = helper::now(); @@ -564,7 +562,7 @@ class taskZen extends task if(strpos($this->config->task->create->requiredFields, 'deadline') !== false && empty($deadline)) $task->deadline = ''; if(isset($tasks->lanes[$index])) $task->laneID = $tasks->lanes[$index]; - /* 附加工作流字段。 */ + /* 处理工作流字段。 Process workflow fields. */ foreach($extendFields as $extendField) { $task->{$extendField->field} = $tasks->{$extendField->field}[$index]; @@ -1107,7 +1105,7 @@ class taskZen extends task */ protected function getCustomFields(object $execution, string $action): array { - /* 设置自定义字段列表。 */ + /* 设置自定义字段列表。 Set custom field list. */ $customFormField = 'custom' . ucfirst($action). 'Fields'; foreach(explode(',', $this->config->task->{$customFormField}) as $field) { @@ -1115,16 +1113,16 @@ class taskZen extends task $customFields[$field] = $this->lang->task->$field; } - /* 设置已勾选的自定义字段。 */ - $showFields = $this->config->task->custom->{$action . 'Fields'}; + /* 设置已勾选的自定义字段。 Set checked custom fields. */ + $checkedFields = $this->config->task->custom->{$action . 'Fields'}; if($execution->lifetime == 'ops' || $execution->attribute == 'request' || $execution->attribute == 'review') { unset($customFields['story']); - $showFields = str_replace(',story,', ',', ",{$showFields},"); - $showFields = trim($showFields, ','); + $checkedFields = str_replace(',story,', ',', ",{$checkedFields},"); + $checkedFields = trim($checkedFields, ','); } - return array($customFields, $showFields); + return array($customFields, $checkedFields); } /** @@ -1142,9 +1140,9 @@ class taskZen extends task protected function buildBatchCreateForm(object $execution, int $storyID, int $moduleID, int $taskID, array $output): void { /* 获取区域和泳道下拉数据,并设置区域和泳道的默认值。 */ + /* Get region and lane dropdown data and set default values for regions and lanes. */ if($execution->type == 'kanban') $this->assignKanbanRelatedVars($execution->id, $output); - /* 任务拆解。 */ if($taskID) { $task = $this->dao->findById($taskID)->from(TABLE_TASK)->fetch(); @@ -1152,13 +1150,12 @@ class taskZen extends task $this->view->parentPri = $task->pri; } - /* 获取模块下拉数据。 */ + /* 获取模块和需求下拉数据。 Get module and story dropdown data. */ $showAllModule = !empty($this->config->execution->task->allModule) ? 'allModule' : ''; $modules = $this->loadModel('tree')->getTaskOptionMenu($execution->id, 0, 0, $showAllModule); $story = $this->story->getByID($storyID); $stories = $this->story->getExecutionStoryPairs($execution->id, 0, 'all', $story ? $story->module : 0, 'short', 'active'); - /* Set Custom. */ list($customFields, $showFields) = $this->getCustomFields($execution, 'batchCreate'); $this->view->title = $execution->name . $this->lang->colon . $this->lang->task->batchCreate; @@ -1179,14 +1176,14 @@ class taskZen extends task } /** - * 获取重定向链接。 - * Get redirected link. + * 获取跳转链接。 + * Get jump link. * * @param object $execution * @access protected * @return string */ - protected function getRedirectedLink(object $execution): string + protected function getJumpLink(object $execution): string { if($this->app->tab == 'my') { @@ -1216,25 +1213,21 @@ class taskZen extends task { $this->loadModel('kanban'); - $executionLaneType = $this->session->executionLaneType ? $this->session->executionLaneType : 'all'; - $execGroupBy = $this->session->executionGroupBy ? $this->session->executionGroupBy : 'default'; - $rdSearchValue = $this->session->rdSearchValue ? $this->session->rdSearchValue : ''; - $taskSearchValue = $this->session->taskSearchValue ? $this->session->taskSearchValue : ''; + $executionLaneType = $this->session->executionLaneType ? $this->session->executionLaneType : 'all'; + $execGroupBy = $this->session->executionGroupBy ? $this->session->executionGroupBy : 'default'; + $rdSearchValue = $this->session->rdSearchValue ? $this->session->rdSearchValue : ''; + $taskSearchValue = $this->session->taskSearchValue ? $this->session->taskSearchValue : ''; - /* 处理专业研发看板。 */ + /* 处理专业研发看板。 Handling professional R&D kanban. */ if($execution->type == 'kanban') { - $kanbanData = $this->kanban->getRDKanban($execution->id, $executionLaneType, 'id_desc', 0, $execGroupBy, $rdSearchValue); - $kanbanData = json_encode($kanbanData); - - return $kanbanData; + $kanbanData = $this->kanban->getRDKanban($execution->id, $executionLaneType, 'id_desc', 0, $execGroupBy, $rdSearchValue); + return json_encode($kanbanData); } - /* 处理任务看板。 */ + /* 处理任务看板。 Handling task kanban. */ $kanbanData = $this->kanban->getExecutionKanban($execution->id, $executionLaneType, $execGroupBy, $taskSearchValue); $kanbanType = $executionLaneType == 'all' ? 'task' : key($kanbanData); - $kanbanData = json_encode($kanbanData[$kanbanType]); - - return $kanbanData; + return json_encode($kanbanData[$kanbanType]); } }