From c0f638b983af295a42bc89d0edcb6bab09ed17d3 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Mon, 27 Nov 2023 16:09:29 +0800 Subject: [PATCH] * Merge 18.9 execution module. --- module/execution/control.php | 33 ++++++++++++++++++++++++++++++--- module/execution/js/task.ui.js | 2 ++ module/execution/model.php | 15 ++++++++++++++- module/execution/zen.php | 7 ++++++- 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 12b5e5ff98..e4d8a78e5e 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -368,10 +368,12 @@ class execution extends control $this->execution->setMenu($executionID); - /* Get users, products and executions.*/ + /* Get users, products, executions, project and projects.*/ $users = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution', 'nodeleted'); $products = $this->loadModel('product')->getProductPairsByProject($executionID); $executions = !empty($products) ? $this->execution->getPairsByProduct(array_keys($products)) : $executions[$executionID] = $execution->name; + $project = $this->loadModel('project')->getByID($execution->project); + !empty($products) ? $projects = $this->product->getProjectPairsByProductIDList(array_keys($products)) : $projects[$project->id] = $project->name; /* Set browseType, productID, moduleID and queryID. */ $browseType = strtolower($browseType); @@ -385,7 +387,7 @@ class execution extends control $bugs = $this->executionZen->getImportBugs($executionID, array_keys($products), $browseType, $queryID, $pager); /* Build the search form. */ - $this->executionZen->buildImportBugSearchForm($execution, $queryID, $products, $executions); + $this->executionZen->buildImportBugSearchForm($execution, $queryID, $products, $executions, $projects); /* Assign. */ $this->view->title = $executions[$executionID] . $this->lang->colon . $this->lang->execution->importBug; @@ -2819,7 +2821,8 @@ class execution extends control } $users = $this->loadModel('user')->getPairs('noletter'); - $executionStats = $this->execution->getStatData($projectID, $status == 'byproduct' ? 'all' : $status, $productID, 0, false, 'hasParentName', $orderBy); + $executionStats = $this->execution->getStatData($projectID, $status == 'byproduct' ? 'all' : $status, $productID, 0, false, 'withchild', $orderBy); + $executionStats = $this->flattenObjectArray($executionStats); foreach($executionStats as $i => $execution) { $execution->PM = zget($users, $execution->PM); @@ -2829,6 +2832,7 @@ class execution extends control $execution->totalLeft = $execution->hours->totalLeft; $execution->progress = $execution->hours->progress . '%'; $execution->name = isset($execution->title) ? $execution->title : $execution->name; + if(isset($executionStats[$execution->parent])) $execution->name = $executionStats[$execution->parent]->name . '/' . $execution->name; if($this->app->tab == 'project' and ($project->model == 'agileplus' or $project->model == 'waterfallplus')) $execution->method = zget($executionLang->typeList, $execution->type); if($this->post->exportType == 'selected') @@ -2837,6 +2841,7 @@ class execution extends control if(strpos(",$checkedItem,", ",{$execution->id},") === false) unset($executionStats[$i]); } } + if($this->config->edition != 'open') list($fields, $executionStats) = $this->loadModel('workflowfield')->appendDataFromFlow($fields, $executionStats); $this->post->set('fields', $fields); @@ -3174,4 +3179,26 @@ class execution extends control $this->display(); } + + /** + * Flatten Object Array. + * + * @param array $array + * @access public + * @return void + */ + public function flattenObjectArray(array $array = array()) + { + $result = array(); + + foreach ($array as $key => $object) { + $result[$object->id] = $object; + + if (isset($object->children) && is_array($object->children)) { + $result = array_replace($result, $this->flattenObjectArray($object->children)); + } + } + + return $result; + } } diff --git a/module/execution/js/task.ui.js b/module/execution/js/task.ui.js index 994a1d6688..27e3b1676b 100644 --- a/module/execution/js/task.ui.js +++ b/module/execution/js/task.ui.js @@ -50,6 +50,8 @@ window.setStatistics = function(element, checkedIDList) { const task = row.data; + if(task.isParent == true) return true; + if(!task.isParent) { totalEstimate += Number(task.estimate); diff --git a/module/execution/model.php b/module/execution/model.php index 1f8bb73aab..2889aa34e1 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2020,7 +2020,7 @@ class executionModel extends model ->where('deleted')->eq(0) ->andWhere('status')->notin('closed,cancel') ->andWhere('execution')->in($executionIdList) - ->orderBy('id_asc') + ->orderBy('order_asc') ->fetchGroup('execution', 'id'); $taskIdList = array(); @@ -2102,6 +2102,19 @@ class executionModel extends model return $execution; } + /** + * Get execution by build id. + * + * @param int $buildID + * @access public + * @return object + */ + public function getByBuild(int $buildID) + { + $build = $this->loadModel('build')->getById($buildID); + return $this->getById($build->execution); + } + /** * 获取执行的产品相关负责人。 * Get the default managers for a execution from it's related products. diff --git a/module/execution/zen.php b/module/execution/zen.php index 7b632f3e47..cef8e75887 100644 --- a/module/execution/zen.php +++ b/module/execution/zen.php @@ -751,10 +751,11 @@ class executionZen extends execution * @param int $queryID * @param array $products * @param array $executions + * @param array $projects * @access protected * @return void */ - protected function buildImportBugSearchForm(object $execution, int $queryID, array $products, array $executions) + protected function buildImportBugSearchForm(object $execution, int $queryID, array $products, array $executions, array $projects) { $project = $this->loadModel('project')->getByID($execution->project); @@ -790,6 +791,10 @@ class executionZen extends execution } $this->config->bug->search['params']['module']['values'] = $bugModules; + $this->config->bug->search['params']['project']['values'] = array('' => '') + $projects; + + $this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getBuildPairs($productID, 'all', 'withbranch|releasetag'); + unset($this->config->bug->search['fields']['resolvedBy']); unset($this->config->bug->search['fields']['closedBy']); unset($this->config->bug->search['fields']['status']);