diff --git a/module/bug/control.php b/module/bug/control.php index eecc71db5a..777ba3f02f 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -435,7 +435,7 @@ class bug extends control /* Get product, then set menu. */ $productID = $this->product->saveState($productID, $this->products); $productInfo = $this->product->getById($productID); - $branches = $productInfo->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($productID, 'active'); + if($branch === '') $branch = (int)$this->cookie->preBranch; /* Init vars. */ @@ -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 = $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; @@ -948,9 +973,9 @@ class bug extends control $this->view->projects = array(0 => '') + $this->product->getProjectPairsByProduct($productID, $bug->branch, $bug->project); $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); $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->executions = array(0 => '') + $this->product->getExecutionPairsByProduct($bug->product, $bug->branch, 'id_desc', $bug->project); $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"); diff --git a/module/bug/js/common.js b/module/bug/js/common.js index f0a27b5437..c6cfc14dc0 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -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¶m=&projectID=" + objectID : "productID=" + productID; + $.get(createLink('branch', 'ajaxGetBranches', param), function(data) { if(data) { diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index 9371aaedf5..7e7b8b7b01 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -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); ?>