From bbae037e9f897fa2ab20ac79328a452502182c30 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 4 Jul 2018 09:08:20 +0800 Subject: [PATCH] * finish task #4529. --- module/bug/control.php | 6 +++--- module/bug/model.php | 25 +++++++++++++++++-------- module/testtask/js/common.js | 16 ++++++++++++++++ module/testtask/view/results.html.php | 6 +++--- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 1cd4977818..4d460a554d 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -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)) diff --git a/module/bug/model.php b/module/bug/model.php index dc97cd92fd..d68f1e0227 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -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 = "

[" . $this->lang->testcase->precondition . "]

" . "\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 . "
"; + $bugStep .= $i . '. ' . $step->desc . "
"; $i++; } + $bugSteps .= $bugStep ? str_replace('
', '', $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'] . "
"; + $bugResult .= $i . '. ' . $stepResults[$stepId]['real'] . "
"; $i++; } + $bugSteps .= $bugResult ? str_replace('
', '', $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 . "
"; + if($step->expect) $bugExpect .= $i . '. ' . $step->expect . "
"; $i++; } + $bugSteps .= $bugExpect ? str_replace('
', '', $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); diff --git a/module/testtask/js/common.js b/module/testtask/js/common.js index fcee896bf6..1c67ebf668 100644 --- a/module/testtask/js/common.js +++ b/module/testtask/js/common.js @@ -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; +} diff --git a/module/testtask/view/results.html.php b/module/testtask/view/results.html.php index a8b2386b5b..5842848947 100644 --- a/module/testtask/view/results.html.php +++ b/module/testtask/view/results.html.php @@ -49,7 +49,7 @@ id,projectID=$testtask->project,buildID=$testtask->build" : '';?> -
product&branch=$case->branch&extras=caseID=$case->id,version=$case->version,resultID=$result->id,runID=$runID" . $params)?>' target='_blank' method='post'> + @@ -82,7 +82,7 @@ - +
caseResult == 'fail'):?> - +
@@ -113,7 +113,7 @@ caseResult == 'fail'):?>
testcase->createBug);?>testcase->createBug, "onclick='createBug(this)'", "btn btn-primary createBtn");?>