From 53620035dbd6ae20c3de8e071d5e38e55103e10f Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Sat, 9 Jan 2010 03:12:53 +0000 Subject: [PATCH] + add the feature of search case. --- module/testcase/config.php | 21 +++++++++ module/testcase/control.php | 70 ++++++++++++++-------------- module/testcase/lang/zh-cn.php | 5 +- module/testcase/model.php | 2 +- module/testcase/view/browse.html.php | 35 +++++++++----- module/testcase/view/edit.html.php | 2 +- 6 files changed, 87 insertions(+), 48 deletions(-) create mode 100644 module/testcase/config.php diff --git a/module/testcase/config.php b/module/testcase/config.php new file mode 100644 index 0000000000..ac6a9a37bc --- /dev/null +++ b/module/testcase/config.php @@ -0,0 +1,21 @@ +testcase->search['module'] = 'testcase'; +$config->testcase->search['fields']['id'] = $lang->testcase->id; +$config->testcase->search['fields']['title'] = $lang->testcase->title; +$config->testcase->search['fields']['product'] = $lang->testcase->product; +$config->testcase->search['fields']['openedBy'] = $lang->testcase->openedBy; +$config->testcase->search['fields']['lastEditedBy'] = $lang->testcase->lastEditedBy; +$config->testcase->search['fields']['status'] = $lang->testcase->status; +$config->testcase->search['fields']['pri'] = $lang->testcase->pri; +$config->testcase->search['fields']['type'] = $lang->testcase->type; +$config->testcase->search['fields']['openedDate'] = $lang->testcase->openedDate; +$config->testcase->search['fields']['lastEditedDate'] = $lang->testcase->lastEditedDate; + +$config->testcase->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->testcase->search['params']['product'] = array('operator' => '=', 'control' => 'select', 'values' => 'products'); +$config->testcase->search['params']['openedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); +$config->testcase->search['params']['lastEditedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); +$config->testcase->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->testcase->statusList); +$config->testcase->search['params']['pri'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->testcase->priList); +$config->testcase->search['params']['type'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->testcase->typeList); diff --git a/module/testcase/control.php b/module/testcase/control.php index d3bf0c69f9..b94129939e 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -32,8 +32,7 @@ class testcase extends control $this->loadModel('product'); $this->loadModel('tree'); $this->loadModel('user'); - $this->products = $this->product->getPairs(); - $this->assign('products', $this->products); + $this->view->products = $this->products = $this->product->getPairs(); } /* case首页。*/ @@ -43,47 +42,50 @@ class testcase extends control } /* 浏览一个产品下面的case。*/ - public function browse($productID = 0, $type = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function browse($productID = 0, $browseType = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { - if(empty($this->products)) $this->locate($this->createLink('product', 'create')); + /* 构造搜索表单。*/ + $this->config->testcase->search['actionURL'] = $this->createLink('testcase', 'browse', "productID=$productID&browseType=bySearch"); + $this->assign('searchForm', $this->fetch('search', 'buildForm', $this->config->testcase->search)); - $productID = (int)$productID; - if($productID == 0) $productID = key($this->products); + /* 设置浏览模式,产品ID和模块ID。 */ + $browseType = strtolower($browseType); + $productID = common::saveProductState($productID, key($this->products)); + $moduleID = ($browseType == 'bymodule') ? (int)$param : 0; - /* 设置菜单。*/ + /* 设置菜单,登记session。*/ $this->testcase->setMenu($this->products, $productID); + $this->session->set('caseList', $this->app->getURI(true)); - /* 设置模块ID。*/ - $type = strtolower($type); - $moduleID = ($type == 'bymodule') ? (int)$param : 0; + /* 加载分页类。*/ + $this->app->loadClass('pager', $static = true); + $pager = pager::init($recTotal, $recPerPage, $pageID); /* 如果是按照模块查找,或者列出所有。*/ - if($type == 'bymodule' or $type == 'all') + if($browseType == 'bymodule' or $browseType == 'all') { - $this->app->loadClass('pager', $static = true); - $pager = pager::init($recTotal, $recPerPage, $pageID); - $childModuleIds = $this->tree->getAllChildId($moduleID); - $cases = $this->testcase->getModuleCases($productID, $childModuleIds, $orderBy, $pager); + $childModuleIds = $this->tree->getAllChildId($moduleID); + $this->view->cases = $this->testcase->getModuleCases($productID, $childModuleIds, $orderBy, $pager); + } + elseif($browseType == 'bysearch') + { + if($this->session->testcaseQuery == false) $this->session->set('testcaseQuery', ' 1 = 1'); + $this->view->cases = $this->dao->select('*')->from(TABLE_CASE)->where($this->session->testcaseQuery)->orderBy($orderBy)->page($pager)->fetchAll(); } - - $header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->common; - $position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); - $position[] = $this->lang->testcase->common; - $this->assign('header', $header); - $this->assign('position', $position); - $this->assign('productID', $productID); - $this->assign('productName', $this->products[$productID]); - $this->assign('moduleTree', $this->tree->getTreeMenu($productID, $viewType = 'case', $rooteModuleID = 0, array('treeModel', 'createCaseLink'))); - $this->assign('type', $type); - $this->assign('cases', $cases); - $this->assign('pager', $pager->get()); - $this->assign('users', $this->user->getPairs($this->app->company->id, 'noletter')); - $this->assign('moduleID', $moduleID); - $this->assign('param', $param); - $this->assign('recTotal', $pager->recTotal); - $this->assign('recPerPage', $pager->recPerPage); - $this->assign('orderBy', $orderBy); + /* 赋值。*/ + $this->view->header->title = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->common; + $this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); + $this->view->position[] = $this->lang->testcase->common; + $this->view->productID = $productID; + $this->view->productName = $this->products[$productID]; + $this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'case', $rooteModuleID = 0, array('treeModel', 'createCaseLink')); + $this->view->moduleID = $moduleID; + $this->view->pager = $pager; + $this->view->users = $this->user->getPairs($this->app->company->id, 'noletter'); + $this->view->orderBy = $orderBy; + $this->view->browseType = $browseType; + $this->view->param = $param; $this->display(); } @@ -98,7 +100,7 @@ class testcase extends control if(dao::isError()) die(js::error(dao::getError())); $this->loadModel('action'); $this->action->create('case', $caseID, 'Opened'); - die(js::locate($this->createLink('testcase', 'browse', "productID=$_POST[product]&type=byModule¶m=$_POST[module]"), 'parent')); + die(js::locate($this->createLink('testcase', 'browse', "productID=$_POST[product]&browseType=byModule¶m=$_POST[module]"), 'parent')); } if(empty($this->products)) $this->locate($this->createLink('product', 'create')); diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php index 9cffdd5eea..0acade3572 100644 --- a/module/testcase/lang/zh-cn.php +++ b/module/testcase/lang/zh-cn.php @@ -55,7 +55,8 @@ $lang->testcase->byModule = '按模块'; $lang->testcase->assignToMe = '指派给我'; $lang->testcase->openedByMe = '由我创建'; $lang->testcase->allCases = '所有Case'; -$lang->testcase->moduleCases = '按模块浏览'; +$lang->testcase->moduleCases = '按模块浏览'; +$lang->testcase->bySearch = '搜索'; $lang->testcase->labProductAndModule = '产品模块'; $lang->testcase->labTypeAndPri = '类型&优先级'; @@ -103,9 +104,11 @@ $lang->testcase->browserList->opera9 = 'opera9'; $lang->testcase->browserList->oprea10 = '其他'; /* Define the types. */ +$lang->testcase->typeList[''] = ''; $lang->testcase->typeList['feature'] = '功能测试'; $lang->testcase->typeList['performance'] = '性能测试'; +$lang->testcase->statusList[''] = ''; $lang->testcase->statusList['normal'] = '正常'; $lang->testcase->statusList['blocked'] = 'Blocked'; diff --git a/module/testcase/model.php b/module/testcase/model.php index 2a0f7ac051..9f6d72b523 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -80,7 +80,7 @@ class testcaseModel extends model ->specialChars('steps') ->remove('comment') ->get(); - $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->check('title', 'notempty')->where('id')->eq((int)$caseID)->exec(); + $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck('title,status,type', 'notempty')->where('id')->eq((int)$caseID)->exec(); if(!dao::isError()) return common::createChanges($oldCase, $case); } } diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index ab4b3a21c6..ac6b7f6e2e 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -26,32 +26,45 @@ -
" . $lang->testcase->moduleCases . " "; - echo "" . html::a($this->createLink('testcase', 'browse', "productid=$productID&type=all¶m=0"), $lang->testcase->allCases) . ""; + echo "" . $lang->testcase->moduleCases . " "; + echo "{$lang->testcase->bySearch} "; + echo "" . html::a($this->createLink('testcase', 'browse', "productid=$productID&browseType=all¶m=0&orderBy=$orderBy&recTotal=0&recPerPage=500"), $lang->testcase->allCases) . ""; ?>
testcase->create); ?>
+
'>
-
' id='mainbox'> -
' id='treebox'> +
' id='mainbox'> +
' id='treebox'>
@@ -64,7 +77,7 @@ function browseByModule(active)
- + recTotal}&recPerPage={$pager->recPerPage}"; ?> @@ -83,12 +96,12 @@ function browseByModule(active)
testcase->id);?> testcase->pri);?> testcase->title);?>
-
+ show();?>
diff --git a/module/testcase/view/edit.html.php b/module/testcase/view/edit.html.php index 1e6fdb3d8c..22ac5a7cd2 100644 --- a/module/testcase/view/edit.html.php +++ b/module/testcase/view/edit.html.php @@ -49,7 +49,7 @@ function loadStory(productID) -
+