* Modify the product range of a single creation use case.

This commit is contained in:
tianshujie
2021-11-19 09:32:00 +08:00
parent 70f8e0d320
commit f033e37924
3 changed files with 24 additions and 13 deletions
+18 -11
View File
@@ -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();
}
+2 -1
View File
@@ -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&param=&projectID=" + objectID : "productID=" + productID;
$.get(createLink('branch', 'ajaxGetBranches', param), function(data)
{
if(data)
{
+4 -1
View File
@@ -17,6 +17,9 @@
<?php js::set('lblAfter', $lang->testcase->insertAfter);?>
<?php js::set('isonlybody', isonlybody());?>
<?php js::set('executionID', $projectID);?>
<?php js::set('tab', $this->app->tab);?>
<?php if($this->app->tab == 'execution') js::set('objectID', $this->session->execution);?>
<?php if($this->app->tab == 'project') js::set('objectID', $this->session->project);?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
@@ -40,7 +43,7 @@
<td>
<div class='input-group'>
<?php echo html::select('product', $products, $productID, "onchange='loadAll(this.value);' class='form-control chosen'");?>
<?php if($this->session->currentProductType != 'normal') echo html::select('branch', $branches, $branch, "onchange='loadBranch();' class='form-control' style='width:120px'");?>
<?php if(isset($product->type) and $product->type != 'normal') echo html::select('branch', $branches, $branch, "onchange='loadBranch();' class='form-control' style='width:120px'");?>
</div>
</td>
<td style='padding-left:15px;'>