* Deal with the scope of the product when creating and editing bugs.

This commit is contained in:
tianshujie
2021-11-19 19:21:34 +08:00
parent 01bfb0629e
commit 47a651b599
5 changed files with 37 additions and 4 deletions

View File

@@ -501,6 +501,20 @@ class bug extends control
$steps = $todo->desc;
$pri = $todo->pri;
}
/* Get branches. */
if($this->app->tab == 'execution' or $this->app->tab == 'project')
{
$objectID = $this->app->tab == 'project' ? $projectID : $executionID;
$productBranches = (isset($productInfo->type) and $productInfo->type != 'normal') ? $this->loadModel('execution')->getBranchByProduct($productID, $objectID) : array();
$branches = isset($productBranches[$productID]) ? $productBranches[$productID] : array();
$branch = key($branches);
}
else
{
$branches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('branch')->getPairs($productID, 'active') : array();
}
/* Replace the value of bug that needs to be replaced with the value of the object that is transferred to bug. */
if(isset($fromObject))
{
@@ -940,6 +954,17 @@ class bug extends control
$projectID = $this->lang->navGroup->bug == 'project' ? $this->session->project : 0;
if($this->app->tab == 'execution' or $this->app->tab == 'project')
{
$objectID = $this->app->tab == 'project' ? $bug->project : $bug->execution;
$productBranches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('execution')->getBranchByProduct($productID, $objectID) : array();
$branches = isset($productBranches[$productID]) ? $productBranches[$productID] : array();
}
else
{
$branches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('branch')->getPairs($productID) : array();
}
$this->view->bug = $bug;
$this->view->productID = $productID;
$this->view->product = $product;
@@ -950,7 +975,7 @@ class bug extends control
$this->view->currentModuleID = $currentModuleID;
$this->view->executions = array(0 => '') + $this->product->getExecutionPairsByProduct($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'id_desc', $projectID);
$this->view->stories = $bug->execution ? $this->story->getExecutionStoryPairs($bug->execution) : $this->story->getProductStoryPairs($bug->product, $bug->branch);
$this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($bug->product);
$this->view->branches = $branches;
$this->view->tasks = $this->task->getExecutionTaskPairs($bug->execution);
$this->view->testtasks = $this->loadModel('testtask')->getPairs($bug->product, $bug->execution, $bug->testtask);
$this->view->users = $this->user->getPairs('nodeleted', "$bug->assignedTo,$bug->resolvedBy,$bug->closedBy,$bug->openedBy");

View File

@@ -492,7 +492,9 @@ function loadProductBranches(productID)
$('#branch').remove();
$('#branch_chosen').remove();
$('#branch').next('.picker').remove();
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data)
var param = (typeof(tab) != 'undefined' && (tab == 'execution' || tab == 'project')) ? "productID=" + productID + "&oldBranch=0&param=&projectID=" + objectID : "productID=" + productID;
$.get(createLink('branch', 'ajaxGetBranches', param), function(data)
{
if(data)
{

View File

@@ -26,6 +26,9 @@ js::set('isStepsTemplate', $isStepsTemplate);
js::set('oldProjectID', $projectID);
js::set('blockID', $blockID);
js::set('moduleID', $moduleID);
js::set('tab', $this->app->tab);
if($this->app->tab == 'execution') js::set('objectID', $executionID);
if($this->app->tab == 'project') js::set('objectID', $projectID);
?>
<div id="mainContent" class="main-content fade">
<div class="center-block">

View File

@@ -26,6 +26,9 @@ js::set('oldOpenedBuild' , $bug->openedBuild);
js::set('oldResolvedBuild' , $bug->resolvedBuild);
js::set('systemMode' , $config->systemMode);
js::set('confirmUnlinkBuild' , sprintf($lang->bug->confirmUnlinkBuild, zget($resolvedBuilds, $bug->resolvedBuild)));
js::set('tab' , $this->app->tab);
if($this->app->tab == 'execution') js::set('objectID', $bug->execution);
if($this->app->tab == 'project') js::set('objectID', $bug->project);
?>
<div class='main-content' id='mainContent'>

View File

@@ -456,14 +456,14 @@ class testcase extends control
$product = $this->product->getById($productID);
if($this->app->tab == 'execution' or $this->app->tab == 'project')
{
$objectID = $this->app->tab == 'project' ? $this->session->project : $this->session->execution;
$objectID = $this->app->tab == 'project' ? $projectID : $executionID;
$productBranches = (isset($product->type) and $product->type != 'normal') ? $this->execution->getBranchByProduct($productID, $objectID) : array();
$branches = isset($productBranches[$productID]) ? $productBranches[$productID] : array();
$branch = key($branches);
}
else
{
$branches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('branch')->getPairs($productID) : array();
$branches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('branch')->getPairs($productID, 'active') : array();
}
$this->view->customFields = $customFields;