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); ?>
diff --git a/module/bug/view/edit.html.php b/module/bug/view/edit.html.php index ae065ded78..30cfc7cd40 100644 --- a/module/bug/view/edit.html.php +++ b/module/bug/view/edit.html.php @@ -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); ?>
diff --git a/module/execution/model.php b/module/execution/model.php index 7b24c4b01e..61af50ee20 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1323,7 +1323,7 @@ class executionModel extends model { $link = helper::createLink($module, $method, "productID=0&branch=0&extra=executionID=%s"); } - elseif(in_array($module, array('bug', 'case', 'testtask', 'testreport')) and $method == 'view') + elseif(in_array($module, array('bug', 'case', 'testtask', 'testreport')) and strpos(',view,edit,', ",$method,") !== false) { $link = helper::createLink('execution', $module, "executionID=%s"); } diff --git a/module/testcase/control.php b/module/testcase/control.php index d1d80274ea..1ef99605cf 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -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; diff --git a/module/testcase/js/batchedit.js b/module/testcase/js/batchedit.js index a8bbaa48bd..97889bfd11 100644 --- a/module/testcase/js/batchedit.js +++ b/module/testcase/js/batchedit.js @@ -30,7 +30,7 @@ function loadBranches(product, branch, caseID) if(typeof(branch) == 'undefined') branch = 0; if(!branch) branch = 0; - moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + product + '&viewtype=case&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=' + caseID + '&needManage=true'); + moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + product + '&viewtype=case&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=' + caseID); $('#modules' + caseID).parent('td').load(moduleLink, function() { $("#modules" + caseID).attr('onchange', "loadStories("+ product + ", this.value, " + caseID + ")").chosen();