diff --git a/module/testcase/control.php b/module/testcase/control.php index e340fa8cce..ea35a7644f 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -299,15 +299,6 @@ class testcase extends control */ public function create($productID, $branch = '', $moduleID = 0, $from = '', $param = 0, $storyID = 0, $extras = '') { - if($this->app->tab == 'execution') - { - $this->loadModel('execution')->setMenu($this->session->execution); - } - else - { - $this->qa->setMenu($this->products, $productID, $branch); - } - $testcaseID = ($from and strpos('testcase|work|contribute', $from) !== false) ? $param : 0; $bugID = $from == 'bug' ? $param : 0; @@ -362,13 +353,14 @@ class testcase extends control if($branch === '') $branch = $this->cookie->preBranch; /* Set menu. */ + if($this->app->tab == 'project' or $this->app->tab == 'execution') $this->loadModel('execution'); if($this->app->tab == 'project') { $this->loadModel('project')->setMenu($this->session->project); } elseif($this->app->tab == 'execution') { - $this->loadModel('execution')->setMenu($this->session->execution); + $this->execution->setMenu($this->session->execution); } else { @@ -458,6 +450,20 @@ class testcase extends control /* Set custom. */ foreach(explode(',', $this->config->testcase->customCreateFields) as $field) $customFields[$field] = $this->lang->testcase->$field; + + $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; + $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(); + } + $this->view->customFields = $customFields; $this->view->showFields = $this->config->testcase->custom->createFields; @@ -481,7 +487,8 @@ class testcase extends control $this->view->steps = $steps; $this->view->users = $this->user->getPairs('noletter|noclosed|nodeleted'); $this->view->branch = $branch; - $this->view->branches = $this->session->currentProductType != 'normal' ? $this->loadModel('branch')->getPairs($productID) : array(); + $this->view->product = $product; + $this->view->branches = $branches; $this->display(); } diff --git a/module/testcase/js/common.js b/module/testcase/js/common.js index 8ec70ffa3f..f5503151a3 100644 --- a/module/testcase/js/common.js +++ b/module/testcase/js/common.js @@ -50,7 +50,8 @@ function loadBranch() function loadProductBranches(productID) { $('#branch').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/testcase/view/create.html.php b/module/testcase/view/create.html.php index 1e1a6c5df2..1670368904 100644 --- a/module/testcase/view/create.html.php +++ b/module/testcase/view/create.html.php @@ -17,6 +17,9 @@ testcase->insertAfter);?> +app->tab);?> +app->tab == 'execution') js::set('objectID', $this->session->execution);?> +app->tab == 'project') js::set('objectID', $this->session->project);?>