* Modify the code.

This commit is contained in:
tianshujie
2021-11-29 14:16:10 +08:00
parent f2b60bda9e
commit 96a46aa2ca
10 changed files with 57 additions and 83 deletions
+5 -4
View File
@@ -771,7 +771,7 @@ class execution extends control
$storyBugs = $this->loadModel('bug')->getStoryBugCounts($storyIdList, $executionID);
$storyCases = $this->loadModel('testcase')->getStoryCaseCounts($storyIdList);
$plans = $this->execution->getPlans($products, true, true);
$plans = $this->execution->getPlans($products, 'skipParent|withMainPlan');
$allPlans = array('' => '');
if(!empty($plans))
{
@@ -1284,7 +1284,7 @@ class execution extends control
$projectID = $copyExecution->project;
$products = $this->loadModel('product')->getProducts($copyExecutionID);
$branches = $this->project->getBranchesByProject($copyExecutionID);
$plans = $this->loadModel('productplan')->getGroupByProduct(array_keys($products), true, 'unexpired');
$plans = $this->loadModel('productplan')->getGroupByProduct(array_keys($products), 'skipParent|unexpired');
$branchGroups = $this->execution->getBranchByProduct(array_keys($products), $projectID);
$linkedBranches = array();
@@ -1501,7 +1501,7 @@ class execution extends control
$linkedBranches = array();
$linkedProducts = $this->product->getProducts($executionID);
$branches = $this->project->getBranchesByProject($executionID);
$plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), true);
$plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), 'skipParent');
$executionStories = $this->project->getStoriesByProject($executionID);
/* If the story of the product which linked the execution, you don't allow to remove the product. */
@@ -1514,6 +1514,7 @@ class execution extends control
{
$linkedBranches[$productID][$branchID] = $branchID;
$productPlans[$productID][$branchID] = isset($plans[$productID][$branchID]) ? $plans[$productID][$branchID] : array();
if($branchID != BRANCH_MAIN and isset($plans[$productID][BRANCH_MAIN])) $productPlans[$productID][$branchID] += $plans[$productID][BRANCH_MAIN];
if(!empty($executionStories[$productID][$branchID]))
{
array_push($unmodifiableProducts, $productID);
@@ -2492,7 +2493,7 @@ class execution extends control
$this->loadModel('branch');
foreach($products as $product)
{
$productModules = $this->tree->getOptionMenu($product->id, 'story', 0, array_keys(array(BRANCH_MAIN) + $branches[$product->id]));
$productModules = $this->tree->getOptionMenu($product->id, 'story', 0, $branches[$product->id]);
foreach($productModules as $branch => $branchModules)
{
foreach($branchModules as $moduleID => $moduleName) $modules[$moduleID] = ((count($products) >= 2 and $moduleID != 0) ? $product->name : '') . $moduleName;
+2 -5
View File
@@ -162,13 +162,10 @@ function loadBranches(product)
$inputgroup.addClass('has-branch').append(data);
$inputgroup.find('select:last').attr('name', 'branch[' + index + ']').attr('id', 'branch' + index).attr('onchange', "loadPlans('#products" + index + "', this.value)").chosen();
}
});
setTimeout(function()
{
var branchID = $('#branch0').val();
var branchID = $('#branch' + index).val();
loadPlans(product, branchID);
},100)
});
}
function loadPlans(product, branchID)
+5 -16
View File
@@ -1728,18 +1728,6 @@ class executionModel extends model
if($branchID != BRANCH_MAIN) $branchPairs[$branchID] = ((count($products) > 1) ? $product->name . '/' : '') . $branchGroups[$product->id][$branchID];
}
}
else
{
$productBranches = isset($branchGroups[$product->id]) ? $branchGroups[$product->id] : array(0);
if(count($products) > 1)
{
foreach($productBranches as $branchID => $branchName)
{
if($branchID !== BRANCH_MAIN) $productBranches[$branchID] = $product->name . '/' . $branchName;
}
}
$branchPairs += $productBranches;
}
}
}
@@ -3667,14 +3655,15 @@ class executionModel extends model
* Get plans by $productID.
*
* @param int|array $productID
* @param bool $skipParent
* @param string $param withMainPlan|skipParent
* @return mixed
*/
public function getPlans($products, $skipParent = false, $withMainPlan = false)
public function getPlans($products, $param = '')
{
$this->loadModel('productplan');
$branchIDList = $withMainPlan ? array(BRANCH_MAIN) : array();
$param = strtolower($param);
$branchIDList = strpos($param, 'withmainplan') !== false ? array(BRANCH_MAIN => BRANCH_MAIN) : array();
foreach($products as $product)
{
foreach($product->branches as $branchID) $branchIDList[$branchID] = $branchID;
@@ -3684,7 +3673,7 @@ class executionModel extends model
->where('product')->in(array_keys($products))
->andWhere('deleted')->eq(0)
->andWhere('branch')->in($branchIDList)->fi()
->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi()
->beginIF(strpos($param, 'skipparent') !== false)->andWhere('parent')->ne(-1)->fi()
->orderBy('begin desc')
->fetchAll('id');