Merge branch 'sgm_56629' into 'master'

* Finish task #56629.

See merge request easycorp/zentaopms!3893
This commit is contained in:
王怡栋
2022-06-14 02:24:12 +00:00
7 changed files with 216 additions and 3 deletions
+2
View File
@@ -971,6 +971,7 @@ $lang->resource->testcase->createBug = 'createBug';
$lang->resource->testcase->view = 'view';
$lang->resource->testcase->edit = 'edit';
$lang->resource->testcase->linkCases = 'linkCases';
$lang->resource->testcase->linkBugs = 'linkBugs';
$lang->resource->testcase->batchEdit = 'batchEdit';
$lang->resource->testcase->delete = 'deleteAction';
$lang->resource->testcase->batchDelete = 'batchDelete';
@@ -1008,6 +1009,7 @@ $lang->testcase->methodOrder[65] = 'batchDelete';
$lang->testcase->methodOrder[70] = 'batchChangeModule';
$lang->testcase->methodOrder[75] = 'batchChangeBranch';
$lang->testcase->methodOrder[80] = 'linkCases';
$lang->testcase->methodOrder[82] = 'linkBugs';
$lang->testcase->methodOrder[90] = 'bugs';
$lang->testcase->methodOrder[95] = 'review';
$lang->testcase->methodOrder[100] = 'batchReview';
+36
View File
@@ -1334,6 +1334,42 @@ class testcase extends control
$this->display();
}
/**
* Link related bugs.
*
* @param int $caseID
* @param string $browseType
* @param int $param
* @access public
* @return void
*/
public function linkBugs($caseID, $browseType = '', $param = 0)
{
$this->loadModel('bug');
/* Get case and queryID. */
$case = $this->testcase->getById($caseID);
$queryID = ($browseType == 'bySearch') ? (int)$param : 0;
/* Build the search form. */
$actionURL = $this->createLink('testcase', 'linkBugs', "caseID=$caseID&browseType=bySearch&queryID=myQueryID", '', true);
$objectID = 0;
if($this->app->tab == 'project') $objectID = $case->project;
if($this->app->tab == 'execution') $objectID = $case->execution;
$this->bug->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID);
/* Get cases to link. */
$bugs2Link = $this->testcase->getBugs2Link($caseID, $browseType, $queryID);
/* Assign. */
$this->view->position[] = $this->lang->testcase->linkBugs;
$this->view->case = $case;
$this->view->bugs2Link = $bugs2Link;
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->display();
}
/**
* Confirm testcase changed.
*
+3
View File
@@ -43,6 +43,9 @@ $lang->testcase->files = '附件';
$lang->testcase->linkCase = '相关用例';
$lang->testcase->linkCases = '关联相关用例';
$lang->testcase->unlinkCase = '移除相关用例';
$lang->testcase->linkBug = '相关Bug';
$lang->testcase->linkBugs = '关联相关Bug';
$lang->testcase->unlinkBug = '移除相关Bug';
$lang->testcase->stage = '适用阶段';
$lang->testcase->scriptedBy = '脚本由谁创建';
$lang->testcase->scriptedDate = '脚本创建日期';
+47 -1
View File
@@ -771,7 +771,7 @@ class testcaseModel extends model
->setForce('status', $status)
->cleanInt('story,product,branch,module')
->stripTags($this->config->testcase->editor->edit['id'], $this->config->allowedTags)
->remove('comment,steps,expects,files,labels,stepType')
->remove('comment,steps,expects,files,labels,linkBug,stepType')
->get();
$requiredFields = $this->config->testcase->edit->requiredFields;
@@ -835,6 +835,24 @@ class testcaseModel extends model
}
}
/* Link bugs to case. */
if($this->post->linkBug)
{
$linkedBugs = array_keys($oldCase->toBugs);
$linkBugs = $this->post->linkBug;
$newBugs = array_diff($linkBugs, $linkedBugs);
$removeBugs = array_diff($linkedBugs, $linkBugs);
if($newBugs)
{
foreach($newBugs as $bugID) $this->dao->update(TABLE_BUG)->set('`case`')->eq($caseID)->set('caseVersion')->eq($case->version)->where('id')->eq($bugID)->exec();
}
if($removeBugs)
{
foreach($removeBugs as $bugID) $this->dao->update(TABLE_BUG)->set('`case`')->eq(0)->set('caseVersion')->eq(0)->where('id')->eq($bugID)->exec();
}
}
/* Join the steps to diff. */
if($stepChanged and $this->post->steps)
@@ -960,6 +978,34 @@ class testcaseModel extends model
}
}
/**
* Get bugs to link.
*
* @param int $caseID
* @param string $browseType
* @param int $queryID
* @access public
* @return array
*/
public function getBugs2Link($caseID, $browseType = 'bySearch', $queryID = 0)
{
$this->loadModel('bug');
if($browseType == 'bySearch')
{
$case = $this->getById($caseID);
$bugs2Link = $this->bug->getBySearch($case->product, $case->branch, $queryID, 'id');
foreach($bugs2Link as $key => $bug2Link)
{
if($bug2Link->case != 0) unset($bugs2Link[$key]);
}
return $bugs2Link;
}
else
{
return array();
}
}
/**
* Batch update testcases.
*
+30 -2
View File
@@ -233,12 +233,13 @@
<th><?php echo $lang->testcase->keywords;?></th>
<td><?php echo html::input('keywords', $case->keywords, "class='form-control'");?></td>
</tr>
<?php if(!$isLibCase):?>
<?php if(!$isLibCase and common::hasPriv('testcase', 'linkCases')):?>
<tr>
<th><?php echo $lang->testcase->linkCase;?></th>
<td><?php echo html::a($this->createLink('testcase', 'linkCases', "caseID=$case->id", '', true), $lang->testcase->linkCases, '', "data-type='iframe' data-toggle='modal' data-width='95%'");?></td>
</tr>
<tr>
<?php $class = isset($case->linkCaseTitles) ? '' : 'hide';?>
<tr class=<?php echo $class;?>>
<th></th>
<td>
<ul class='list-unstyled'>
@@ -259,6 +260,33 @@
</td>
</tr>
<?php endif;?>
<?php if(!$isLibCase and common::hasPriv('testcase', 'linkBugs')):?>
<tr>
<th><?php echo $lang->testcase->linkBug;?></th>
<td><?php echo html::a($this->createLink('testcase', 'linkBugs', "caseID=$case->id", '', true), $lang->testcase->linkBugs, '', "data-type='iframe' data-toggle='modal' data-width='95%'");?></td>
</tr>
<?php $class = !empty($case->toBugs) ? '' : 'hide';?>
<tr class=<?php echo $class;?>>
<th></th>
<td>
<ul class='list-unstyled'>
<?php
if(isset($case->toBugs))
{
foreach($case->toBugs as $bugID => $bugTitle)
{
echo "<li><div class='checkbox-primary'>";
echo "<input type='checkbox' checked='checked' name='linkBug[]' value=$bugID />";
echo "<label>#{$bugID} {$bugTitle}</label>";
echo '</div></li>';
}
}
?>
<span id='linkBugBox'></span>
</ul>
</td>
</tr>
<?php endif;?>
</table>
</div>
<?php $this->printExtendFields($case, 'div', 'position=right');?>
+97
View File
@@ -0,0 +1,97 @@
<?php
/**
* The linkbugs view file of testcase module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Fei Chen <chenfei@cnezsoft.com>
* @package testcase
* @version $Id: linkbugs.html.php 4411 2016-03-09 11:02:04Z Chen Fei $
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/tablesorter.html.php';?>
<div id="mainContent" class="main-content">
<div class='main-header'>
<h2>
<span class='label label-id'><?php echo $case->id;?></span>
<?php echo html::a($this->createLink('case', 'view', "caseID={$case->id}"), $case->title, '_blank');?>
<small class='text-muted'> <?php echo $lang->arrow . $lang->testcase->linkBugs;?></small>
</h2>
</div>
<div id='queryBox' data-module='bug' class='show divider'></div>
<?php if($bugs2Link):?>
<form class='main-table' method='post' target='hiddenwin' id='linkBugsForm' data-ride='table'>
<table class='table tablesorter' id='caseList'>
<thead>
<tr>
<th class='c-id'>
<div class="checkbox-primary check-all" title="<?php echo $lang->selectAll?>">
<label></label>
</div>
<?php echo $lang->idAB;?>
</th>
<th class='c-pri' title=<?php echo $lang->pri;?>><?php echo $lang->priAB;?></th>
<th><?php echo $lang->bug->product;?></th>
<th><?php echo $lang->bug->title;?></th>
<th class='c-type'><?php echo $lang->bug->type;?></th>
<th class='c-user'><?php echo $lang->openedByAB;?></th>
<th class='c-status'><?php echo $lang->statusAB;?></th>
</tr>
</thead>
<tbody>
<?php $bugCount = 0;?>
<?php foreach($bugs2Link as $bug2Link):?>
<tr>
<td class='c-id'>
<div class="checkbox-primary">
<input type='checkbox' name='bugs[]' value='<?php echo $bug2Link->id;?>' />
<label></label>
</div>
<?php printf('%03d', $bug2Link->id);?>
</td>
<td><span class='<?php echo 'pri' . zget($lang->bug->priList, $bug2Link->pri, $bug2Link->pri)?>'><?php echo zget($lang->bug->priList, $bug2Link->pri, $bug2Link->pri)?></span></td>
<td><?php echo html::a($this->createLink('product', 'browse', "productID={$bug2Link->product}&branch={$bug2Link->branch}"), $products[$bug2Link->product], '_blank');?></td>
<td class='text-left' title='<?php echo $bug2Link->title;?>'><?php echo html::a($this->createLink('bug', 'view', "bugID=$bug2Link->id"), $bug2Link->title, '_blank');?></td>
<td><?php echo zget($lang->bug->typeList, $bug2Link->type);?></td>
<td><?php echo zget($users, $bug2Link->openedBy);?></td>
<td class='status-<?php echo $bug2Link->status?>'><?php echo $this->bug->processStatus('bug', $bug2Link);?></td>
</tr>
<?php $bugCount ++;?>
<?php endforeach;?>
</tbody>
</table>
<div class='table-footer'>
<div class="checkbox-primary check-all"><label><?php echo $lang->selectAll?></label></div>
<div class="table-actions btn-toolbar"><?php if($bugCount) echo html::submitButton('', '', 'btn btn-default');?></div>
<?php echo html::hidden('case', $case->id);?>
</div>
</form>
<?php endif;?>
</div>
<script>
$(function()
{
<?php if($bugs2Link):?>
$('#linkBugsForm').table();
setTimeout(function(){$('#linkBugsForm .table-footer').removeClass('fixed-footer');}, 100);
<?php endif;?>
$('#submit').click(function(){
var output = '';
$('#linkBugsForm').find('tr.checked').each(function(){
var bugID = $(this).find('td.c-id').find('div.checkbox-primary input').attr('value');
var bugTitle = "#" + bugID + ' ' + $(this).find('td').eq(3).attr('title');
var checkbox = "<li><div class='checkbox-primary'><input type='checkbox' checked='checked' name='linkBug[]' " + "value=" + bugID + " /><label>" + bugTitle + "</label></div></li>";
output += checkbox;
});
$.closeModal();
parent.$('#linkBugBox').html(output);
parent.$('#linkBugBox').closest('tr').removeClass('hide');
return false;
});
});
</script>
<?php include '../../common/view/footer.html.php';?>
+1
View File
@@ -89,6 +89,7 @@ $(function()
});
$.closeModal();
parent.$('#linkCaseBox').html(output);
parent.$('#linkCaseBox').closest('tr').removeClass('hide');
return false;
});
});