* code for task#1562.
* refactory the testcase-batchEdit.
This commit is contained in:
+22
-19
@@ -1,4 +1,26 @@
|
||||
<?php
|
||||
$config->testcase->defaultSteps = 3;
|
||||
$config->testcase->batchCreate = 10;
|
||||
|
||||
$config->testcase->create = new stdclass();
|
||||
$config->testcase->edit = new stdclass();
|
||||
$config->testcase->create->requiredFields = 'title,type';
|
||||
$config->testcase->edit->requiredFields = 'title,type';
|
||||
|
||||
$config->testcase->batchEdit = new stdclass();
|
||||
$config->testcase->batchEdit->columns = 7;
|
||||
|
||||
$config->testcase->editor = new stdclass();
|
||||
$config->testcase->editor->edit = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
$config->testcase->editor->view = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
|
||||
$config->testcase->exportFields = '
|
||||
id, product, module, story,
|
||||
title, precondition, stepDesc, stepExpect, keywords,
|
||||
pri, type, stage, status, frequency,
|
||||
openedBy, openedDate, lastEditedBy, lastEditedDate,
|
||||
version,linkCase';
|
||||
|
||||
global $lang;
|
||||
$config->testcase->search['module'] = 'testcase';
|
||||
$config->testcase->search['fields']['title'] = $lang->testcase->title;
|
||||
@@ -31,22 +53,3 @@ $config->testcase->search['params']['stage'] = array('operator' => 'inclu
|
||||
|
||||
$config->testcase->search['params']['openedDate'] = array('operator' => '>=', 'control' => 'input', 'values' => '', 'class' => 'date');
|
||||
$config->testcase->search['params']['lastEditedDate'] = array('operator' => '>=', 'control' => 'input', 'values' => '', 'class' => 'date');
|
||||
|
||||
$config->testcase->defaultSteps = 3;
|
||||
$config->testcase->batchCreate = 10;
|
||||
|
||||
$config->testcase->create = new stdclass();
|
||||
$config->testcase->edit = new stdclass();
|
||||
$config->testcase->create->requiredFields = 'title,type';
|
||||
$config->testcase->edit->requiredFields = 'title,type';
|
||||
|
||||
$config->testcase->editor = new stdclass();
|
||||
$config->testcase->editor->edit = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
$config->testcase->editor->view = array('id' => 'comment', 'tools' => 'simpleTools');
|
||||
|
||||
$config->testcase->exportFields = '
|
||||
id, product, module, story,
|
||||
title, precondition, stepDesc, stepExpect, keywords,
|
||||
pri, type, stage, status, frequency,
|
||||
openedBy, openedDate, lastEditedBy, lastEditedDate,
|
||||
version,linkCase';
|
||||
|
||||
+36
-51
@@ -418,69 +418,54 @@ class testcase extends control
|
||||
/**
|
||||
* 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 = '')
|
||||
public function batchEdit($productID = 0)
|
||||
{
|
||||
if($from == 'testcaseBrowse' or $from == 'testtaskCases')
|
||||
if($this->post->titles)
|
||||
{
|
||||
/* 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)->where('id')->in($caseIDList)->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->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->display();
|
||||
}
|
||||
elseif($from == 'testcaseBatchEdit')
|
||||
{
|
||||
if(!empty($_POST))
|
||||
$allChanges = $this->testcase->batchUpdate();
|
||||
if($allChanges)
|
||||
{
|
||||
$allChanges = $this->testcase->batchUpdate();
|
||||
if($allChanges)
|
||||
foreach($allChanges as $caseID => $changes )
|
||||
{
|
||||
foreach($allChanges as $caseID => $changes )
|
||||
{
|
||||
$actionID = $this->loadModel('action')->create('case', $caseID, 'Edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
$actionID = $this->loadModel('action')->create('case', $caseID, 'Edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
}
|
||||
|
||||
die(js::locate($this->session->caseList, 'parent'));
|
||||
}
|
||||
}
|
||||
/* Init vars. */
|
||||
$caseIDList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList, 'parent'));
|
||||
$product = $this->product->getByID($productID);
|
||||
|
||||
/* Get all cases. */
|
||||
$cases = $this->dao->select('*')->from(TABLE_CASE)->where('id')->in($caseIDList)->fetchAll('id');
|
||||
|
||||
/* Set product menu. */
|
||||
$this->testcase->setMenu($this->products, $productID);
|
||||
|
||||
/* Judge whether the editedTasks is too large and set session. */
|
||||
$showSuhosinInfo = false;
|
||||
$showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($cases), $this->config->testcase->batchEdit->columns);
|
||||
$this->app->session->set('showSuhosinInfo', $showSuhosinInfo);
|
||||
if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo;
|
||||
|
||||
/* Assign. */
|
||||
$this->view->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;
|
||||
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0);
|
||||
$this->view->caseIDList = $caseIDList;
|
||||
$this->view->productID = $productID;
|
||||
$this->view->cases = $cases;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a test case
|
||||
|
||||
+31
-34
@@ -275,48 +275,45 @@ class testcaseModel extends model
|
||||
$cases = array();
|
||||
$allChanges = array();
|
||||
$now = helper::now();
|
||||
$caseIDList = $this->post->caseIDList ? $this->post->caseIDList : array();
|
||||
$caseIDList = $this->post->caseIDList;
|
||||
|
||||
/* 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)
|
||||
{
|
||||
/* 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]);
|
||||
$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);
|
||||
$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);
|
||||
}
|
||||
|
||||
/* Update cases. */
|
||||
foreach($cases as $caseID => $case)
|
||||
else
|
||||
{
|
||||
$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)));
|
||||
}
|
||||
die(js::error('case#' . $caseID . dao::getError(true)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<form method='post' target='hiddenwin' action="<?php echo $this->inLink('batchEdit', "from=testcaseBatchEdit");?>">
|
||||
<form method='post' target='hiddenwin' action="<?php echo $this->inLink('batchEdit');?>">
|
||||
<table class='table-1 fixed'>
|
||||
<caption><?php echo $lang->testcase->common . $lang->colon . $lang->testcase->batchEdit;?></caption>
|
||||
<tr>
|
||||
@@ -23,25 +23,25 @@
|
||||
<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):?>
|
||||
<?php foreach($caseIDList as $caseID):?>
|
||||
<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 echo $caseID . html::hidden("caseIDList[$caseID]", $caseID);?></td>
|
||||
<td><?php echo html::select("pris[$caseID]", $lang->testcase->priList, $cases[$caseID]->pri, 'class=select-1');?></td>
|
||||
<td><?php echo html::select("statuses[$caseID]", (array)$lang->testcase->statusList, $cases[$caseID]->status, 'class=select-1');?></td>
|
||||
<td><?php echo html::select("modules[$caseID]", $moduleOptionMenu, $cases[$caseID]->module, "class='select-1'");?></span></td>
|
||||
<td><?php echo html::input("titles[$caseID]", $cases[$caseID]->title, 'class=text-1'); echo "<span class='star'>*</span>";?></td>
|
||||
<td><?php echo html::select("types[$caseID]", $lang->testcase->typeList, $cases[$caseID]->type, 'class=select-1');?></td>
|
||||
<td>
|
||||
<?php
|
||||
foreach($lang->testcase->stageListAB as $key => $stage)
|
||||
{
|
||||
if(in_array($key, explode(',', $case->stage)))
|
||||
if(in_array($key, explode(',', $cases[$caseID]->stage)))
|
||||
{
|
||||
echo "<input type='checkbox' name='stages[$case->id][$key]' checked='checked' value='$key'/>$stage ";
|
||||
echo "<input type='checkbox' name='stages[$caseID][$key]' checked='checked' value='$key'/>$stage ";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<input type='checkbox' name='stages[$case->id][$key]' value='$key'/>$stage ";
|
||||
echo "<input type='checkbox' name='stages[$caseID][$key]' value='$key'/>$stage ";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -49,9 +49,9 @@
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<?php if(isset($suhosinInfo)):?>
|
||||
<tr><td colspan='7'><div class='f-left blue'><?php echo $suhosinInfo;?></div></td></tr>
|
||||
<tr><td colspan='<?php echo $this->config->testcase->batchEdit->columns;?>'><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>
|
||||
<tr><td colspan='<?php echo $this->config->testcase->batchEdit->columns;?>' class='a-center'><?php echo html::submitButton();?></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -50,7 +50,7 @@ js::set('moduleID' , $moduleID);
|
||||
</td>
|
||||
<td class='divider <?php echo $treeClass;?>'></td>
|
||||
<td>
|
||||
<form id='batchForm' method='post' action='<?php echo inLink('batchEdit', "from=testcaseBrowse&productID=$productID&orderBy=$orderBy");?>'>
|
||||
<form id='batchForm' method='post'>
|
||||
<?php include 'caselist.html.php';?>
|
||||
</form>
|
||||
</td>
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<div class='f-left'>
|
||||
<?php
|
||||
if($canBatchEdit or $canBatchClose) echo html::selectAll() . html::selectReverse();
|
||||
if($canBatchEdit) echo html::submitButton($lang->edit, "onclick='changeAction(\"" . inLink('batchEdit', "from=testcaseBrowse&productID=$productID&orderBy=$orderBy") . "\")'");
|
||||
if($canBatchEdit) echo html::submitButton($lang->edit, "onclick='changeAction(\"" . inLink('batchEdit', "productID=$productID") . "\")'");
|
||||
if($canBatchClose) echo html::submitButton($lang->testtask->runCase, "onclick='changeAction(\"" . $this->createLink('testtask', 'batchRun', "productID=$productID&orderBy=$orderBy") . "\")'");
|
||||
?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user