* code for task #2522,2579.
This commit is contained in:
+13
-54
@@ -230,7 +230,11 @@ class testtask extends control
|
||||
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
||||
/* Set the browseType and moduleID. */
|
||||
$browseType = strtolower($browseType);
|
||||
$moduleID = ($browseType == 'bymodule') ? (int)$param : 0;
|
||||
|
||||
if($browseType == 'bymodule') setcookie('taskCaseModule', (int)$param, $this->config->cookieLife, $this->config->webRoot);
|
||||
if($browseType != 'bymodule') $this->session->set('taskCaseBrowseType', $browseType);
|
||||
|
||||
$moduleID = ($browseType == 'bymodule') ? (int)$param : ($browseType == 'bysearch' ? 0 : ($this->cookie->taskCaseModule ? $this->cookie->taskCaseModule : 0));
|
||||
$queryID = ($browseType == 'bysearch') ? (int)$param : 0;
|
||||
|
||||
/* Append id for secend sort. */
|
||||
@@ -241,58 +245,9 @@ class testtask extends control
|
||||
if(!$task) die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
$productID = $task->product;
|
||||
$this->testtask->setMenu($this->products, $productID, $task->branch);
|
||||
if($browseType == 'bymodule' or $browseType == 'all')
|
||||
{
|
||||
$modules = '';
|
||||
if($moduleID) $modules = $this->loadModel('tree')->getAllChildID($moduleID);
|
||||
$this->view->runs = $this->testtask->getRuns($taskID, $modules, $sort, $pager);
|
||||
}
|
||||
elseif($browseType == 'assignedtome')
|
||||
{
|
||||
$this->view->runs = $this->testtask->getUserRuns($taskID, $this->session->user->account, $sort, $pager);
|
||||
}
|
||||
/* By search. */
|
||||
elseif($browseType == 'bysearch')
|
||||
{
|
||||
if($queryID)
|
||||
{
|
||||
$query = $this->loadModel('search')->getQuery($queryID);
|
||||
if($query)
|
||||
{
|
||||
$this->session->set('testcaseQuery', $query->sql);
|
||||
$this->session->set('testcaseForm', $query->form);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set('testcaseQuery', ' 1 = 1');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->session->testcaseQuery == false) $this->session->set('testcaseQuery', ' 1 = 1');
|
||||
}
|
||||
|
||||
$queryProductID = $productID;
|
||||
$allProduct = "`product` = 'all'";
|
||||
$caseQuery = $this->session->testcaseQuery;
|
||||
if(strpos($this->session->testcaseQuery, $allProduct) !== false)
|
||||
{
|
||||
$products = array_keys($this->loadModel('product')->getPrivProducts());
|
||||
$caseQuery = str_replace($allProduct, '1', $this->session->testcaseQuery);
|
||||
$caseQuery = $caseQuery . ' AND `product`' . helper::dbIN(array_keys($products));
|
||||
$queryProductID = 'all';
|
||||
}
|
||||
|
||||
$caseQuery = preg_replace('/`(\w+)`/', 't2.`$1`', $caseQuery);
|
||||
$this->view->runs = $this->dao->select('t2.*,t1.*, t2.version as caseVersion')->from(TABLE_TESTRUN)->alias('t1')
|
||||
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id')
|
||||
->where($caseQuery)
|
||||
->andWhere('t1.task')->eq($taskID)
|
||||
->beginIF($task->branch)->andWhere('t2.branch')->in("0,{$task->branch}")->fi()
|
||||
->orderBy(strpos($sort, 'assignedTo') !== false ? ('t1.' . $sort) : ('t2.' . $sort))
|
||||
->page($pager)
|
||||
->fetchAll();
|
||||
}
|
||||
/* Get test cases. */
|
||||
$this->view->runs = $this->testtask->getTaskCases($productID, $browseType, $queryID, $moduleID, $sort, $pager, $task);
|
||||
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false);
|
||||
|
||||
/* Save testcaseIDs session for get the pre and next testcase. */
|
||||
@@ -302,12 +257,15 @@ class testtask extends control
|
||||
|
||||
/* Build the search form. */
|
||||
$this->loadModel('testcase');
|
||||
$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['style'] = 'shortcut';
|
||||
$this->config->testcase->search['module'] = 'testtask';
|
||||
$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");
|
||||
unset($this->config->testcase->search['fields']['branch']);
|
||||
unset($this->config->testcase->search['params']['branch']);
|
||||
$this->loadModel('search')->setSearchParams($this->config->testcase->search);
|
||||
$this->search->mergeFeatureBar('testtask', 'cases');
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->cases;
|
||||
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
|
||||
@@ -325,6 +283,7 @@ class testtask extends control
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->taskID = $taskID;
|
||||
$this->view->moduleID = $moduleID;
|
||||
$this->view->moduleName = $moduleID ? $this->tree->getById($moduleID)->name : $this->lang->tree->all;
|
||||
$this->view->treeClass = $browseType == 'bymodule' ? '' : 'hidden';
|
||||
$this->view->pager = $pager;
|
||||
$this->view->branches = $this->loadModel('branch')->getPairs($productID);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
setModal4List('runCase', 'caseList', function(){$(".iframe").modalTrigger({width:1024, type:'iframe'});}, 1024);
|
||||
$('#' + browseType + 'Tab').addClass('active');
|
||||
$('#module' + moduleID).addClass('active');
|
||||
if(browseType == 'bysearch') ajaxGetSearchForm();
|
||||
setTimeout(function(){fixedTfootAction('#casesForm')}, 100);
|
||||
});
|
||||
|
||||
@@ -282,7 +282,7 @@ class testtaskModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getUserRuns($taskID, $user, $orderBy, $pager = null)
|
||||
public function getUserRuns($taskID, $user, $modules = '', $orderBy, $pager = null)
|
||||
{
|
||||
$orderBy = strpos($orderBy, 'assignedTo') !== false ? ('t1.' . $orderBy) : ('t2.' . $orderBy);
|
||||
|
||||
@@ -290,11 +290,77 @@ class testtaskModel extends model
|
||||
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id')
|
||||
->where('t1.task')->eq((int)$taskID)
|
||||
->andWhere('t1.assignedTo')->eq($user)
|
||||
->beginIF($modules)->andWhere('t2.module')->in($modules)->fi()
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get testtask linked cases.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param string $browseType
|
||||
* @param int $queryID
|
||||
* @param int $moduleID
|
||||
* @param string $sort
|
||||
* @param object $pager
|
||||
* @param object $task
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTaskCases($productID, $browseType, $queryID, $moduleID, $sort, $pager, $task)
|
||||
{
|
||||
/* Set modules and browse type. */
|
||||
$modules = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : '0';
|
||||
$browseType = ($browseType == 'bymodule' and $this->session->taskCaseBrowseType and $this->session->taskCaseBrowseType != 'bysearch') ? $this->session->taskCaseBrowseType : $browseType;
|
||||
|
||||
if($browseType == 'bymodule' or $browseType == 'all')
|
||||
{
|
||||
$runs = $this->getRuns($task->id, $modules, $sort, $pager);
|
||||
}
|
||||
elseif($browseType == 'assignedtome')
|
||||
{
|
||||
$runs = $this->getUserRuns($task->id, $this->session->user->account, $modules, $sort, $pager);
|
||||
}
|
||||
/* By search. */
|
||||
elseif($browseType == 'bysearch')
|
||||
{
|
||||
if($this->session->testtaskQuery == false) $this->session->set('testtaskQuery', ' 1 = 1');
|
||||
if($queryID)
|
||||
{
|
||||
$query = $this->loadModel('search')->getQuery($queryID);
|
||||
if($query)
|
||||
{
|
||||
$this->session->set('testtaskQuery', $query->sql);
|
||||
$this->session->set('testtaskForm', $query->form);
|
||||
}
|
||||
}
|
||||
|
||||
$queryProductID = $productID;
|
||||
$allProduct = "`product` = 'all'";
|
||||
$caseQuery = $this->session->testtaskQuery;
|
||||
if(strpos($this->session->testtaskQuery, $allProduct) !== false)
|
||||
{
|
||||
$products = array_keys($this->loadModel('product')->getPrivProducts());
|
||||
$caseQuery = str_replace($allProduct, '1', $this->session->testtaskQuery);
|
||||
$caseQuery = $caseQuery . ' AND `product`' . helper::dbIN(array_keys($products));
|
||||
$queryProductID = 'all';
|
||||
}
|
||||
|
||||
$caseQuery = preg_replace('/`(\w+)`/', 't2.`$1`', $caseQuery);
|
||||
$runs = $this->dao->select('t2.*,t1.*, t2.version as caseVersion')->from(TABLE_TESTRUN)->alias('t1')
|
||||
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id')
|
||||
->where($caseQuery)
|
||||
->andWhere('t1.task')->eq($task->id)
|
||||
->beginIF($task->branch)->andWhere('t2.branch')->in("0,{$task->branch}")->fi()
|
||||
->orderBy(strpos($sort, 'assignedTo') !== false ? ('t1.' . $sort) : ('t2.' . $sort))
|
||||
->page($pager)
|
||||
->fetchAll();
|
||||
}
|
||||
return $runs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info of a test run.
|
||||
*
|
||||
|
||||
@@ -3,14 +3,36 @@
|
||||
<?php echo "<span class='prefix'>" . html::icon($lang->icons['usecase']) . '</span><strong>' . $task->name . '</strong>';?>
|
||||
</div>
|
||||
<div class='nav'>
|
||||
<li>
|
||||
<span>
|
||||
<?php
|
||||
echo isset($moduleID) ? $moduleName : $this->lang->tree->all;
|
||||
if(!empty($moduleID))
|
||||
{
|
||||
$removeLink = $browseType == 'bymodule' ? inlink('cases', "taskID=$taskID&browseType=$browseType¶m=0&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}") : 'javascript:removeCookieByKey("caseModule")';
|
||||
echo ' ' . html::a($removeLink, "<i class='icon icon-remove'></i>") . ' ';
|
||||
}
|
||||
echo " <i class='icon-angle-right'></i> ";
|
||||
?>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
$hasCasesPriv = common::hasPriv('testtask', 'cases');
|
||||
$hasGroupPriv = common::hasPriv('testtask', 'groupcase');
|
||||
?>
|
||||
<?php foreach($app->customMenu['featurebar'] as $type => $featurebar):?>
|
||||
<?php if($featurebar['status'] == 'hide') continue;?>
|
||||
<?php
|
||||
if(common::hasPriv('testtask', 'cases') and ($type == 'all' or $type == 'assignedtome'))
|
||||
if($hasCasesPriv and strpos($type, 'QUERY') === 0)
|
||||
{
|
||||
$queryID = (int)substr($type, 5);
|
||||
echo "<li id='{$type}Tab'>" . html::a($this->inlink('cases', "taskID=$taskID&browseType=bySearch¶m=$queryID"), $featurebar['link']) . "</li>";
|
||||
}
|
||||
elseif($hasCasesPriv and ($type == 'all' or $type == 'assignedtome'))
|
||||
{
|
||||
echo "<li id='{$type}Tab'>" . html::a($this->inlink('cases', "taskID=$taskID&browseType=$type¶m=0"), $featurebar['link']) . "</li>";
|
||||
}
|
||||
elseif(common::hasPriv('testtask', 'cases') and $type == 'group')
|
||||
elseif($hasGroupPriv and $type == 'group')
|
||||
{
|
||||
echo "<li id='groupTab' class='dropdown'>";
|
||||
$groupBy = isset($groupBy) ? $groupBy : '';
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<?php include '../../common/view/datatable.fix.html.php';?>
|
||||
<?php include './caseheader.html.php';?>
|
||||
<?php js::set('confirmUnlink', $lang->testtask->confirmUnlinkCase)?>
|
||||
<?php js::set('taskCaseBrowseType', ($browseType == 'bymodule' and $this->session->taskCaseBrowseType == 'bysearch') ? 'all' : $this->session->taskCaseBrowseType);?>
|
||||
<script language="Javascript">
|
||||
var browseType = '<?php echo $browseType;?>';
|
||||
var moduleID = '<?php echo $moduleID;?>';
|
||||
@@ -79,4 +80,17 @@ include $useDatatable ? dirname(__FILE__) . '/datatabledata.html.php' : dirname(
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
$('#module' + moduleID).addClass('active');
|
||||
$('#' + taskCaseBrowseType + 'Tab').addClass('active');
|
||||
<?php if($browseType == 'bysearch'):?>
|
||||
$shortcut = $('#QUERY<?php echo (int)$param;?>Tab');
|
||||
if($shortcut.size() > 0)
|
||||
{
|
||||
$shortcut.addClass('active');
|
||||
$('#bysearchTab').removeClass('active');
|
||||
$('#querybox').removeClass('show');
|
||||
}
|
||||
<?php endif;?>
|
||||
</script>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user