+ add the feature of search case.

This commit is contained in:
wangchunsheng
2010-01-09 03:12:53 +00:00
parent 13b1d0426d
commit 53620035db
6 changed files with 87 additions and 48 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
global $lang;
$config->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);
+36 -34
View File
@@ -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&param=$_POST[module]"), 'parent'));
die(js::locate($this->createLink('testcase', 'browse', "productID=$_POST[product]&browseType=byModule&param=$_POST[module]"), 'parent'));
}
if(empty($this->products)) $this->locate($this->createLink('product', 'create'));
+4 -1
View File
@@ -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';
+1 -1
View File
@@ -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);
}
}
+24 -11
View File
@@ -26,32 +26,45 @@
<?php include '../../common/treeview.html.php';?>
<?php include '../../common/colorize.html.php';?>
<script language='Javascript'>
/* 切换浏览方式。*/
/* 切换至按模块浏览。*/
function browseByModule(active)
{
$('#mainbox').addClass('yui-t7');
$('#treebox').removeClass('hidden');
$('#bymoduletab').addClass('active');
$('#' + active + 'tab').removeClass('active');
$('#bymoduleTab').addClass('active');
$('#' + active + 'Tab').removeClass('active');
$('#bysearchTab').removeClass('active');
}
/* 通过搜索方式。*/
function browseBySearch(active)
{
$('#mainbox').removeClass('yui-t7');
$('#treebox').addClass('hidden');
$('#querybox').removeClass('hidden');
$('#' + active + 'Tab').removeClass('active');
$('#bysearchTab').addClass('active');
$('#bymoduleTab').removeClass('active');
}
</script>
<div class='yui-d0'>
<div id='featurebar'>
<div class='f-left'>
<?php
echo "<span id='bymoduletab' onclick=\"browseByModule('$type')\">" . $lang->testcase->moduleCases . "</span> ";
echo "<span id='alltab'>" . html::a($this->createLink('testcase', 'browse', "productid=$productID&type=all&param=0"), $lang->testcase->allCases) . "</span>";
echo "<span id='bymoduleTab' onclick=\"browseByModule('$browseType')\">" . $lang->testcase->moduleCases . "</span> ";
echo "<span id='bysearchTab' onclick=\"browseBySearch('$browseType')\">{$lang->testcase->bySearch}</span> ";
echo "<span id='allTab'>" . html::a($this->createLink('testcase', 'browse', "productid=$productID&browseType=all&param=0&orderBy=$orderBy&recTotal=0&recPerPage=500"), $lang->testcase->allCases) . "</span>";
?>
</div>
<div class='f-right'>
<?php common::printLink('testcase', 'create', "productID=$productID&moduleID=$moduleID", $lang->testcase->create); ?>
</div>
</div>
<div id='querybox' class='<?php if($browseType != 'bysearch') echo 'hidden';?>'><?php echo $searchForm;?></div>
</div>
<div class='yui-d0 <?php if($type == 'bymodule') echo 'yui-t7';?>' id='mainbox'>
<div class='yui-b <?php if($type != 'bymodule') echo 'hidden';?>' id='treebox'>
<div class='yui-d0 <?php if($browseType == 'bymodule') echo 'yui-t7';?>' id='mainbox'>
<div class='yui-b <?php if($browseType != 'bymodule') echo 'hidden';?>' id='treebox'>
<div class='box-title'><?php echo $productName;?></div>
<div class='box-content'>
<?php echo $moduleTree;?>
@@ -64,7 +77,7 @@ function browseByModule(active)
<div class='yui-b'>
<table class='table-1 colored'>
<tr class='colhead'>
<?php $vars = "productID=$productID&type=$type&param=$param&orderBy=%s&recTotal=$recTotal&recPerPage=$recPerPage"; ?>
<?php $vars = "productID=$productID&browseType=$browseType&param=$param&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; ?>
<th><?php common::printOrderLink('id', $orderBy, $vars, $lang->testcase->id);?></th>
<th><?php common::printOrderLink('pri', $orderBy, $vars, $lang->testcase->pri);?></th>
<th><?php common::printOrderLink('title', $orderBy, $vars, $lang->testcase->title);?></th>
@@ -83,12 +96,12 @@ function browseByModule(active)
</tr>
<?php endforeach;?>
</table>
<div class='a-right'><?php echo $pager;?></div>
<?php $pager->show();?>
</div>
</div>
</div>
<script language="Javascript">
$("#<?php echo $type;?>tab").addClass('active');
$("#<?php echo $browseType;?>Tab").addClass('active');
$("#module<?php echo $moduleID;?>").addClass('active');
</script>
<?php include '../../common/footer.html.php';?>
+1 -1
View File
@@ -49,7 +49,7 @@ function loadStory(productID)
</script>
<form method='post'>
<form method='post' target='hiddenwin'>
<div class='yui-d0'>
<div id='titlebar'>
<div id='main'>