diff --git a/module/execution/control.php b/module/execution/control.php index ca1e33e419..19303a9938 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -982,9 +982,7 @@ class execution extends control $showBranch = false; if($execution->hasProduct) { - if(count($products) > 1) $productOption[0] = $this->lang->product->all; - foreach($products as $productData) $productOption[$productData->id] = $productData->name; - + list($productOption, $branchOption, $showBranch) = $this->executionZen->buildProductSwitcher($productID, $products); unset($this->config->bug->search['fields']['product']); unset($this->config->bug->search['params']['product']); if($project->model != 'scrum') @@ -993,19 +991,6 @@ class execution extends control unset($this->config->bug->search['params']['plan']); } - $product = $this->product->getById((int)$productID); - if($product and $product->type != 'normal') - { - /* Display of branch label. */ - $showBranch = $this->loadModel('branch')->showBranch($productID); - - /* Display status of branch. */ - $branches = $this->branch->getList($productID, $executionID, 'all'); - foreach($branches as $branchInfo) - { - $branchOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - } - } } /* Load pager and get bugs, user. */ @@ -1076,6 +1061,7 @@ class execution extends control $this->view->orderBy = $orderBy; $this->view->users = $users; $this->view->productID = $productID; + $this->view->product = $this->product->getByID((int) $productID); $this->view->project = $project; $this->view->branchID = empty($this->view->build->branch) ? $branch : $this->view->build->branch; $this->view->memberPairs = $memberPairs; @@ -1127,7 +1113,7 @@ class execution extends control $this->session->set('caseList', $uri, 'execution'); $this->session->set('bugList', $uri, 'execution'); - $products = $this->product->getProducts($executionID, 'all', '', false); + $products = $this->product->getProducts($executionID); if(count($products) == 1) $productID = key($products); $execution = $this->execution->getByID($executionID); @@ -1136,20 +1122,7 @@ class execution extends control $showBranch = false; if($execution->hasProduct) { - $productOption = array(0 => $this->lang->product->all) + $products; - $product = $this->product->getById((int)$productID); - if($product and $product->type != 'normal') - { - /* Display of branch label. */ - $showBranch = $this->loadModel('branch')->showBranch($productID); - - /* Display status of branch. */ - $branches = $this->branch->getList($productID, $executionID, 'all'); - foreach($branches as $branchInfo) - { - $branchOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - } - } + list($productOption, $branchOption, $showBranch) = $this->executionZen->buildProductSwitcher($productID, $products); } /* Load pager. */ @@ -1185,6 +1158,7 @@ class execution extends control $this->view->title = $this->lang->execution->testcase; $this->view->executionID = $executionID; $this->view->productID = $productID; + $this->view->product = $this->product->getByID((int) $productID); $this->view->cases = $cases; $this->view->orderBy = $orderBy; $this->view->pager = $pager; diff --git a/module/execution/ui/bug.html.php b/module/execution/ui/bug.html.php index 8e9d2f68a0..d7c9b02264 100644 --- a/module/execution/ui/bug.html.php +++ b/module/execution/ui/bug.html.php @@ -15,7 +15,7 @@ $productDropdown = ''; if($execution->hasProduct) { $productDropdown = productMenu( - set::title($productOption[$productID]), + set::title($product ? $product->name : $productOption[$productID]), set::items($productOption), set::activeKey($productID), set::link(helper::createLink('execution', 'bug', "executionID={$execution->id}&productID=%s")), diff --git a/module/execution/ui/testcase.html.php b/module/execution/ui/testcase.html.php index 7ecb68038b..97f4c54c37 100644 --- a/module/execution/ui/testcase.html.php +++ b/module/execution/ui/testcase.html.php @@ -15,7 +15,7 @@ $productDropdown = ''; if($execution->hasProduct) { $productDropdown = productMenu( - set::title($productOption[$productID]), + set::title($product ? $product->name : $productOption[$productID]), set::items($productOption), set::activeKey($productID), set::link(helper::createLink('execution', 'testcase', "executionID={$execution->id}&productID=%s")), diff --git a/module/execution/zen.php b/module/execution/zen.php index 40e1f915e8..66c0ed1a59 100644 --- a/module/execution/zen.php +++ b/module/execution/zen.php @@ -51,5 +51,46 @@ class executionZen extends execution return array_values($buildList); } -} + /** + * 构建产品下拉选择数据。 + * Build product drop-down select data. + * + * @param int $productID + * @param object[] $products + * @access protected + * @return array + */ + protected function buildProductSwitcher(int $productID, array $products) + { + $showBranch = false; + $productOption = array(); + $programIdList = array(); + if(count($products) > 1) $productOption[0] = $this->lang->product->all; + foreach($products as $productData) $programIdList[$productData->program] = $productData->program; + $programPairs = $this->loadModel('program')->getPairsByList($programIdList); + $linePairs = $this->loadModel('product')->getLinePairs($programIdList); + + foreach($products as $productData) + { + $programName = isset($programPairs[$productData->program]) ? $programPairs[$productData->program] . ' / ' : ''; + $lineName = isset($linePairs[$productData->line]) ? $linePairs[$productData->line] . ' / ' : ''; + $productOption[$productData->id] = $programName . $lineName . $productData->name; + } + + $product = $this->product->getById((int)$productID); + if($product and $product->type != 'normal') + { + /* Display of branch label. */ + $showBranch = $this->loadModel('branch')->showBranch($productID); + + /* Display status of branch. */ + $branches = $this->branch->getList($productID, $executionID, 'all'); + foreach($branches as $branchInfo) + { + $branchOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + } + } + return array($productOption, $branchOption, $showBranch); + } +} diff --git a/module/product/model.php b/module/product/model.php index 8f8addbc73..af8cfa1363 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -1270,15 +1270,15 @@ class productModel extends model * 获取项目集下的产品线。 * Get product line pairs by program. * - * @param int $programID + * @param int|array $programID * @access public * @return string[] */ - public function getLinePairs(int $programID = 0): array + public function getLinePairs(int|array $programIdList = 0): array { return $this->dao->select('id,name')->from(TABLE_MODULE) ->where('type')->eq('line') - ->beginIF($programID)->andWhere('root')->eq($programID)->fi() + ->beginIF($programIdList)->andWhere('root')->in($programIdList)->fi() ->andWhere('deleted')->eq(0) ->fetchPairs('id', 'name'); }