* [perf story #72331] Adjust create programplan with level.

This commit is contained in:
wangyidong
2025-04-14 10:41:30 +08:00
committed by 刘刚
parent 1f3b4f7595
commit 85b977204d
7 changed files with 27 additions and 1 deletions
+1
View File
@@ -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);
+1
View File
@@ -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';
+1
View File
@@ -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';
+1
View File
@@ -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';
+1
View File
@@ -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'] = '按指派给分组';
+9 -1
View File
@@ -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);
+13
View File
@@ -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);