From ed5cbcc2fd3f9488b184b9da070480f10a2d03d5 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 9 Jun 2023 13:27:52 +0800 Subject: [PATCH] * Optimize build product drop-down logic. --- module/execution/control.php | 8 ++++---- module/execution/zen.php | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 19303a9938..057244eb74 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -979,10 +979,10 @@ class execution extends control /* Set the product drop-down and search fields. */ $productOption = array(); $branchOption = array(); - $showBranch = false; + $showBranch = $this->loadModel('branch')->showBranch($productID); if($execution->hasProduct) { - list($productOption, $branchOption, $showBranch) = $this->executionZen->buildProductSwitcher($productID, $products); + list($productOption, $branchOption) = $this->executionZen->buildProductSwitcher($productID, $products); unset($this->config->bug->search['fields']['product']); unset($this->config->bug->search['params']['product']); if($project->model != 'scrum') @@ -1119,10 +1119,10 @@ class execution extends control $execution = $this->execution->getByID($executionID); $productOption = array(); $branchOption = array(); - $showBranch = false; + $showBranch = $this->loadModel('branch')->showBranch($productID); if($execution->hasProduct) { - list($productOption, $branchOption, $showBranch) = $this->executionZen->buildProductSwitcher($productID, $products); + list($productOption, $branchOption) = $this->executionZen->buildProductSwitcher($productID, $products); } /* Load pager. */ diff --git a/module/execution/zen.php b/module/execution/zen.php index 66c0ed1a59..a5ca3cd973 100644 --- a/module/execution/zen.php +++ b/module/execution/zen.php @@ -63,8 +63,8 @@ class executionZen extends execution */ protected function buildProductSwitcher(int $productID, array $products) { - $showBranch = false; $productOption = array(); + $branchOption = array(); $programIdList = array(); if(count($products) > 1) $productOption[0] = $this->lang->product->all; foreach($products as $productData) $programIdList[$productData->program] = $productData->program; @@ -81,9 +81,6 @@ class executionZen extends execution $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) @@ -91,6 +88,6 @@ class executionZen extends execution $branchOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); } } - return array($productOption, $branchOption, $showBranch); + return array($productOption, $branchOption); } }