This commit is contained in:
hufangzhou
2021-11-22 13:46:02 +08:00
parent 2ebe6c5dca
commit 5492d27798
4 changed files with 54 additions and 7 deletions
+24
View File
@@ -468,4 +468,28 @@ class branchModel extends model
if($branchID) $this->dao->update(TABLE_BRANCH)->set('`default`')->eq('1')->where('id')->eq($branchID)->exec();
}
/**
* Get branches of product which linked project.
*
* @param int $projectID
* @param int $productID
* @access public
* @return array
*/
public function getPairsByProjectProduct($projectID, $productID)
{
$branches = $this->dao->select('branch,t2.name')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_BRANCH)->alias('t2')->on('t1.branch=t2.id')
->where('t1.project')->eq($projectID)
->andWhere('t1.product')->eq($productID)
->andWhere('t2.deleted')->eq('0')
->fetchPairs('branch', 'name');
$projectProduct = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->andWhere('product')->eq($productID)->fetchAll('branch');
if(isset($projectProduct[BRANCH_MAIN])) $branches = array(BRANCH_MAIN => $this->lang->branch->main) + $branches;
return $branches;
}
}
+9 -1
View File
@@ -182,7 +182,7 @@ class testcase extends control
}
else
{
$moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createCaseLink'), '', $branch);
$moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createCaseLink'), array('projectID' => $projectID, 'productID' => $productID), $branch);
}
$product = $this->product->getById($productID);
@@ -880,6 +880,8 @@ class testcase extends control
* Batch edit case.
*
* @param int $productID
* @param int $branch
* @param string $type
* @access public
* @return void
*/
@@ -940,6 +942,11 @@ class testcase extends control
if($product->type != 'normal')
{
$branches = $this->loadModel('branch')->getPairs($productID);
if($this->app->tab == 'project')
{
$branches = $this->loadModel('branch')->getPairsByProjectProduct($this->session->project, $productID);
}
foreach($branches as $branchID => $branchName) $modules[$branchID] = $this->tree->getOptionMenu($productID, $viewType = 'case', 0, $branchID);
}
else
@@ -951,6 +958,7 @@ class testcase extends control
$this->view->modules = $modules;
$this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]);
$this->view->title = $product->name . $this->lang->colon . $this->lang->testcase->batchEdit;
$this->view->product = $product;
}
}
else
+3 -3
View File
@@ -72,11 +72,11 @@
if((!$productID and !$cases[$caseID]->lib) or $app->tab != 'qa')
{
$caseProductID = $cases[$caseID]->product;
$product = $products[$caseProductID];
$branches = array('' => '');
$product = isset($product) ? $product : $products[$caseProductID];
$branches = isset($branches) ? $branches : array('' => '');
if($product->type != 'normal')
{
$branches = isset($productBranches[$product->id]) ? $productBranches[$product->id] : array();
$branches = isset($productBranches[$product->id]) ? $productBranches[$product->id] : $branches;
foreach($branches as $branchID => $branchName) $branches[$branchID] = '/' . $product->name . '/' . $branchName;
}
+18 -3
View File
@@ -387,7 +387,7 @@ class treeModel extends model
{
if($product->type != 'normal') $branches = array(BRANCH_MAIN => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($rootID, 'noempty');
}
elseif($type == 'story' and $this->app->rawModule == 'projectstory')
elseif(($type == 'story' and $this->app->rawModule == 'projectstory') or ($type == 'case' and $this->app->tab == 'project'))
{
$projectID = zget($extra, 'projectID', 0);
if($product->type != 'normal' and $projectID)
@@ -721,7 +721,22 @@ class treeModel extends model
/* If createdVersion <= 4.1, go to getTreeMenu(). */
$products = $this->loadModel('product')->getProductPairsByProject($rootID);
$branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products));
$branchGroups = $this->dao->select('t1.product as product,branch,t3.name')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id')
->leftJoin(TABLE_BRANCH)->alias('t3')->on('t1.branch=t3.id')
->where('t1.project')->eq($rootID)
->andWhere('t2.type')->ne('normal')
->andWhere('t1.product')->in(array_keys($products))
->andWhere('t2.deleted')->eq('0')
->fetchGroup('product', 'branch');
foreach($branchGroups as $productID => $branches)
{
foreach($branches as $branchID => $branchInfo)
{
$branchGroups[$productID][$branchID] = $branchID == BRANCH_MAIN ? $this->lang->branch->main : $branchInfo->name;
}
}
/* createdVersion > 4.1. */
$menu = "<ul id='modules' class='tree' data-ride='tree' data-name='tree-case'>";
@@ -751,7 +766,7 @@ class treeModel extends model
foreach($branchGroups[$id] as $branch => $branchName)
{
$treeMenu = array();
$query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = $id and type = 'case') OR (root = $id and type = 'story' and branch ='$branch'))")
$query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = $id and type = 'case' and branch = '$branch') OR (root = $id and type = 'story' and branch = '$branch'))")
->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi()
->andWhere('deleted')->eq(0)
->orderBy('grade desc, `order`, type')