From d89d674cddfa277ffd8104749dfed9dc04659622 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 20 Apr 2016 14:51:05 +0800 Subject: [PATCH] * code for task #2522,2579. --- db/update8.1.3.sql | 1 + module/bug/control.php | 2 + module/bug/js/browse.js | 2 - module/bug/model.php | 2 +- module/bug/view/browse.html.php | 27 ++++-- module/file/view/export.html.php | 2 +- module/product/control.php | 3 + module/product/model.php | 2 +- module/product/view/browse.html.php | 18 +++- module/project/control.php | 2 + module/project/css/task.css | 1 + module/project/lang/zh-cn.php | 15 +--- module/project/view/task.html.php | 73 +++++++++++++++- module/project/view/taskheader.html.php | 90 ++++---------------- module/search/control.php | 26 ++++++ module/search/lang/zh-cn.php | 4 + module/search/model.php | 36 ++++++++ module/search/view/ajaxsaveshortcut.html.php | 28 ++++++ module/search/view/buildform.html.php | 4 +- module/testcase/control.php | 2 + module/testcase/js/browse.js | 2 - module/testcase/model.php | 2 +- module/testcase/view/browse.html.php | 15 +++- module/testcase/view/caseheader.html.php | 22 +++-- module/testtask/control.php | 67 +++------------ module/testtask/js/cases.js | 2 - module/testtask/model.php | 68 ++++++++++++++- module/testtask/view/caseheader.html.php | 26 +++++- module/testtask/view/cases.html.php | 14 +++ 29 files changed, 385 insertions(+), 173 deletions(-) create mode 100644 module/search/view/ajaxsaveshortcut.html.php diff --git a/db/update8.1.3.sql b/db/update8.1.3.sql index 8ace0ad427..346092b2a7 100644 --- a/db/update8.1.3.sql +++ b/db/update8.1.3.sql @@ -19,3 +19,4 @@ ALTER TABLE `zt_task` ADD `color` char(7) COLLATE 'utf8_general_ci' NOT NULL AFT ALTER TABLE `zt_story` ADD `color` char(7) COLLATE 'utf8_general_ci' NOT NULL AFTER `status`; ALTER TABLE `zt_bug` ADD `color` char(7) COLLATE 'utf8_general_ci' NOT NULL AFTER `status`; ALTER TABLE `zt_case` ADD `color` char(7) COLLATE 'utf8_general_ci' NOT NULL AFTER `status`; +ALTER TABLE `zt_userquery` ADD `shortcut` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '0'; diff --git a/module/bug/control.php b/module/bug/control.php index b34a1b8dc2..0365bdc7d2 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -105,8 +105,10 @@ class bug extends control $bugs = $this->bug->processBuildForBugs($bugs); /* Build the search form. */ + $this->config->bug->search['style'] = 'shortcut'; $actionURL = $this->createLink('bug', 'browse', "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID"); $this->bug->buildSearchForm($productID, $this->products, $queryID, $actionURL); + $this->loadModel('search')->mergeFeatureBar('bug', 'browse'); $showModule = !empty($this->config->datatable->bugbrowse->showModule) ? $this->config->datatable->bugbrowse->showModule : ''; $this->view->modulePairs = $showModule ? $this->tree->getModulePairs($productID, 'bug', $showModule) : array(); diff --git a/module/bug/js/browse.js b/module/bug/js/browse.js index 52439e9671..550b231de9 100644 --- a/module/bug/js/browse.js +++ b/module/bug/js/browse.js @@ -1,7 +1,5 @@ $(document).ready(function() { - $('#' + bugBrowseType + 'Tab').addClass('active'); - $('#module' + moduleID).addClass('active'); if(browseType == 'bysearch') ajaxGetSearchForm(); $('.dropdown-menu .with-search .menu-search').click(function(e) diff --git a/module/bug/model.php b/module/bug/model.php index 922470965f..dbe4c47cdc 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -224,7 +224,7 @@ class bugModel extends model { /* Set modules and browse type. */ $modules = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : '0'; - $browseType = (($browseType == 'bymodule') and ($this->session->bugBrowseType) and ($this->session->bugBrowseType != 'bysearch')) ? $this->session->bugBrowseType : $browseType; + $browseType = ($browseType == 'bymodule' and $this->session->bugBrowseType and $this->session->bugBrowseType != 'bysearch') ? $this->session->bugBrowseType : $browseType; /* Get bugs by browse type. */ $bugs = array(); diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php index 0948e1483a..403ba46524 100644 --- a/module/bug/view/browse.html.php +++ b/module/bug/view/browse.html.php @@ -15,7 +15,7 @@ include '../../common/view/header.html.php'; include '../../common/view/datatable.fix.html.php'; js::set('browseType', $browseType); js::set('moduleID', $moduleID); -js::set('bugBrowseType', $this->session->bugBrowseType); +js::set('bugBrowseType', ($browseType == 'bymodule' and $this->session->bugBrowseType == 'bysearch') ? 'all' : $this->session->bugBrowseType); ?>
@@ -211,14 +216,20 @@ js::set('bugBrowseType', $this->session->bugBrowseType);
diff --git a/module/file/view/export.html.php b/module/file/view/export.html.php index e9bdaeb834..9cdbdba0ee 100644 --- a/module/file/view/export.html.php +++ b/module/file/view/export.html.php @@ -141,7 +141,7 @@ $(document).ready(function() $exportFieldPairs[$field] = isset($moduleLang->$field) ? $moduleLang->$field : (isset($lang->$field) ? $lang->$field : $field); } ?> -
+
file->exportFields?>

diff --git a/module/product/control.php b/module/product/control.php index 614d716a61..d1c19ad5ae 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -143,8 +143,10 @@ class product extends control $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story'); /* Build search form. */ + $this->config->product->search['style'] = 'shortcut'; $actionURL = $this->createLink('product', 'browse', "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID"); $this->product->buildSearchForm($productID, $this->products, $queryID, $actionURL); + $this->loadModel('search')->mergeFeatureBar('product', 'browse'); $showModule = !empty($this->config->datatable->productbrowse->showModule) ? $this->config->datatable->productbrowse->showModule : ''; $this->view->modulePairs = $showModule ? $this->tree->getModulePairs($productID, 'story', $showModule) : array(); @@ -172,6 +174,7 @@ class product extends control $this->view->branches = $this->loadModel('branch')->getPairs($productID); $this->view->storyStages = $this->product->batchGetStoryStage($stories); $this->view->setShowModule = true; + $this->view->param = $param; $this->display(); } diff --git a/module/product/model.php b/module/product/model.php index 1b1ee0714f..f49732f950 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -367,7 +367,7 @@ class productModel extends model /* Set modules and browse type. */ $modules = $moduleID ? $this->loadModel('tree')->getAllChildID($moduleID) : '0'; - $browseType = (($browseType == 'bymodule') and ($this->session->storyBrowseType) and ($this->session->storyBrowseType != 'bysearch')) ? $this->session->storyBrowseType : $browseType; + $browseType = ($browseType == 'bymodule' and $this->session->storyBrowseType and $this->session->storyBrowseType != 'bysearch') ? $this->session->storyBrowseType : $browseType; /* Get stories by browseType. */ $stories = array(); diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index 2d2f202710..5a9fe6dcec 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -30,7 +30,12 @@ customMenu['featurebar'] as $type => $featurebar):?> + + +
  • inlink('browse', "productID=$productID&branch=$branch&browseType=bySearch¶m=$queryID"), $featurebar['link']);?>
  • +
  • inlink('browse', "productID=$productID&branch=$branch&browseType=$type"), $featurebar['link']);?>
  • +
  • product->searchStory;?>
  • @@ -79,7 +84,7 @@ moduleName . $this->methodName; $useDatatable = (isset($this->config->datatable->$datatableId->mode) and $this->config->datatable->$datatableId->mode == 'datatable'); - $vars = "productID=$productID&branch=$branch&browseType=$browseType¶m=$moduleID&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; + $vars = "productID=$productID&branch=$branch&browseType=$browseType¶m=$param&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; include $useDatatable ? dirname(__FILE__) . '/datatabledata.html.php' : dirname(__FILE__) . '/browsedata.html.php'; ?> @@ -254,7 +259,16 @@
    diff --git a/module/testcase/control.php b/module/testcase/control.php index e0245c59bd..df2232e667 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -95,8 +95,10 @@ class testcase extends control $cases = $this->loadModel('story')->checkNeedConfirm($cases); /* Build the search form. */ + $this->config->testcase->search['style'] = 'shortcut'; $actionURL = $this->createLink('testcase', 'browse', "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID"); $this->testcase->buildSearchForm($productID, $this->products, $queryID, $actionURL); + $this->loadModel('search')->mergeFeatureBar('testcase', 'browse'); $showModule = !empty($this->config->datatable->testcasebrowse->showModule) ? $this->config->datatable->testcasebrowse->showModule : ''; $this->view->modulePairs = $showModule ? $this->tree->getModulePairs($productID, 'case', $showModule) : array(); diff --git a/module/testcase/js/browse.js b/module/testcase/js/browse.js index 7b67fdf9ff..9bc4c3fc8c 100644 --- a/module/testcase/js/browse.js +++ b/module/testcase/js/browse.js @@ -23,8 +23,6 @@ function confirmBatchDelete(actionLink) $(document).ready(function() { - $('#' + caseBrowseType + 'Tab').addClass('active'); - $('#module' + moduleID).addClass('active'); if(browseType == 'bysearch') ajaxGetSearchForm(); setTimeout(function(){fixedTfootAction('#batchForm')}, 100); setTimeout(function(){fixedTheadOfList('#caseList')}, 100); diff --git a/module/testcase/model.php b/module/testcase/model.php index 28094d8c79..0c68609672 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -262,7 +262,7 @@ class testcaseModel extends model { /* 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; + $browseType = ($browseType == 'bymodule' and $this->session->caseBrowseType and $this->session->caseBrowseType != 'bysearch') ? $this->session->caseBrowseType : $browseType; /* By module or all cases. */ $cases = array(); diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index f7a4f1ba20..ba4206eaae 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -16,7 +16,7 @@ include '../../common/view/datepicker.html.php'; include '../../common/view/datatable.fix.html.php'; include './caseheader.html.php'; js::set('browseType', $browseType); -js::set('caseBrowseType', $this->session->caseBrowseType); +js::set('caseBrowseType', ($browseType == 'bymodule' and $this->session->caseBrowseType == 'bysearch') ? 'all' : $this->session->caseBrowseType); js::set('moduleID' , $moduleID); js::set('confirmDelete', $lang->testcase->confirmDelete); js::set('batchDelete', $lang->testcase->confirmBatchDelete); @@ -98,4 +98,17 @@ js::set('batchDelete', $lang->testcase->confirmBatchDelete);
    + diff --git a/module/testcase/view/caseheader.html.php b/module/testcase/view/caseheader.html.php index bb10d7233e..c95601d3b1 100644 --- a/module/testcase/view/caseheader.html.php +++ b/module/testcase/view/caseheader.html.php @@ -1,12 +1,11 @@
    '; } - elseif($type == 'zerocase' and common::hasPriv('story', 'zeroCase')) + elseif($hasZeroPriv and $type == 'zerocase') { echo "
  • " . html::a($this->createLink('story', 'zeroCase', "productID=$productID"), $lang->story->zeroCase) . '
  • '; } diff --git a/module/testtask/control.php b/module/testtask/control.php index 01dc4e72da..0f8e653d0a 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -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); diff --git a/module/testtask/js/cases.js b/module/testtask/js/cases.js index 8177f26650..0ca63241c5 100644 --- a/module/testtask/js/cases.js +++ b/module/testtask/js/cases.js @@ -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); }); diff --git a/module/testtask/model.php b/module/testtask/model.php index 97789258ac..9854b9d3c5 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -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. * diff --git a/module/testtask/view/caseheader.html.php b/module/testtask/view/caseheader.html.php index 6b9c4c5155..39c7646ea3 100644 --- a/module/testtask/view/caseheader.html.php +++ b/module/testtask/view/caseheader.html.php @@ -3,14 +3,36 @@ " . html::icon($lang->icons['usecase']) . '' . $task->name . '';?>