* Code for task #5267.

This commit is contained in:
Yagami
2019-02-26 14:06:07 +08:00
parent b9b7fbdceb
commit c31b04da67
6 changed files with 51 additions and 46 deletions
+4 -4
View File
@@ -293,7 +293,7 @@
{
if(!isset($projects[$task->project])) continue;
$projectName = $projects[$task->project];
echo "<li title='$task->name'>" . html::a($this->createLink('task', 'view', "taskID=$task->id", '', true), "#$task->id $task->name", '', "class='iframe' data-width='80%'");
echo "<li title='$task->name'>" . html::a($this->createLink('task', 'view', "taskID=$task->id", '', true), "[T]$task->id $task->name", '', "class='iframe' data-width='80%'");
echo html::a($this->createLink('project', 'browse', "projectID=$task->project"), $projectName, '', "class='text-muted'") . '</li>';
}
}
@@ -329,7 +329,7 @@
<?php
foreach($bugs as $bug)
{
echo "<li title='#$bug->id $bug->title'>" . html::a($this->createLink('bug', 'view', "bugID=$bug->id", '', true), "#$bug->id $bug->title", '', "class='iframe' data-width='80%'") . '</li>';
echo "<li title='[B]$bug->id $bug->title'>" . html::a($this->createLink('bug', 'view', "bugID=$bug->id", '', true), "[B]$bug->id $bug->title", '', "class='iframe' data-width='80%'") . '</li>';
}
?>
</ul>
@@ -342,7 +342,7 @@
<?php
foreach($cases as $case)
{
echo "<li title='#$case->id $case->title'>" . html::a($this->createLink('testcase', 'view', "caseID=$case->id", '', true), "#$case->id $case->title", '', "class='iframe' data-width='80%'") . '</li>';
echo "<li title='[C]$case->id $case->title'>" . html::a($this->createLink('testcase', 'view', "caseID=$case->id", '', true), "[C]$case->id $case->title", '', "class='iframe' data-width='80%'") . '</li>';
}
?>
</ul>
@@ -357,7 +357,7 @@
$linkStories = explode(',', $story->linkStories) ;
foreach($linkStories as $linkStoryID)
{
if(isset($story->extraStories[$linkStoryID])) echo '<li>' . html::a($this->createLink('story', 'view', "storyID=$linkStoryID", '', true), "#$linkStoryID " . $story->extraStories[$linkStoryID], '', "class='iframe' data-width='80%'") . '</li>';
if(isset($story->extraStories[$linkStoryID])) echo '<li>' . html::a($this->createLink('story', 'view', "storyID=$linkStoryID", '', true), "[S]$linkStoryID " . $story->extraStories[$linkStoryID], '', "class='iframe' data-width='80%'") . '</li>';
}
?>
</ul>
+19 -4
View File
@@ -546,9 +546,19 @@ class testcase extends control
* @access public
* @return void
*/
public function edit($caseID, $comment = false)
public function edit($caseID, $comment = false, $confirm = 'no')
{
$this->loadModel('story');
$case = $this->testcase->getById($caseID);
$isLibCase = ($case->lib and empty($case->product));
if($confirm == 'yes')
{
$linkedCaseID = '';
if($isLibCase) $linkedCaseID = $this->dao->select('id')->from(TABLE_CASE)->where('fromCaseID')->eq($caseID)->fetchPairs();
if(!empty($linkedCaseID)) $this->testcase->updateLinkedCases($linkedCaseID, $case->steps);
die(js::locate($this->createLink('testcase', 'view', "caseID=$caseID"), 'parent'));
}
if(!empty($_POST))
{
@@ -569,10 +579,17 @@ class testcase extends control
$actionID = $this->action->create('case', $caseID, $action, $fileAction . $this->post->comment);
$this->action->logHistory($actionID, $changes);
}
$stepChanged = false;
foreach($changes as $change)
{
if($change['field'] == 'version') $stepChanged = true;
}
if($isLibCase and $stepChanged) die(js::confirm($this->lang->testcase->haveLinkCase, inlink('edit', "caseID=$caseID&comment=&confirm=yes"), inlink('view', "caseID=$caseID"), 'parent', 'parent'));
die(js::locate($this->createLink('testcase', 'view', "caseID=$caseID"), 'parent'));
}
$case = $this->testcase->getById($caseID);
if(empty($case->steps))
{
$step = new stdclass();
@@ -582,7 +599,6 @@ class testcase extends control
$case->steps[] = $step;
}
$isLibCase = ($case->lib and empty($case->product));
if($isLibCase)
{
$libraries = $this->loadModel('testsuite')->getLibraries();
@@ -596,7 +612,6 @@ class testcase extends control
$this->view->libID = $case->lib;
$this->view->libName = $libraries[$case->lib];
$this->view->libraries = $libraries;
$this->view->linkedCaseID = $this->testcase->getLinkedCaseID($case->lib, $caseID);
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($case->lib, $viewType = 'caselib', $startModuleID = 0);
}
else
+1 -1
View File
@@ -139,7 +139,7 @@ $lang->testcase->confirmDelete = 'Do you want to delete this Test Case?';
$lang->testcase->confirmBatchDelete = 'Do you want to batch delete these Test Cases?';
$lang->testcase->ditto = 'Ditto';
$lang->testcase->dittoNotice = 'This Case does not belong to the Product as the previous one!';
$lang->testcase->haveLinkCase = 'It has linked case, update this one, the linked case will change.';
$lang->testcase->haveLinkCase = 'It has linked cases. Confirm it first and linked cases will be updated.';
$lang->testcase->reviewList[0] = 'NO';
$lang->testcase->reviewList[1] = 'YES';
+1 -1
View File
@@ -139,7 +139,7 @@ $lang->testcase->confirmDelete = '您确认要删除该测试用例吗?';
$lang->testcase->confirmBatchDelete = '您确认要批量删除这些测试用例吗?';
$lang->testcase->ditto = '同上';
$lang->testcase->dittoNotice = '该用例与上一用例不属于同一产品!';
$lang->testcase->haveLinkCase = '此用例存在相关用例,更新后,其相关用例会一并更新。';
$lang->testcase->haveLinkCase = '此用例存在相关用例,确认后,其相关用例会一并更新。';
$lang->testcase->reviewList[0] = '否';
$lang->testcase->reviewList[1] = '是';
+26 -35
View File
@@ -604,24 +604,6 @@ class testcaseModel extends model
return $caseCounts;
}
/**
* Check have linked cases or not.
*
* @param int $libID
* @param int $caseID$
* @access public
* @return int
*/
public function getLinkedCaseID($libID, $caseID)
{
$linkedCaseID = $this->dao->select('id')->from(TABLE_CASE)
->where('lib')->eq($libID)
->andWhere('fromCaseID')->eq($caseID)
->andWhere('deleted')->eq(0)
->fetch('id');
return $linkedCaseID;
}
/**
* Update a case.
*
@@ -631,10 +613,7 @@ class testcaseModel extends model
*/
public function update($caseID)
{
$oldCase = $this->getById($caseID);
$isLibCase = ($oldCase->lib and empty($oldCase->product));
$linkedCases = '';
if($isLibCase) $linkedCases = $this->dao->select('id')->from(TABLE_CASE)->where('fromCaseID')->eq($caseID)->fetchPairs();
$oldCase = $this->getById($caseID);
if(!empty($_POST['lastEditedDate']) and $oldCase->lastEditedDate != $this->post->lastEditedDate)
{
dao::$errors[] = $this->lang->error->editedByOther;
@@ -687,10 +666,6 @@ class testcaseModel extends model
->get();
if(!$this->forceNotReview() and $stepChanged) $case->status = 'wait';
$this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->edit->requiredFields, 'notempty')->where('id')->eq((int)$caseID)->exec();
if($isLibCase and $linkedCases)
{
foreach($linkedCases as $linkedCaseID) $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->edit->requiredFields, 'notempty')->where('id')->eq((int)$linkedCaseID)->exec();
}
if(!$this->dao->isError())
{
if($stepChanged)
@@ -710,15 +685,6 @@ class testcaseModel extends model
$this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec();
if($step->type == 'group') $parentStepID = $this->dao->lastInsertID();
if($step->type == 'step') $parentStepID = 0;
if($isLibCase and $linkedCases)
{
foreach($linkedCases as $linkedCaseID)
{
$step->case = $linkedCaseID;
$this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec();
}
}
}
}
@@ -736,6 +702,31 @@ class testcaseModel extends model
}
}
/**
* Update linked case.
*
* @param int $linkedCaseID
* @param object $steps
* @access public
* @return bool
*/
public function updateLinkedCases($linkedCaseID, $steps)
{
foreach($linkedCaseID as $caseID)
{
$version = $this->dao->findByID($caseID)->from(TABLE_CASE)->fetch('version');
$version = $version + 1;
foreach($steps as $step)
{
unset($step->id);
$step->case = $caseID;
$step->version = $version;
$this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec();
}
$this->dao->update(TABLE_CASE)->set('version')->eq($version)->where('id')->eq($caseID)->exec();
}
}
/**
* Review case
*
-1
View File
@@ -125,7 +125,6 @@
<?php echo html::hidden('lastEditedDate', $case->lastEditedDate);?>
<?php echo html::submitButton();?>
<input type='button' value='<?php echo $lang->testcase->buttonToList;?>' class='btn btn-wide' onclick='location.href="<?php echo $isLibCase ? $this->createLink('testsuite', 'library', "libID=$libID") : $this->createLink('testcase', 'browse', "productID=$productID");?>"' />
<?php if($isLibCase and $linkedCaseID) echo '<span class="text-danger">' . $lang->testcase->haveLinkCase . '</span>'; ?>
</div>
<?php include '../../common/view/action.html.php';?>
</div>