From 85b977204d5f184bd379a62d104f5de31e7829c0 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 9 Apr 2025 08:57:36 +0800 Subject: [PATCH] * [perf story #72331] Adjust create programplan with level. --- module/programplan/config/form.php | 1 + module/programplan/lang/de.php | 1 + module/programplan/lang/en.php | 1 + module/programplan/lang/fr.php | 1 + module/programplan/lang/zh-cn.php | 1 + module/programplan/model.php | 10 +++++++++- module/programplan/zen.php | 13 +++++++++++++ 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/module/programplan/config/form.php b/module/programplan/config/form.php index a8957d8f70..a61e869e24 100644 --- a/module/programplan/config/form.php +++ b/module/programplan/config/form.php @@ -24,6 +24,7 @@ $config->programplan->form->create['realEnd'] = array('label' => $lang->progr $config->programplan->form->create['milestone'] = array('label' => $lang->programplan->milestone, 'type' => 'int', 'control' => 'radioList','required' => false, 'default' => 0, 'options' => $lang->programplan->milestoneList); $config->programplan->form->create['desc'] = array('label' => $lang->programplan->desc, 'type' => 'string', 'control' => 'textarea', 'required' => false, 'default' => '', 'filter' => 'trim'); $config->programplan->form->create['output'] = array('label' => '', 'type' => 'string', 'control' => 'text', 'required' => false, 'default' => ''); +$config->programplan->form->create['level'] = array('label' => '', 'type' => 'string', 'control' => 'text', 'required' => false, 'default' => 0); $config->programplan->form->edit = array(); $config->programplan->form->edit['parent'] = array('required' => false, 'type' => 'int', 'default' => 0); diff --git a/module/programplan/lang/de.php b/module/programplan/lang/de.php index 9d0aae4b3e..3351d8aa15 100644 --- a/module/programplan/lang/de.php +++ b/module/programplan/lang/de.php @@ -143,6 +143,7 @@ $lang->programplan->error->taskDrag = 'The %s task cannot be dragged'; $lang->programplan->error->planDrag = 'The %s stage cannot be dragged'; $lang->programplan->error->notStage = $lang->executionCommon . '/Kanban cannot create a sub stage.'; $lang->programplan->error->sameType = 'Type of the stage must be as same as parent: "%s"'; +$lang->programplan->error->emptyParentName = "Contains sub stages, stage names cannot be empty."; $lang->programplan->ganttBrowseType['gantt'] = 'Group by Stage'; $lang->programplan->ganttBrowseType['assignedTo'] = 'Group by AssignedTo'; diff --git a/module/programplan/lang/en.php b/module/programplan/lang/en.php index 1a0a31a87f..e7082e99c4 100644 --- a/module/programplan/lang/en.php +++ b/module/programplan/lang/en.php @@ -143,6 +143,7 @@ $lang->programplan->error->taskDrag = 'The %s task cannot be dragged'; $lang->programplan->error->planDrag = 'The %s stage cannot be dragged'; $lang->programplan->error->notStage = $lang->executionCommon . '/Kanban cannot create a sub stage.'; $lang->programplan->error->sameType = 'Type of the stage must be as same as parent: "%s"'; +$lang->programplan->error->emptyParentName = "Contains sub stages, stage names cannot be empty."; $lang->programplan->ganttBrowseType['gantt'] = 'Group by Stage'; $lang->programplan->ganttBrowseType['assignedTo'] = 'Group by AssignedTo'; diff --git a/module/programplan/lang/fr.php b/module/programplan/lang/fr.php index 9d0aae4b3e..3351d8aa15 100644 --- a/module/programplan/lang/fr.php +++ b/module/programplan/lang/fr.php @@ -143,6 +143,7 @@ $lang->programplan->error->taskDrag = 'The %s task cannot be dragged'; $lang->programplan->error->planDrag = 'The %s stage cannot be dragged'; $lang->programplan->error->notStage = $lang->executionCommon . '/Kanban cannot create a sub stage.'; $lang->programplan->error->sameType = 'Type of the stage must be as same as parent: "%s"'; +$lang->programplan->error->emptyParentName = "Contains sub stages, stage names cannot be empty."; $lang->programplan->ganttBrowseType['gantt'] = 'Group by Stage'; $lang->programplan->ganttBrowseType['assignedTo'] = 'Group by AssignedTo'; diff --git a/module/programplan/lang/zh-cn.php b/module/programplan/lang/zh-cn.php index fc3f9147e9..88099c16bc 100644 --- a/module/programplan/lang/zh-cn.php +++ b/module/programplan/lang/zh-cn.php @@ -143,6 +143,7 @@ $lang->programplan->error->taskDrag = '%s的任务不可以拖动'; $lang->programplan->error->planDrag = '%s的阶段不可以拖动'; $lang->programplan->error->notStage = $lang->executionCommon . '/看板不支持创建子阶段'; $lang->programplan->error->sameType = '父阶段类型为"%s",阶段类型需与父阶段一致'; +$lang->programplan->error->emptyParentName = "包含子阶段,阶段名称不能为空。"; $lang->programplan->ganttBrowseType['gantt'] = '按阶段分组'; $lang->programplan->ganttBrowseType['assignedTo'] = '按指派给分组'; diff --git a/module/programplan/model.php b/module/programplan/model.php index 7a970a5301..3cbc021431 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -344,14 +344,20 @@ class programplanModel extends model $enabledPoints = array(); $parallel = 0; $firstStageID = 0; + $parents = array(); foreach($plans as $plan) { + $level = $plan->level; + unset($plan->level); + $parallel = isset($plan->parallel) ? $plan->parallel : 0; if(!empty($plan->point)) $enabledPoints = array_merge($enabledPoints, $plan->point); if($plan->id) { $stageID = $plan->id; + $parents[$level] = $stageID; unset($plan->id, $plan->type); + $changes = $this->programplanTao->updateRow($stageID, $projectID, $plan); if(dao::isError()) return false; if(empty($changes)) continue; @@ -367,9 +373,11 @@ class programplanModel extends model } else { - $stageID = $this->programplanTao->insertStage($plan, $projectID, $productID, $parentID); + if($level > 0 && isset($parents[$level - 1])) $plan->parent = $parents[$level - 1]; + $stageID = $this->programplanTao->insertStage($plan, $projectID, $productID, $level > 0 ? $plan->parent : $parentID); if(dao::isError()) return false; + $parents[$level] = $stageID; $extra = ($project && $project->hasProduct and !empty($linkProducts['products'])) ? implode(',', $linkProducts['products']) : ''; $this->action->create('execution', $stageID, 'opened', '', $extra); diff --git a/module/programplan/zen.php b/module/programplan/zen.php index c677f9a235..8b3a60aac1 100644 --- a/module/programplan/zen.php +++ b/module/programplan/zen.php @@ -44,6 +44,19 @@ class programplanZen extends programplan */ protected function buildPlansForCreate(int $projectID, int $parentID): array { + /* Check parent name is not empty when has child task. */ + $levelNames = array(); + foreach($this->post->level as $i => $level) + { + $level = (int)$level; + $levelNames[$level]['name'] = trim($this->post->name[$i]); + $levelNames[$level]['index'] = $i; + + $preLevel = $level - 1; + if($level > 0 && !empty($levelNames[$level]['name']) && empty($levelNames[$preLevel]['name'])) dao::$errors["name[" . $levelNames[$preLevel]['index'] . "]"] = $this->lang->programplan->error->emptyParentName; + } + if(dao::isError()) return false; + $project = $this->loadModel('project')->getByID($projectID); if($parentID) $parentStage = $this->programplan->getByID($parentID); if(!$parentID) $oldPlans = $this->programplan->getStage($projectID);