* finish task #4529.

This commit is contained in:
wangyidong
2018-07-04 09:08:20 +08:00
parent 266146bb34
commit bbae037e9f
4 changed files with 39 additions and 14 deletions
+3 -3
View File
@@ -254,7 +254,7 @@ class bug extends control
$this->view->users = $this->user->getPairs('devfirst|noclosed|nodeleted');
$this->app->loadLang('release');
if(!empty($_POST) and !isset($_POST['stepIDList']))
if(!empty($_POST))
{
$response['result'] = 'success';
$response['message'] = '';
@@ -332,8 +332,8 @@ class bug extends control
$extras = str_replace(array(',', ' '), array('&', ''), $extras);
parse_str($extras);
if($runID and $resultID) extract($this->bug->getBugInfoFromResult($resultID));// If set runID and resultID, get the result info by resultID as template.
if(!$runID and $caseID) extract($this->bug->getBugInfoFromResult($resultID, $caseID, $version));// If not set runID but set caseID, get the result info by resultID and case info.
if($runID and $resultID) extract($this->bug->getBugInfoFromResult($resultID, 0, 0, isset($stepIdList) ? $stepIdList : ''));// If set runID and resultID, get the result info by resultID as template.
if(!$runID and $caseID) extract($this->bug->getBugInfoFromResult($resultID, $caseID, $version, isset($stepIdList) ? $stepIdList : ''));// If not set runID but set caseID, get the result info by resultID and case info.
/* If bugID setted, use this bug as template. */
if(isset($bugID))
+17 -8
View File
@@ -1610,11 +1610,11 @@ class bugModel extends model
* @access public
* @return array
*/
public function getBugInfoFromResult($resultID, $caseID = 0, $version = 0)
public function getBugInfoFromResult($resultID, $caseID = 0, $version = 0, $stepIdList = '')
{
$title = '';
$bugSteps = '';
$steps = zget($_POST, 'stepIDList', array());
$steps = explode('_', trim($stepIdList, '_'));
$result = $this->dao->findById($resultID)->from(TABLE_TESTRESULT)->fetch();
if($caseID > 0)
@@ -1635,38 +1635,47 @@ class bugModel extends model
$bugSteps = "<p>[" . $this->lang->testcase->precondition . "]</p>" . "\n" . $run->case->precondition;
}
$bugSteps .= $this->lang->bug->tplStep;
if(!empty($stepResults))
{
$i = 1;
$bugStep = '';
foreach($steps as $stepId)
{
if(!isset($caseSteps[$stepId])) continue;
$step = $caseSteps[$stepId];
$bugSteps .= $i . '. ' . $step->desc . "<br />";
$bugStep .= $i . '. ' . $step->desc . "<br />";
$i++;
}
$bugSteps .= $bugStep ? str_replace('<br/>', '', $this->lang->bug->tplStep) . $bugStep : $this->lang->bug->tplStep;
$bugSteps .= $this->lang->bug->tplResult;
$i = 1;
$bugResult = '';
foreach($steps as $stepId)
{
if(!isset($stepResults[$stepId]) or empty($stepResults[$stepId]['real'])) continue;
$bugSteps .= $i . '. ' . $stepResults[$stepId]['real'] . "<br />";
$bugResult .= $i . '. ' . $stepResults[$stepId]['real'] . "<br />";
$i++;
}
$bugSteps .= $bugResult ? str_replace('<br/>', '', $this->lang->bug->tplResult) . $bugResult : $this->lang->bug->tplResult;
$bugSteps .= $this->lang->bug->tplExpect;
$i = 1;
$bugExpect = '';
foreach($steps as $stepId)
{
if(!isset($caseSteps[$stepId])) continue;
$step = $caseSteps[$stepId];
if($step->expect) $bugSteps .= $i . '. ' . $step->expect . "<br />";
if($step->expect) $bugExpect .= $i . '. ' . $step->expect . "<br />";
$i++;
}
$bugSteps .= $bugExpect ? str_replace('<br/>', '', $this->lang->bug->tplExpect) . $bugExpect : $this->lang->bug->tplExpect;
}
else
{
$bugSteps .= $this->lang->bug->tplStep;
$bugSteps .= $this->lang->bug->tplResult;
$bugSteps .= $this->lang->bug->tplExpect;
}
return array('title' => $title, 'steps' => $bugSteps, 'storyID' => $run->case->story, 'moduleID' => $run->case->module, 'version' => $run->case->version);
+16
View File
@@ -28,3 +28,19 @@ function adjustPriBoxWidth()
var addonWidth = $('#ownerAndPriBox .input-group-addon').outerWidth();
$('#pri,#pri_chosen .chosen-single').css('width', boxWidth - beginWidth -addonWidth);
}
function createBug(obj)
{
var $form = $(obj).closest('form');
var params = $form.data('params');
var stepIdList = '';
$form.find('.step .step-id :checkbox').each(function()
{
if($(this).prop('checked')) stepIdList += $(this).val() + '_';
});
var onlybody = config.onlybody;
config.onlybody = 'no';
window.open(createLink('bug', 'create', params + ',stepIdList=' + stepIdList), '_blank');
config.onlybody = onlybody;
}
+3 -3
View File
@@ -49,7 +49,7 @@
<?php $params = isset($testtask) ? ",testtask=$testtask->id,projectID=$testtask->project,buildID=$testtask->build" : '';?>
<tr class='result-detail hide' id='tr-detail_<?php echo $trCount++; ?>'>
<td colspan='7' class='pd-0'>
<form action='<?php echo $this->createLink('bug', 'create', "product=$case->product&branch=$case->branch&extras=caseID=$case->id,version=$case->version,resultID=$result->id,runID=$runID" . $params)?>' target='_blank' method='post'>
<form data-params='<?php echo "product=$case->product&branch=$case->branch&extras=caseID=$case->id,version=$case->version,resultID=$result->id,runID=$runID" . $params?>' method='post'>
<table class='table table-condensed resultSteps'>
<thead>
<tr>
@@ -82,7 +82,7 @@
<tr class='step <?php echo $stepClass?>'>
<td class='step-id'>
<?php if($result->caseResult == 'fail'):?>
<?php $inputName = $stepResult['type'] != 'group' ? 'stepIDList[]' : '';?>
<?php $inputName = $stepResult['type'] != 'group' ? 'stepIdList[]' : '';?>
<div class='checkbox-primary'>
<input type='checkbox' id='<?php echo $inputName;?>' name='<?php echo $inputName;?>' value='<?php echo $key;?>'/>
<label><?php echo $stepId;?></label>
@@ -113,7 +113,7 @@
<?php if($result->caseResult == 'fail'):?>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td>
<td><?php echo html::submitButton($lang->testcase->createBug);?></td>
<td><?php echo html::commonButton($lang->testcase->createBug, "onclick='createBug(this)'", "btn btn-primary createBtn");?></td>
</tr>
<?php endif;?>
</tbody>