From b2955aa6572d720bb7d26d50ef33f97cd7b0eb6c Mon Sep 17 00:00:00 2001 From: Yagami Date: Mon, 20 Feb 2023 15:11:00 +0800 Subject: [PATCH] * Code for task #85045. --- api/v1/entries/executions.php | 2 +- module/execution/model.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api/v1/entries/executions.php b/api/v1/entries/executions.php index 03aac1de48..3fd6949a6b 100644 --- a/api/v1/entries/executions.php +++ b/api/v1/entries/executions.php @@ -80,7 +80,7 @@ class executionsEntry extends entry */ public function post($projectID = 0) { - $fields = 'project,code,name,begin,end,lifetime,desc,days'; + $fields = 'project,code,name,begin,end,lifetime,desc,days,percent,parent'; $this->batchSetPost($fields); $projectID = $this->param('project', $projectID); diff --git a/module/execution/model.php b/module/execution/model.php index be0a83044d..dd1dc9d835 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -387,6 +387,7 @@ class executionModel extends model ->setDefault('lastEditedDate', helper::now()) ->setDefault('team', $this->post->name) ->setDefault('parent', $this->post->project) + ->setIF($this->post->parent, 'parent', $this->post->parent) ->setIF($this->post->heightType == 'auto', 'displayCards', 0) ->setIF(!isset($_POST['whitelist']), 'whitelist', '') ->setIF($this->post->acl == 'open', 'whitelist', '') @@ -396,7 +397,7 @@ class executionModel extends model ->remove('products, workDays, delta, branch, uid, plans, teams, teamMembers, contactListMenu, heightType') ->get(); - if(!empty($sprint->parent)) + if(!empty($sprint->parent) and ($sprint->project == $sprint->parent)) { $project = $this->loadModel('project')->getByID($sprint->parent); $sprint->hasProduct = $project->hasProduct; @@ -459,6 +460,15 @@ class executionModel extends model if((isset($project) and $project->model != 'kanban') or empty($project)) $this->loadModel('kanban')->createExecutionLane($executionID); + /* Api create infinitus stages. */ + if(isset($sprint->parent) and ($sprint->parent != $sprint->project) and $sprint->type == 'stage') + { + $parent = $this->getByID($sprint->parent); + $grade = $parent->grade + 1; + $path = rtrim($parent->path, ',') . ",{$executionID}"; + $this->dao->update(TABLE_EXECUTION)->set('path')->eq($path)->set('grade')->eq($grade)->where('id')->eq($executionID)->exec(); + } + /* Save order. */ $this->dao->update(TABLE_EXECUTION)->set('`order`')->eq($executionID * 5)->where('id')->eq($executionID)->exec(); $this->file->updateObjectID($this->post->uid, $executionID, 'execution');