* finish task #2577.
This commit is contained in:
+17
-3
@@ -16,10 +16,11 @@ class file extends control
|
||||
*
|
||||
* @param int $fileCount
|
||||
* @param float $percent
|
||||
* @param array $htmlTagName
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function buildForm($fileCount = 1, $percent = 0.9)
|
||||
public function buildForm($fileCount = 1, $percent = 0.9, $htmlTagName = array())
|
||||
{
|
||||
if(!file_exists($this->file->savePath))
|
||||
{
|
||||
@@ -31,8 +32,21 @@ class file extends control
|
||||
printf($this->lang->file->errorCanNotWrite, $this->file->savePath, $this->file->savePath);
|
||||
return false;
|
||||
}
|
||||
$this->view->fileCount = $fileCount;
|
||||
$this->view->percent = $percent;
|
||||
|
||||
if(empty($htmlTagName))
|
||||
{
|
||||
$filesName = 'files';
|
||||
$labelsName = 'labels';
|
||||
}
|
||||
else
|
||||
{
|
||||
list($filesName, $labelsName) = $htmlTagName;
|
||||
}
|
||||
|
||||
$this->view->fileCount = $fileCount;
|
||||
$this->view->percent = $percent;
|
||||
$this->view->filesName = $filesName;
|
||||
$this->view->labelsName = $labelsName;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
+23
-7
@@ -36,12 +36,17 @@ class fileModel extends model
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param string $objectID
|
||||
* @param string $extra
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getByObject($objectType, $objectID)
|
||||
public function getByObject($objectType, $objectID, $extra = '')
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_FILE)->where('objectType')->eq($objectType)->andWhere('objectID')->eq((int)$objectID)->orderBy('id')->fetchAll();
|
||||
return $this->dao->select('*')->from(TABLE_FILE)
|
||||
->where('objectType')->eq($objectType)
|
||||
->andWhere('objectID')->eq((int)$objectID)
|
||||
->beginIF($extra)->andWhere('extra')->eq($extra)
|
||||
->orderBy('id')->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,14 +70,24 @@ class fileModel extends model
|
||||
* @param string $objectType
|
||||
* @param string $objectID
|
||||
* @param string $extra
|
||||
* @param array $htmlTagName
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function saveUpload($objectType = '', $objectID = '', $extra = '')
|
||||
public function saveUpload($objectType = '', $objectID = '', $extra = '', $htmlTagName = array())
|
||||
{
|
||||
if(empty($htmlTagName))
|
||||
{
|
||||
$files = $this->getUpload();
|
||||
}
|
||||
else
|
||||
{
|
||||
list($filesName, $labelsName) = $htmlTagName;
|
||||
$files = $this->getUpload($filesName, $labelsName);
|
||||
}
|
||||
|
||||
$fileTitles = array();
|
||||
$now = helper::today();
|
||||
$files = $this->getUpload();
|
||||
|
||||
foreach($files as $id => $file)
|
||||
{
|
||||
@@ -107,10 +122,11 @@ class fileModel extends model
|
||||
* Get info of uploaded files.
|
||||
*
|
||||
* @param string $htmlTagName
|
||||
* @param string $labelsName
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getUpload($htmlTagName = 'files')
|
||||
public function getUpload($htmlTagName = 'files', $labelsName = 'labels')
|
||||
{
|
||||
$files = array();
|
||||
if(!isset($_FILES[$htmlTagName])) return $files;
|
||||
@@ -130,7 +146,7 @@ class fileModel extends model
|
||||
if(!validater::checkFileName($filename)) continue;
|
||||
$file['extension'] = $this->getExtension($filename);
|
||||
$file['pathname'] = $this->setPathName($id, $file['extension']);
|
||||
$file['title'] = !empty($_POST['labels'][$id]) ? htmlspecialchars($_POST['labels'][$id]) : str_replace('.' . $file['extension'], '', $filename);
|
||||
$file['title'] = !empty($_POST[$labelsName][$id]) ? htmlspecialchars($_POST[$labelsName][$id]) : str_replace('.' . $file['extension'], '', $filename);
|
||||
$file['title'] = $purifier->purify($file['title']);
|
||||
$file['size'] = $size[$id];
|
||||
$file['tmpname'] = $tmp_name[$id];
|
||||
@@ -144,7 +160,7 @@ class fileModel extends model
|
||||
if(!validater::checkFileName($name)) return array();;
|
||||
$file['extension'] = $this->getExtension($name);
|
||||
$file['pathname'] = $this->setPathName(0, $file['extension']);
|
||||
$file['title'] = !empty($_POST['labels'][0]) ? htmlspecialchars($_POST['labels'][0]) : substr($name, 0, strpos($name, $file['extension']) - 1);
|
||||
$file['title'] = !empty($_POST[$labelsName][0]) ? htmlspecialchars($_POST[$labelsName][0]) : substr($name, 0, strpos($name, $file['extension']) - 1);
|
||||
$file['title'] = $purifier->purify($file['title']);
|
||||
$file['size'] = $size;
|
||||
$file['tmpname'] = $tmp_name;
|
||||
|
||||
@@ -12,10 +12,10 @@ table.fileBox td {padding: 0!important}
|
||||
$fileRow = <<<EOT
|
||||
<table class='fileBox' id='fileBox\$i'>
|
||||
<tr>
|
||||
<td class='w-p45'><div class='form-control file-wrapper'><input type='file' name='files[]' class='fileControl' tabindex='-1' onchange='checkSizeAndType(this)'/></div></td>
|
||||
<td class=''><input type='text' name='labels[]' class='form-control' placeholder='{$lang->file->label}' tabindex='-1' /></td>
|
||||
<td class='w-30px'><a href='javascript:void();' onclick='addFile(this)' class='btn btn-block'><i class='icon-plus'></i></a></td>
|
||||
<td class='w-30px'><a href='javascript:void();' onclick='delFile(this)' class='btn btn-block'><i class='icon-remove'></i></a></td>
|
||||
<td class='w-p45'><div class='form-control file-wrapper'><input type='file' name='{$filesName}[]' class='fileControl' tabindex='-1' onchange='checkSizeAndType(this)'/></div></td>
|
||||
<td class=''><input type='text' name='{$labelsName}[]' class='form-control' placeholder='{$lang->file->label}' tabindex='-1' /></td>
|
||||
<td class='w-30px'><a href='javascript:void(0);' onclick='addFile(this)' class='btn btn-block'><i class='icon-plus'></i></a></td>
|
||||
<td class='w-30px'><a href='javascript:void(0);' onclick='delFile(this)' class='btn btn-block'><i class='icon-remove'></i></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
EOT;
|
||||
@@ -100,7 +100,13 @@ function addFile(clickedButton)
|
||||
{
|
||||
fileRow = <?php echo json_encode($fileRow);?>;
|
||||
fileRow = fileRow.replace('$i', $('.fileID').size() + 1);
|
||||
$(clickedButton).closest('.fileBox').after(fileRow);
|
||||
|
||||
filesName = $(clickedButton).closest('tr').find('input[type="file"]').attr('name');
|
||||
labelsName = $(clickedButton).closest('tr').find('input[type="text"]').attr('name');
|
||||
|
||||
$fileBox = $(clickedButton).closest('.fileBox').after(fileRow).next('.fileBox');
|
||||
$fileBox.find('input[type="file"]').attr('name', filesName);
|
||||
$fileBox.find('input[type="text"]').attr('name', labelsName);
|
||||
|
||||
setFileFormWidth(<?php echo $percent;?>);
|
||||
updateID();
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
.outer > #titlebar {display: none}
|
||||
|
||||
.btn-file {float:right}
|
||||
.fix-border td {border:0px;}
|
||||
.fix-position td {vertical-align: middle;}
|
||||
|
||||
@@ -50,6 +50,7 @@ $lang->testtask->lastRunAccount = "Run";
|
||||
$lang->testtask->lastRunTime = 'Time';
|
||||
$lang->testtask->lastRunResult = 'Result';
|
||||
$lang->testtask->report = 'Report';
|
||||
$lang->testtask->files = 'Upload Files';
|
||||
|
||||
$lang->testtask->legendDesc = 'Desc';
|
||||
$lang->testtask->legendReport = 'Report';
|
||||
|
||||
@@ -50,6 +50,7 @@ $lang->testtask->lastRunAccount = '执行人';
|
||||
$lang->testtask->lastRunTime = '执行时间';
|
||||
$lang->testtask->lastRunResult = '结果';
|
||||
$lang->testtask->report = '测试总结';
|
||||
$lang->testtask->files = '上传附件';
|
||||
|
||||
$lang->testtask->legendDesc = '版本描述';
|
||||
$lang->testtask->legendReport = '测试总结';
|
||||
|
||||
@@ -365,7 +365,28 @@ class testtaskModel extends model
|
||||
->skipSpecial('stepResults')
|
||||
->remove('steps,reals,result')
|
||||
->get();
|
||||
|
||||
/* Remove files and labels field when uploading files for case result or step result. */
|
||||
foreach($result as $fieldName => $field)
|
||||
{
|
||||
if((strpos($fieldName, 'files') !== false) or (strpos($fieldName, 'labels') !== false)) unset($result->$fieldName);
|
||||
}
|
||||
|
||||
$this->dao->insert(TABLE_TESTRESULT)->data($result)->autoCheck()->exec();
|
||||
|
||||
/* Save upload files for case result or step result. */
|
||||
if(!dao::isError())
|
||||
{
|
||||
$resultID = $this->dao->lastInsertID();
|
||||
if(!empty($stepResults))
|
||||
{
|
||||
foreach($stepResults as $stepID => $stepResult) $this->loadModel('file')->saveUpload('stepResult', $resultID, $stepID, array("files{$stepID}", "labels{$stepID}"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->loadModel('file')->saveUpload('caseResult', $resultID);
|
||||
}
|
||||
}
|
||||
$this->dao->update(TABLE_CASE)->set('lastRunner')->eq($this->app->user->account)->set('lastRunDate')->eq($now)->set('lastRunResult')->eq($caseResult)->where('id')->eq($postData->case)->exec();
|
||||
|
||||
if($runID)
|
||||
@@ -502,6 +523,7 @@ class testtaskModel extends model
|
||||
{
|
||||
$result->stepResults = unserialize($result->stepResults);
|
||||
$result->build = $result->run ? zget($runs, $result->run, 0) : 0;
|
||||
$result->files = $this->loadModel('file')->getByObject('caseResult', $resultID);//Get files of case result.
|
||||
$results[$resultID] = $result;
|
||||
|
||||
foreach($relatedSteps as $key => $step)
|
||||
@@ -512,6 +534,12 @@ class testtaskModel extends model
|
||||
$result->stepResults[$step->id]['expect'] = $step->expect;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get files of step result. */
|
||||
foreach($result->stepResults as $stepID => $stepResult)
|
||||
{
|
||||
$result->stepResults[$stepID]['files'] = $this->loadModel('file')->getByObject('stepResult', $resultID, $stepID);
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,12 @@
|
||||
<td class='w-180px'><?php echo $result->date;?></td>
|
||||
<td><?php echo $users[$result->lastRunner] . ' ' . $lang->testtask->runCase;?></td>
|
||||
<td class='w-150px'><?php echo zget($builds, $result->build, '');?></td>
|
||||
<td class='w-50px'><?php if(!empty($result->files)) echo html::a("#caseResult{$result->id}", '<i class="icon icon-file"></i>', '', "data-toggle='modal' title='{$lang->files}' data-type='iframe'")?></td>
|
||||
<td class='w-50px text-right'><strong class='text-<?php echo $class;?>'><?php echo $lang->testcase->resultList[$result->caseResult]?></strong></td>
|
||||
<td class='w-50px text-center'><i class='collapse-handle icon-chevron-down text-muted'></i></td>
|
||||
</tr>
|
||||
<tr class='result-detail hide'>
|
||||
<td colspan='6' class='pd-0'>
|
||||
<td colspan='7' class='pd-0'>
|
||||
<table class='table table-condensed borderless mg-0'>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -61,13 +62,17 @@
|
||||
$i = 1;
|
||||
foreach($result->stepResults as $key => $stepResult):
|
||||
?>
|
||||
<?php $modalID = $result->id . '-' . $key;?>
|
||||
<tr>
|
||||
<td class='w-30px text-center'><?php echo $i;?></td>
|
||||
<td><?php if(isset($stepResult['desc'])) echo nl2br($stepResult['desc']);?></td>
|
||||
<td><?php if(isset($stepResult['expect'])) echo nl2br($stepResult['expect']);?></td>
|
||||
<?php if(!empty($stepResult['result'])):?>
|
||||
<td class='<?php echo $stepResult['result'];?> text-center'><?php echo $lang->testcase->resultList[$stepResult['result']];?></td>
|
||||
<td><?php echo $stepResult['real'];?></td>
|
||||
<td>
|
||||
<?php echo $stepResult['real'];?>
|
||||
<?php if(!empty($stepResult['files'])) echo html::a("#stepResult{$modalID}", '<i class="icon icon-file"></i>', '', "data-toggle='modal' title='{$lang->files}' data-type='iframe' style='float:right'")?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php else:?>
|
||||
<td></td>
|
||||
@@ -80,6 +85,32 @@
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
<?php foreach($results as $result):?>
|
||||
<div class="modal fade" id="caseResult<?php echo $result->id;?>">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title"><?php echo $lang->files;?></h4>
|
||||
</div>
|
||||
<div class="modal-body"><?php echo $this->fetch('file', 'printFiles', array('files' => $result->files, 'fieldset' => 'false'));?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php foreach($result->stepResults as $stepID => $stepResult):?>
|
||||
<div class="modal fade" id="stepResult<?php echo $result->id . '-' .$stepID;?>">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title"><?php echo $lang->files;?></h4>
|
||||
</div>
|
||||
<div class="modal-body"><?php echo $this->fetch('file', 'printFiles', array('files' => $stepResult['files'], 'fieldset' => 'false'));?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach;?>
|
||||
<?php endforeach;?>
|
||||
<div id='resultTip' class='hide'><?php if($count > 0) echo $failCount > 0 ? "<span>" . sprintf($lang->testtask->showFail, $failCount) . "</span>":"<span class='text-success'>{$lang->testtask->passAll}</span>";?></div>
|
||||
<style>.table-hover tr.result-detail:hover td {background: #fff} #casesResults > table > caption {border: 1px solid #ddd; margin-bottom: -1px}</style>
|
||||
</div>
|
||||
|
||||
@@ -19,18 +19,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class='main'>
|
||||
<form class='form-condensed' method='post'>
|
||||
<form class='form-condensed' method='post' enctype='multipart/form-data'>
|
||||
<table class='table table-bordered table-form' style='word-break:break-all'>
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan='5' style='word-break: break-all;'><strong><?php echo $lang->testcase->precondition;?></strong> <?php echo $run->case->precondition;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class='fix-position'>
|
||||
<th class='w-40px'><?php echo $lang->testcase->stepID;?></th>
|
||||
<th class='w-p30'><?php echo $lang->testcase->stepDesc;?></th>
|
||||
<th class='w-p30'><?php echo $lang->testcase->stepExpect;?></th>
|
||||
<th class='w-100px'><?php echo $lang->testcase->result;?></th>
|
||||
<th><?php echo $lang->testcase->real;?></th>
|
||||
<th>
|
||||
<?php echo $lang->testcase->real;?>
|
||||
<?php if(empty($run->case->steps)):?>
|
||||
<button type='button' class='btn-file' data-toggle='modal' data-target='#fileModal'><?php echo $lang->testtask->files;?></button>
|
||||
<?php endif;?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach($run->case->steps as $key => $step):?>
|
||||
@@ -40,7 +45,14 @@
|
||||
<td><?php echo nl2br($step->desc);?></td>
|
||||
<td><?php echo nl2br($step->expect);?></td>
|
||||
<td class='text-center'><?php echo html::select("steps[$step->id]", $lang->testcase->resultList, $defaultResult, "class='form-control'");?></td>
|
||||
<td><?php echo html::textarea("reals[$step->id]", '', "rows=2 class='form-control'");?></td>
|
||||
<td>
|
||||
<table class='fix-border fix-position'>
|
||||
<tr>
|
||||
<td><?php echo html::textarea("reals[$step->id]", '', "rows=2 class='form-control fix-textarea'");?></td>
|
||||
<td><button type='button' title='<?php echo $lang->testtask->files?>' class='btn-file' data-toggle='modal' data-target='#fileModal<?php echo $step->id?>'><i class='icon icon-paper-clip'></i></button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr class='text-center'>
|
||||
@@ -64,6 +76,46 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php if(empty($run->case->steps)):?>
|
||||
<div class="modal fade" id="fileModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title"><?php echo $lang->testtask->files;?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<td><?php echo $this->fetch('file', 'buildform');?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<?php foreach($run->case->steps as $key => $step):?>
|
||||
<?php $htmlTagName = array("files{$step->id}", "labels{$step->id}");?>
|
||||
<div class="modal fade" id="fileModal<?php echo $step->id;?>">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title"><?php echo $lang->testtask->files;?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<td><?php echo $this->fetch('file', 'buildform', array('fileCount' => 1, 'percent' => 0.9, 'htmlTagName' => $htmlTagName));?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach;?>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
</div>
|
||||
<div class='main' id='resultsContainer'>
|
||||
|
||||
Reference in New Issue
Block a user