* Modify the product drop-down menu.

This commit is contained in:
tianshujie
2023-06-09 10:53:12 +08:00
parent e5a2443b26
commit c4addd484b
5 changed files with 52 additions and 37 deletions
+5 -31
View File
@@ -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;
+1 -1
View File
@@ -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")),
+1 -1
View File
@@ -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")),
+42 -1
View File
@@ -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);
}
}
+3 -3
View File
@@ -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');
}