* Adjust for execution create.

This commit is contained in:
wangyidong
2023-09-12 15:31:06 +08:00
parent b069701b1e
commit 89ed463b6c
3 changed files with 34 additions and 16 deletions
-3
View File
@@ -958,9 +958,7 @@ class execution extends control
$executionID = $this->execution->create($execution, isset($_POST['teamMembers']) ? $_POST['teamMembers'] : array());
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->execution->updateProducts($executionID, zget($_POST, 'products', array()), zget($_POST, 'plans', array()), zget($_POST, 'branch', array(0)));
$this->loadModel('action')->create($this->objectType, $executionID, 'opened', '', $execution->hasProduct ? implode(',', $_POST['products']) : '');
$this->loadModel('programplan')->computeProgress($executionID, 'create');
if(!empty($projectID) and strpos(',kanban,agileplus,waterfallplus,', ",$project->model,") !== false and $execution->type == 'kanban')
{
$execution = $this->execution->fetchByID($executionID);
@@ -981,7 +979,6 @@ class execution extends control
$this->view->title = $this->app->tab == 'execution' ? $this->lang->execution->createExec : $this->lang->execution->create;
$this->view->gobackLink = (isset($output['from']) and $output['from'] == 'global') ? $this->createLink('execution', 'all') : '';
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->allProducts = array_filter($this->executionZen->getAllProductsForCreate($project));
$this->view->allProjects = $this->project->getPairsByModel('all', 'noclosed,multiple');
$this->view->multiBranchProducts = $this->loadModel('product')->getMultiBranchPairs();
+16 -12
View File
@@ -229,12 +229,14 @@ class executionModel extends model
/**
* Create a execution.
*
* @param object $execution
* @param array $postMembers
* @access public
* @return bool|int
* @return int|false
*/
public function create(object $execution, array $postMembers)
public function create(object $execution, array $postMembers): int|false
{
$this->dao->insert(TABLE_EXECUTION)->data($execution)
$this->dao->insert(TABLE_EXECUTION)->data($execution, 'products,plans,branch')
->autoCheck('begin,end')
->batchcheck($this->config->execution->create->requiredFields, 'notempty')
->checkIF(!empty($execution->name), 'name', 'unique', "`type` in ('sprint','stage', 'kanban') and `project` = " . (int)$execution->project . " and `deleted` = '0'")
@@ -274,7 +276,9 @@ class executionModel extends model
$this->loadModel('personnel')->updateWhitelist(explode(',', $execution->whitelist), 'execution', $executionID);
if($execution->acl != 'open') $this->updateUserView($executionID);
if(!dao::isError()) $this->loadModel('score')->create('program', 'createguide', $executionID);
$this->updateProducts($executionID, $execution);
$this->loadModel('programplan')->computeProgress($executionID, 'create');
$this->loadModel('score')->create('program', 'createguide', $executionID);
return $executionID;
}
@@ -2326,16 +2330,17 @@ class executionModel extends model
* 更新执行关联的产品信息。
* Update products of a execution.
*
* @param int $executionID
* @param array $products
* @param array $plans
* @param array $branches
* @param int $executionID
* @param object|array $postData
* @access public
* @return bool
*/
public function updateProducts(int $executionID, array $products= array(), array $plans = array(), array $branches = array()): bool
public function updateProducts(int $executionID, object|array $postData): bool
{
$this->loadModel('user');
$products = array_filter(zget($postData, 'products', array()));
$branches = zget($postData, 'branch', array(0));
$plans = zget($postData, 'plans', array());
$oldProducts = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($executionID)->fetchGroup('product', 'branch');
$this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->eq($executionID)->exec();
$members = array_keys($this->getTeamMembers($executionID));
@@ -2348,11 +2353,10 @@ class executionModel extends model
$existedProducts = array();
foreach($products as $i => $productID)
{
if(empty($productID)) continue;
if(!isset($existedProducts[$productID])) $existedProducts[$productID] = array();
$oldPlan = 0;
$branch = isset($branches[$i]) ? (array) $branches[$i] : array();
$branch = isset($branches[$i]) ? $branches[$i] : array();
foreach($branch as $branchID)
{
if(isset($existedProducts[$productID][$branchID])) continue;
@@ -4781,7 +4785,7 @@ class executionModel extends model
if($executionID)
{
$this->update($executionID);
$this->updateProducts($executionID, (array)$updateProductsData);
$this->updateProducts($executionID, $updateProductsData);
}
$_POST = $postData;
+18 -1
View File
@@ -902,7 +902,7 @@ class executionZen extends execution
->join('whitelist', ',')
->setDefault('type', $type)
->stripTags(implode(',', $editorFields), $this->config->allowedTags)
->remove('products, workDays, delta, branch, uid, plans, teams, teamMembers, contactListMenu, heightType')
->remove('workDays, delta, uid, teams, teamMembers, contactListMenu, heightType')
->get();
if(!empty($execution->parent) && ($execution->project == $execution->parent)) $execution->hasProduct = $project->hasProduct;
@@ -1892,6 +1892,13 @@ class executionZen extends execution
return true;;
}
/**
* 修正错误提示语言。
* Correct error lang.
*
* @access protected
* @return void
*/
protected function correctErrorLang(): void
{
$this->lang->execution->team = $this->lang->execution->teamName;
@@ -2084,6 +2091,16 @@ class executionZen extends execution
return $linkedObjects;
}
/**
* 获取创建执行后的跳转地址。
* Get location after create.
*
* @param int $projectID
* @param int $executionID
* @param string $model
* @access protected
* @return string
*/
protected function getAfterCreateLocation(int $projectID, int $executionID, string $model = ''): string
{
if($this->app->tab == 'doc') return $this->createLink('doc', 'projectSpace', "objectID=$executionID");