* code for task#933.
* move caseBatchEdit for open source version to pro version.
This commit is contained in:
@@ -3,5 +3,10 @@ INSERT INTO `zt_groupPriv` (`company`, `group`, `module`, `method`) VALUES
|
||||
(1, 2, 'bug', 'batchEdit'),
|
||||
(1, 3, 'bug', 'batchEdit'),
|
||||
(1, 4, 'bug', 'batchEdit'),
|
||||
(1, 5, 'bug', 'batchEdit');
|
||||
(1, 5, 'bug', 'batchEdit'),
|
||||
(1, 1, 'testcase', 'batchEdit'),
|
||||
(1, 2, 'testcase', 'batchEdit'),
|
||||
(1, 3, 'testcase', 'batchEdit'),
|
||||
(1, 4, 'testcase', 'batchEdit'),
|
||||
(1, 5, 'testcase', 'batchEdit');
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ $lang->bug->menu->testtask = array('link' => 'Test Task|testtask|browse|productI
|
||||
|
||||
$lang->testcase->menu->product = '%s';
|
||||
$lang->testcase->menu->bug = array('link' => 'Bug|bug|browse|productID=%s');
|
||||
$lang->testcase->menu->testcase = array('link' => 'Test Case|testcase|browse|productID=%s', 'alias' => 'view,create,batchcreate,edit', 'subModule' => 'tree');
|
||||
$lang->testcase->menu->testcase = array('link' => 'Test Case|testcase|browse|productID=%s', 'alias' => 'view,create,batchcreate,edit,batchedit', 'subModule' => 'tree');
|
||||
$lang->testcase->menu->testtask = array('link' => 'Test Task|testtask|browse|productID=%s', 'alias' => 'view,create,edit,linkcase,cases');
|
||||
$lang->testtask->menu = $lang->testcase->menu;
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ $lang->bug->menu->testtask = array('link' => '测试任务|testtask|browse|produ
|
||||
|
||||
$lang->testcase->menu->product = '%s';
|
||||
$lang->testcase->menu->bug = array('link' => '缺陷管理|bug|browse|productID=%s');
|
||||
$lang->testcase->menu->testcase = array('link' => '用例管理|testcase|browse|productID=%s', 'alias' => 'view,create,batchcreate,edit', 'subModule' => 'tree');
|
||||
$lang->testcase->menu->testcase = array('link' => '用例管理|testcase|browse|productID=%s', 'alias' => 'view,create,batchcreate,edit,batchedit', 'subModule' => 'tree');
|
||||
$lang->testcase->menu->testtask = array('link' => '测试任务|testtask|browse|productID=%s', 'alias' => 'view,create,edit,linkcase,cases');
|
||||
$lang->testtask->menu = $lang->testcase->menu;
|
||||
|
||||
|
||||
@@ -365,6 +365,7 @@ $lang->resource->testcase->create = 'create';
|
||||
$lang->resource->testcase->batchCreate = 'batchCreate';
|
||||
$lang->resource->testcase->view = 'view';
|
||||
$lang->resource->testcase->edit = 'edit';
|
||||
$lang->resource->testcase->batchEdit = 'batchEdit';
|
||||
$lang->resource->testcase->delete = 'delete';
|
||||
$lang->resource->testcase->export = 'export';
|
||||
$lang->resource->testcase->confirmStoryChange = 'confirmStoryChange';
|
||||
|
||||
@@ -398,6 +398,74 @@ class testcase extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch edit case.
|
||||
*
|
||||
* @param string $from example:testcaseBrowse,testtaskCases,testcaseBatchEdit
|
||||
* @param int $productID
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function batchEdit($from = '', $productID = 0, $orderBy = '')
|
||||
{
|
||||
if($from == 'testcaseBrowse' or $from == 'testtaskCases')
|
||||
{
|
||||
/* Init vars. */
|
||||
$orderBy = $orderBy ? $orderBy : 'id_desc';
|
||||
$caseIDList = $this->post->caseIDList ? $this->post->caseIDList : array();
|
||||
$product = $this->product->getByID($productID);
|
||||
$editedCases = array();
|
||||
$columns = 7;
|
||||
$showSuhosinInfo = false;
|
||||
|
||||
/* Get all cases. */
|
||||
$allCases = $this->dao->select('*')->from(TABLE_CASE)->alias('t1')->where($this->session->testcaseQueryCondition)->orderBy($orderBy)->fetchAll('id');
|
||||
|
||||
/* Set product menu. */
|
||||
$this->testcase->setMenu($this->products, $productID);
|
||||
|
||||
/* Initialize the cases whose need to edited. */
|
||||
foreach($allCases as $case) if(in_array($case->id, $caseIDList)) $editedCases[$case->id] = $case;
|
||||
|
||||
/* Judge whether the editedTasks is too large. */
|
||||
$showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($editedCases), $columns);
|
||||
|
||||
/* Set the sessions. */
|
||||
$this->app->session->set('showSuhosinInfo', $showSuhosinInfo);
|
||||
|
||||
/* Assign. */
|
||||
$this->view->header['title'] = $product->name . $this->lang->colon . $this->lang->testcase->batchEdit;
|
||||
$this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]);
|
||||
$this->view->position[] = $this->lang->testcase->common;
|
||||
$this->view->position[] = $this->lang->testcase->batchEdit;
|
||||
|
||||
if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo;
|
||||
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0);
|
||||
$this->view->productID = $productID;
|
||||
$this->view->editedCases = $editedCases;
|
||||
$this->view->users = $this->user->getPairs('noletter');
|
||||
|
||||
$this->display();
|
||||
}
|
||||
elseif($from == 'testcaseBatchEdit')
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$allChanges = $this->testcase->batchUpdate();
|
||||
if($allChanges)
|
||||
{
|
||||
foreach($allChanges as $caseID => $changes )
|
||||
{
|
||||
$actionID = $this->loadModel('action')->create('case', $caseID, 'Edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
}
|
||||
}
|
||||
die(js::locate($this->session->caseList, 'parent'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a test case
|
||||
*
|
||||
|
||||
@@ -54,6 +54,7 @@ $lang->testcase->batchCreate = "Batch create";
|
||||
$lang->testcase->delete = "Delete";
|
||||
$lang->testcase->view = "Info";
|
||||
$lang->testcase->edit = "Edit";
|
||||
$lang->testcase->batchEdit = "Batch edit";
|
||||
$lang->testcase->delete = "Delete";
|
||||
$lang->testcase->browse = "Browse";
|
||||
$lang->testcase->import = "Import";
|
||||
|
||||
@@ -54,6 +54,7 @@ $lang->testcase->batchCreate = "批量添加";
|
||||
$lang->testcase->delete = "删除用例";
|
||||
$lang->testcase->view = "用例详情";
|
||||
$lang->testcase->edit = "编辑";
|
||||
$lang->testcase->batchEdit = "批量编辑 ";
|
||||
$lang->testcase->delete = "删除";
|
||||
$lang->testcase->browse = "用例列表";
|
||||
$lang->testcase->import = "导入用例";
|
||||
|
||||
@@ -250,6 +250,66 @@ class testcaseModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch update testcases.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchUpdate()
|
||||
{
|
||||
$cases = array();
|
||||
$allChanges = array();
|
||||
$now = helper::now();
|
||||
$caseIDList = $this->post->caseIDList ? $this->post->caseIDList : array();
|
||||
|
||||
/* Adjust whether the post data is complete, if not, remove the last element of $caseIDList. */
|
||||
if($this->session->showSuhosinInfo) array_pop($caseIDList);
|
||||
|
||||
if(!empty($caseIDList))
|
||||
{
|
||||
/* Initialize cases from the post data.*/
|
||||
foreach($caseIDList as $caseID)
|
||||
{
|
||||
$case->lastEditedBy = $this->app->user->account;
|
||||
$caee->lastEditedDate = $now;
|
||||
$case->pri = $this->post->pris[$caseID];
|
||||
$case->status = $this->post->statuses[$caseID];
|
||||
$case->module = $this->post->modules[$caseID];
|
||||
$case->title = htmlspecialchars($this->post->titles[$caseID]);
|
||||
$case->type = $this->post->types[$caseID];
|
||||
$case->stage = implode(',', $this->post->stages[$caseID]);
|
||||
|
||||
$cases[$caseID] = $case;
|
||||
unset($case);
|
||||
}
|
||||
|
||||
/* Update cases. */
|
||||
foreach($cases as $caseID => $case)
|
||||
{
|
||||
$oldCase = $this->getByID($caseID);
|
||||
$this->dao->update(TABLE_CASE)->data($case)
|
||||
->autoCheck()
|
||||
->batchCheck($this->config->testcase->edit->requiredFields, 'notempty')
|
||||
->where('id')->eq($caseID)
|
||||
->exec();
|
||||
|
||||
if(!dao::isError())
|
||||
{
|
||||
unset($oldCase->steps);
|
||||
$allChanges[$caseID] = common::createChanges($oldCase, $case);
|
||||
}
|
||||
else
|
||||
{
|
||||
die(js::error('case#' . $caseID . dao::getError(true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $allChanges;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Join steps to a string, thus can diff them.
|
||||
*
|
||||
|
||||
57
module/testcase/view/batchedit.html.php
Normal file
57
module/testcase/view/batchedit.html.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* The batch edit view of testcase module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author Congzhi Chen <congzhi@cnezsoft.com>
|
||||
* @package testcase
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<form method='post' target='hiddenwin' action="<?php echo $this->inLink('batchEdit', "from=testcaseBatchEdit");?>">
|
||||
<table class='table-1 fixed'>
|
||||
<caption><?php echo $lang->testcase->common . $lang->colon . $lang->testcase->batchEdit;?></caption>
|
||||
<tr>
|
||||
<th class='w-30px'><?php echo $lang->idAB;?></th>
|
||||
<th class='w-50px'><?php echo $lang->priAB;?></th>
|
||||
<th class='w-70px'><?php echo $lang->statusAB;?></th>
|
||||
<th class='w-140px'><?php echo $lang->testcase->module;?></th>
|
||||
<th><?php echo $lang->testcase->title;?></th>
|
||||
<th class='w-100px'><?php echo $lang->testcase->type;?></th>
|
||||
<th class='w-340px'><?php echo $lang->testcase->stage;?></th>
|
||||
</tr>
|
||||
<?php foreach($editedCases as $case):?>
|
||||
<tr class='a-center'>
|
||||
<td><?php echo $case->id . html::hidden("caseIDList[$case->id]", $case->id);?></td>
|
||||
<td><?php echo html::select("pris[$case->id]", $lang->testcase->priList, $case->pri, 'class=select-1');?></td>
|
||||
<td><?php echo html::select("statuses[$case->id]", (array)$lang->testcase->statusList, $case->status, 'class=select-1');?></td>
|
||||
<td><?php echo html::select("modules[$case->id]", $moduleOptionMenu, $case->module, "class='select-1'");?></span></td>
|
||||
<td><?php echo html::input("titles[$case->id]", $case->title, 'class=text-1'); echo "<span class='star'>*</span>";?></td>
|
||||
<td><?php echo html::select("types[$case->id]", $lang->testcase->typeList, $case->type, 'class=select-1');?></td>
|
||||
<td>
|
||||
<?php
|
||||
foreach($lang->testcase->stageListAB as $key => $stage)
|
||||
{
|
||||
if(in_array($key, explode(',', $case->stage)))
|
||||
{
|
||||
echo "<input type='checkbox' name='stages[$case->id][$key]' checked='checked' value='$key'/>$stage ";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<input type='checkbox' name='stages[$case->id][$key]' value='$key'/>$stage ";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<?php if(isset($suhosinInfo)):?>
|
||||
<tr><td colspan='7'><div class='f-left blue'><?php echo $suhosinInfo;?></div></td></tr>
|
||||
<?php endif;?>
|
||||
<tr><td colspan='7' class='a-center'><?php echo html::submitButton();?></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -74,7 +74,10 @@ var moduleID = '<?php echo $moduleID;?>';
|
||||
<?php foreach($cases as $case):?>
|
||||
<tr class='a-center'>
|
||||
<?php $viewLink = inlink('view', "caseID=$case->id");?>
|
||||
<td><?php echo html::a($viewLink, sprintf('%03d', $case->id));?></td>
|
||||
<td>
|
||||
<input type='checkbox' name='caseIDList[]' value='<?php echo $case->id;?>'/>
|
||||
<?php echo html::a($viewLink, sprintf('%03d', $case->id));?>
|
||||
</td>
|
||||
<td><span class='<?php echo 'pri' . $case->pri?>'><?php echo $case->pri?></span></td>
|
||||
<td class='a-left nobr'><?php echo html::a($viewLink, $case->title);?></td>
|
||||
<?php if($browseType == 'needconfirm'):?>
|
||||
@@ -101,7 +104,18 @@ var moduleID = '<?php echo $moduleID;?>';
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</thead>
|
||||
<tfoot><tr><td colspan='10'><?php $pager->show();?></td></tr></tfoot>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan='10'>
|
||||
<div class='f-left'>
|
||||
<?php
|
||||
if(common::hasPriv('testcase', 'batchEdit')) echo html::selectAll() . html::selectReverse(). html::submitButton($lang->testcase->batchEdit);
|
||||
?>
|
||||
</div>
|
||||
<?php $pager->show();?>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -87,7 +87,12 @@ var moduleID = '<?php echo $moduleID;?>';
|
||||
<tr>
|
||||
<td colspan='10'>
|
||||
<div class='f-left'>
|
||||
<?php echo html::selectAll() . html::selectReverse(); ?>
|
||||
<?php
|
||||
echo html::selectAll() . html::selectReverse();
|
||||
if(common::hasPriv('testcase', 'batchEdit')):
|
||||
?>
|
||||
<input class='button-s' value="<?php echo $lang->testcase->batchEdit; ?>" type="button" onclick="casesform.action='<?php echo $this->createLink('testcase', 'batchEdit', "from=testtaskCases&productID=$productID");?>';casesform.submit();">
|
||||
<?php endif;?>
|
||||
<?php if(common::hasPriv('testtask', 'batchAssign')):?>
|
||||
<?php echo html::select('assignedTo', $users);?>
|
||||
<input class='button-s' value="<?php echo $lang->testtask->batchAssign; ?>" type="button" onclick="casesform.action='<?php echo $this->inLink('batchAssign', "taskID=$task->id");?>';casesform.submit();">
|
||||
|
||||
Reference in New Issue
Block a user