* finish for testtask branch.

This commit is contained in:
wangyidong
2015-10-29 10:05:01 +08:00
parent d52bb5da5c
commit 1202c8db38
11 changed files with 75 additions and 42 deletions
+10 -10
View File
@@ -51,15 +51,6 @@ class branch extends control
$this->display();
}
public function ajaxGetBranches($productID)
{
$product = $this->loadModel('product')->getById($productID);
if(empty($product) or $product->type == 'normal') die();
$branches = $this->branch->getPairs($productID);
die(html::select('branch', $branches, '', "class='form-control' onchange='loadBranch()'"));
}
public function delete($branchID, $confirm = 'no')
{
if($confirm == 'no') die(js::confirm($this->lang->branch->confirmDelete, inlink('delete', "branchID=$branchID&confirm=yes")));
@@ -67,5 +58,14 @@ class branch extends control
$this->branch->delete(TABLE_BRANCH, $branchID);
die(js::reload('parent'));
}
}
public function ajaxGetBranches($productID, $oldBranch = 0)
{
$product = $this->loadModel('product')->getById($productID);
if(empty($product) or $product->type == 'normal') die();
$branches = $this->branch->getPairs($productID);
if($oldBranch) $branches = array($oldBranch => $branches[$oldBranch]);
die(html::select('branch', $branches, '', "class='form-control' onchange='loadBranch()'"));
}
}
+1 -1
View File
@@ -434,7 +434,7 @@ class bug extends control
$this->view->stories = $stories;
$this->view->builds = $builds;
$this->view->users = $this->user->getPairs('nodeleted,devfirst');
$this->view->projects = $this->product->getProjectPairs($productID, $params = 'nodeleted');
$this->view->projects = $this->product->getProjectPairs($productID, $branch, $params = 'nodeleted');
$this->view->projectID = $projectID;
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $branch);
$this->view->moduleID = $moduleID;
+1 -2
View File
@@ -6,13 +6,12 @@ $(document).ready(function()
function loadBranches(productID)
{
$('#branch').remove();
$.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID), function(data)
$.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=' + productGroups[productID]['branch']), function(data)
{
if(data)
{
$('#product').closest('.input-group').append(data);
$('#branch').css('width', '100px');
$('#branch').val(productGroups[productID]['branch']);
}
});
}
+7 -1
View File
@@ -28,7 +28,13 @@
<?php if($products):?>
<div class='input-group'>
<?php echo html::select('product', $products, $product->id, "onchange='loadBranches(this.value);' class='form-control chosen'");?>
<?php if($product->type != 'normal') echo html::select('branch', $branches, $product->branch, "class='form-control' style='width:100px'");?>
<?php
if($product->type != 'normal')
{
if($product->branch) $branches = array($product->branch => $branches[$product->branch]);
echo html::select('branch', $branches, $product->branch, "class='form-control' style='width:100px'");
}
?>
</div>
<?php endif;?>
</td>
+3 -2
View File
@@ -427,7 +427,7 @@ class testcase extends control
* @access public
* @return void
*/
public function createBug($productID, $extras = '')
public function createBug($productID, $branch = 0, $extras = '')
{
parse_str(str_replace(array(',', ' '), array('&', ''), $extras));
@@ -445,13 +445,14 @@ class testcase extends control
}
if(!$case) die(js::error($this->lang->notFound) . js::locate('back', 'parent'));
if(empty($case->steps)) die(js::locate($this->createLink('bug', 'create', "product=$productID&extras=$extras"), 'parent'));
if(empty($case->steps)) die(js::locate($this->createLink('bug', 'create', "product=$productID&branch=$branch&extras=$extras"), 'parent'));
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->createBug;
$this->view->case = $case;
$this->view->result = reset($results);
$this->view->extras = $extras;
$this->view->productID = $productID;
$this->view->branch = $branch;
$this->display();
}
+1 -1
View File
@@ -11,7 +11,7 @@
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<form action='<?php echo $this->createLink('bug', 'create', "product=$productID&extras=$extras")?>' target='_parent' method='post'>
<form action='<?php echo $this->createLink('bug', 'create', "product=$productID&branch=$branch&extras=$extras")?>' target='_parent' method='post'>
<table class='table table-condensed table-hover table-striped tablesorter table-fixed'>
<thead>
<tr>
+32 -12
View File
@@ -49,14 +49,14 @@ class testtask extends control
* @access public
* @return void
*/
public function browse($productID = 0, $type = 'wait', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function browse($productID = 0, $branch = 0, $type = 'wait', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* Save session. */
$this->session->set('testtaskList', $this->app->getURI(true));
/* Set menu. */
$productID = $this->product->saveState($productID, $this->products);
$this->testtask->setMenu($this->products, $productID);
$this->testtask->setMenu($this->products, $productID, $branch);
/* Load pager. */
$this->app->loadClass('pager', $static = true);
@@ -71,10 +71,11 @@ class testtask extends control
$this->view->productID = $productID;
$this->view->productName = $this->products[$productID];
$this->view->orderBy = $orderBy;
$this->view->tasks = $this->testtask->getProductTasks($productID, $sort, $pager, $type);
$this->view->tasks = $this->testtask->getProductTasks($productID, $branch, $sort, $pager, $type);
$this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter');
$this->view->pager = $pager;
$this->view->type = $type;
$this->view->branch = $branch;
$this->display();
}
@@ -132,7 +133,7 @@ class testtask extends control
/* Create testtask from testtask of test.*/
if($projectID == 0)
{
$projects = $this->product->getProjectPairs($productID, $params = 'nodeleted');
$projects = $this->product->getProjectPairs($productID, $branch = 0, $params = 'nodeleted');
$builds = $this->loadModel('build')->getProductBuildPairs($productID);
}
@@ -186,7 +187,7 @@ class testtask extends control
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug');
}
$this->testtask->setMenu($this->products, $productID);
$this->testtask->setMenu($this->products, $productID, $task->branch);
$this->view->title = "TASK #$task->id $task->name/" . $this->products[$productID];
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
@@ -237,7 +238,7 @@ class testtask extends control
$task = $this->testtask->getById($taskID);
if(!$task) die(js::error($this->lang->notFound) . js::locate('back'));
$productID = $task->product;
$this->testtask->setMenu($this->products, $productID);
$this->testtask->setMenu($this->products, $productID, $task->branch);
if($browseType == 'bymodule' or $browseType == 'all')
{
$modules = '';
@@ -301,6 +302,15 @@ class testtask extends control
$this->config->testcase->search['params']['product']['values']= array($productID => $this->products[$productID], 'all' => $this->lang->testcase->allProduct);
$this->config->testcase->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'case');
$this->config->testcase->search['actionURL'] = inlink('cases', "taskID=$taskID&browseType=bySearch&queryID=myQueryID");
if($this->session->currentProductType == 'normal')
{
unset($this->config->testcase->search['fields']['branch']);
unset($this->config->testcase->search['params']['branch']);
}
else
{
$this->config->testcase->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty');
}
$this->loadModel('search')->setSearchParams($this->config->testcase->search);
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->cases;
@@ -312,7 +322,7 @@ class testtask extends control
$this->view->productName = $this->products[$productID];
$this->view->task = $task;
$this->view->users = $this->loadModel('user')->getPairs('noclosed,nodeleted,qafirst');
$this->view->moduleTree = $this->loadModel('tree')->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createTestTaskLink'), $extra = $taskID);
$this->view->moduleTree = $this->loadModel('tree')->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createTestTaskLink'), $extra = $taskID, $task->branch);
$this->view->browseType = $browseType;
$this->view->param = $param;
$this->view->orderBy = $orderBy;
@@ -335,7 +345,7 @@ class testtask extends control
$task = $this->testtask->getById($taskID);
if(!$task) die(js::error($this->lang->notFound) . js::locate('back'));
$productID = $task->product;
$this->testtask->setMenu($this->products, $productID);
$this->testtask->setMenu($this->products, $productID, $task->branch);
$runs = $this->testtask->getRuns($taskID, 0, $groupBy);
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false);
@@ -396,7 +406,7 @@ class testtask extends control
$productID = $this->product->saveState($task->product, $this->products);
/* Set menu. */
$this->testtask->setMenu($this->products, $productID);
$this->testtask->setMenu($this->products, $productID, $task->branch);
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->edit;
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
@@ -442,7 +452,7 @@ class testtask extends control
$productID = $this->product->saveState($testtask->product, $this->products);
/* Set menu. */
$this->testtask->setMenu($this->products, $productID);
$this->testtask->setMenu($this->products, $productID, $testtask->branch);
$this->view->testtask = $testtask;
$this->view->title = $testtask->name . $this->lang->colon . $this->lang->testtask->start;
@@ -483,7 +493,7 @@ class testtask extends control
$productID = $this->product->saveState($testtask->product, $this->products);
/* Set menu. */
$this->testtask->setMenu($this->products, $productID);
$this->testtask->setMenu($this->products, $productID, $testtask->branch);
$this->view->testtask = $this->testtask->getById($taskID);
$this->view->title = $testtask->name . $this->lang->colon . $this->lang->close;
@@ -562,10 +572,19 @@ class testtask extends control
$this->config->testcase->search['params']['product']['values']= array($productID => $this->products[$productID], 'all' => $this->lang->testcase->allProduct);
$this->config->testcase->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'case');
$this->config->testcase->search['actionURL'] = inlink('linkcase', "taskID=$taskID");
if($this->session->currentProductType == 'normal')
{
unset($this->config->testcase->search['fields']['branch']);
unset($this->config->testcase->search['params']['branch']);
}
else
{
$this->config->testcase->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty');
}
$this->loadModel('search')->setSearchParams($this->config->testcase->search);
/* Save session. */
$this->testtask->setMenu($this->products, $productID);
$this->testtask->setMenu($this->products, $productID, $task->branch);
$this->view->title = $task->name . $this->lang->colon . $this->lang->testtask->linkCase;
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
@@ -581,6 +600,7 @@ class testtask extends control
$cases = $this->dao->select('*')->from(TABLE_CASE)->where($query)
->andWhere('product')->eq($productID)
->andWhere('id')->notIN($linkedCases)
->andWhere('branch')->in("0,$task->branch")
->andWhere('deleted')->eq(0)
->orderBy('id desc')
->page($pager)
+13 -7
View File
@@ -21,10 +21,10 @@ class testtaskModel extends model
* @access public
* @return void
*/
public function setMenu($products, $productID)
public function setMenu($products, $productID, $branch = 0)
{
$this->loadModel('product')->setMenu($products, $productID);
$selectHtml = $this->product->select($products, $productID, 'testtask', 'browse');
$this->loadModel('product')->setMenu($products, $productID, $branch);
$selectHtml = $this->product->select($products, $productID, 'testtask', 'browse', '', $branch);
foreach($this->lang->testtask->menu as $key => $value)
{
$replace = ($key == 'product') ? $selectHtml : $productID;
@@ -61,17 +61,20 @@ class testtaskModel extends model
* @access public
* @return array
*/
public function getProductTasks($productID, $orderBy = 'id_desc', $pager = null, $type = '')
public function getProductTasks($productID, $branch = 0, $orderBy = 'id_desc', $pager = null, $type = '')
{
return $this->dao->select('t1.*, t2.name AS productName, t3.name AS projectName, t4.name AS buildName')
return $this->dao->select('t1.*, t2.name AS productName, t3.name AS projectName, t4.name AS buildName, if(t4.branch, t4.branch, t5.branch) AS branch')
->from(TABLE_TESTTASK)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_PROJECT)->alias('t3')->on('t1.project = t3.id')
->leftJoin(TABLE_BUILD)->alias('t4')->on('t1.build = t4.id')
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t5')->on('t1.project = t5.project')
->where('t1.product')->eq((int)$productID)
->andWhere('t5.product = t1.product')
->andWhere('t1.deleted')->eq(0)
->beginIF($type == 'wait')->andWhere('t1.status')->ne('done')->fi()
->beginIF($type == 'done')->andWhere('t1.status')->eq('done')->fi()
->beginIF($branch)->andWhere("if(t4.branch, t4.branch, t5.branch) = '$branch'")->fi()
->orderBy($orderBy)
->page($pager)
->fetchAll();
@@ -108,12 +111,15 @@ class testtaskModel extends model
*/
public function getById($taskID, $setImgSize = false)
{
$task = $this->dao->select('t1.*, t2.name AS productName, t3.name AS projectName, t4.name AS buildName')
$task = $this->dao->select('t1.*, t2.name AS productName, t2.type AS productType, t3.name AS projectName, t4.name AS buildName, if(t4.branch, t4.branch, t5.branch) AS branch')
->from(TABLE_TESTTASK)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_PROJECT)->alias('t3')->on('t1.project = t3.id')
->leftJoin(TABLE_BUILD)->alias('t4')->on('t1.build = t4.id')
->where('t1.id')->eq((int)$taskID)->fetch();
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t5')->on('t1.project = t5.project')
->where('t1.id')->eq((int)$taskID)
->andWhere('t5.product = t1.product')
->fetch();
if($setImgSize) $task->desc = $this->loadModel('file')->setImgSize($task->desc);
return $task;
}
+3 -3
View File
@@ -14,14 +14,14 @@
<?php js::set('confirmDelete', $lang->testtask->confirmDelete)?>
<div id="featurebar">
<ul class="nav">
<li id='waitTab'><?php echo html::a(inlink('browse', "productID=$productID&type=wait"), $lang->testtask->wait);?></li>
<li id='doneTab'><?php echo html::a(inlink('browse', "productID=$productID&type=done"), $lang->testtask->done);?></li>
<li id='waitTab'><?php echo html::a(inlink('browse', "productID=$productID&branch=$branch&type=wait"), $lang->testtask->wait);?></li>
<li id='doneTab'><?php echo html::a(inlink('browse', "productID=$productID&branch=$branch&type=done"), $lang->testtask->done);?></li>
</ul>
<div class="actions"><?php common::printIcon('testtask', 'create', "product=$productID");?></div>
</div>
<table class='table tablesorter table-fixed' id='taskList'>
<thead>
<?php $vars = "productID=$productID&type=$type&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; ?>
<?php $vars = "productID=$productID&branch=$branch&type=$type&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; ?>
<tr>
<th class='w-id'> <?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
<th> <?php common::printOrderLink('name', $orderBy, $vars, $lang->testtask->name);?></th>
+1 -1
View File
@@ -81,7 +81,7 @@ var moduleID = '<?php echo $moduleID;?>';
echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"caseList\",confirmUnlink)", '<i class="icon-unlink"></i>', '', "title='{$lang->testtask->unlinkCase}' class='btn-icon'");
}
common::printIcon('testcase', 'createBug', "product=$productID&extra=projectID=$task->project,buildID=$task->build,caseID=$run->case,version=$run->version,runID=$run->id,testtask=$taskID", $run, 'list', 'bug', '', 'iframe');
common::printIcon('testcase', 'createBug', "product=$productID&branch=$task->branch&extra=projectID=$task->project,buildID=$task->build,caseID=$run->case,version=$run->version,runID=$run->id,testtask=$taskID", $run, 'list', 'bug', '', 'iframe');
?>
</td>
</tr>
+3 -2
View File
@@ -284,8 +284,9 @@ class treeModel extends model
$treeMenu = array();
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branchID));
while($module = $stmt->fetch()) $this->buildTree($treeMenu, $module, $type, $userFunc, $extra, $branchID);
if($type == 'case' and !empty($extra) and empty($treeMenu)) continue;
ksort($treeMenu);
if(!empty($branchID) and $branchID != 'null')
if(!empty($branchID) and $branch and $branchID != 'null')
{
$linkHtml = $manage ? html::a(inlink('browse', "root=$rootID&viewType=$type&currentModuleID=0&branch=$branchID"), $branch) : $this->createBranchLink($type, $rootID, $branchID, $branch);
$lastMenu .= "<li>$linkHtml<ul>" . @array_shift($treeMenu) . "</ul></li>\n";
@@ -472,7 +473,7 @@ class treeModel extends model
{
$modules = $this->getAllChildID($module->id);
$runs = $this->testtask->getRuns($extra, $modules, 'id');
if(empty($runs)) continue;
if(empty($runs)) return;
}
$extra['branchID'] = $branch;