diff --git a/module/testcase/control.php b/module/testcase/control.php index ea29edeb1f..a218797814 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -57,11 +57,16 @@ class testcase extends control { $this->loadModel('datatable'); - /* Set browseType, productID, moduleID and queryID. */ + /* Set browse type. */ $browseType = strtolower($browseType); + + if($browseType == 'bymodule') setcookie('caseModule', (int)$param, $this->config->cookieLife, $this->config->webRoot); + if($browseType != 'bymodule') $this->session->set('caseBrowseType', $browseType); + + /* Set browseType, productID, moduleID and queryID. */ $productID = $this->product->saveState($productID, $this->products); $branch = ($branch === '') ? $this->session->branch : $branch; - $moduleID = ($browseType == 'bymodule') ? (int)$param : 0; + $moduleID = ($browseType == 'bymodule') ? (int)$param : ($browseType == 'bysearch' ? 0 : ($this->cookie->caseModule ? $this->cookie->caseModule : 0)); $queryID = ($browseType == 'bysearch') ? (int)$param : 0; /* Set menu, save session. */ @@ -101,6 +106,7 @@ class testcase extends control $this->view->productName = $this->products[$productID]; $this->view->modules = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0, $branch); $this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createCaseLink'), '', $branch); + $this->view->moduleName = $moduleID ? $this->tree->getById($moduleID)->name : $this->lang->tree->all; $this->view->moduleID = $moduleID; $this->view->pager = $pager; $this->view->users = $this->user->getPairs('noletter'); diff --git a/module/testcase/js/browse.js b/module/testcase/js/browse.js index 12e1902f6f..7b67fdf9ff 100644 --- a/module/testcase/js/browse.js +++ b/module/testcase/js/browse.js @@ -23,7 +23,7 @@ function confirmBatchDelete(actionLink) $(document).ready(function() { - $('#' + browseType + 'Tab').addClass('active'); + $('#' + caseBrowseType + 'Tab').addClass('active'); $('#module' + moduleID).addClass('active'); if(browseType == 'bysearch') ajaxGetSearchForm(); setTimeout(function(){fixedTfootAction('#batchForm')}, 100); diff --git a/module/testcase/model.php b/module/testcase/model.php index 71fbb016f7..75478b2fe5 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -246,10 +246,15 @@ class testcaseModel extends model */ public function getTestCases($productID, $branch, $browseType, $queryID, $moduleID, $sort, $pager) { + /* Set modules and browse type. */ + $modules = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : '0'; + $browseType = (($browseType == 'bymodule') and ($this->session->caseBrowseType) and ($this->session->caseBrowseType != 'bysearch')) ? $this->session->caseBrowseType : $browseType; + /* By module or all cases. */ + $cases = array(); if($browseType == 'bymodule' or $browseType == 'all') { - $cases = $this->getModuleCases($productID, $branch, $this->loadModel('tree')->getAllChildId($moduleID), $sort, $pager); + $cases = $this->getModuleCases($productID, $branch, $modules, $sort, $pager); } /* Cases need confirmed. */ elseif($browseType == 'needconfirm') @@ -260,6 +265,7 @@ class testcaseModel extends model ->andWhere('t2.version > t1.storyVersion') ->andWhere('t1.product')->eq($productID) ->beginIF($branch)->andWhere('t1.branch')->eq($branch) + ->beginIF($modules)->andWhere('t1.module')->in($modules) ->orderBy($sort) ->page($pager) ->fetchAll(); @@ -270,9 +276,7 @@ class testcaseModel extends model $cases = $this->getBySearch($productID, $queryID, $sort, $pager); } - if($cases) return $cases; - - return array(); + return $cases; } /** diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index 69c9d57777..f7a4f1ba20 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -15,10 +15,11 @@ include '../../common/view/header.html.php'; include '../../common/view/datepicker.html.php'; include '../../common/view/datatable.fix.html.php'; include './caseheader.html.php'; -js::set('browseType', $browseType); -js::set('moduleID' , $moduleID); -js::set('confirmDelete', $lang->testcase->confirmDelete); -js::set('batchDelete', $lang->testcase->confirmBatchDelete); +js::set('browseType', $browseType); +js::set('caseBrowseType', $this->session->caseBrowseType); +js::set('moduleID' , $moduleID); +js::set('confirmDelete', $lang->testcase->confirmDelete); +js::set('batchDelete', $lang->testcase->confirmBatchDelete); ?>
diff --git a/module/testcase/view/caseheader.html.php b/module/testcase/view/caseheader.html.php index ce2bab6369..4f4306c575 100644 --- a/module/testcase/view/caseheader.html.php +++ b/module/testcase/view/caseheader.html.php @@ -1,6 +1,21 @@