* testcase: move the printRow method to model.php.
This commit is contained in:
@@ -2103,6 +2103,62 @@ class testcaseModel extends model
|
||||
$this->loadModel('search')->setSearchParams($this->config->testcase->search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print rows of cases.
|
||||
*
|
||||
* @param int $index
|
||||
* @param array $cases
|
||||
* @param array $setting
|
||||
* @param array $users
|
||||
* @param array $branchOption
|
||||
* @param array $modulePairs
|
||||
* @param string $browseType
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function printRow($index, $cases, $setting, $users, $branchOption, $modulePairs, $browseType, $mode)
|
||||
{
|
||||
foreach($cases as $case)
|
||||
{
|
||||
$case->index = $index;
|
||||
|
||||
$trClass = '';
|
||||
$trAttrs = "data-id='{$case->id}' data-auto='" . zget($case, 'auto', '') . "' data-order='{$case->sort}' data-parent='{$case->parent}' data-product='{$case->product}'";
|
||||
if($case->isCase == 2)
|
||||
{
|
||||
$trAttrs .= " data-nested='true'";
|
||||
$trClass .= $case->parent == '0' ? ' is-top-level table-nest-child-hide' : ' table-nest-hide';
|
||||
}
|
||||
|
||||
if($case->parent)
|
||||
{
|
||||
if($case->isCase != 2) $trClass .= ' is-nest-child';
|
||||
$trClass .= ' table-nest-hide';
|
||||
$trAttrs .= " data-nest-parent='{$case->parent}' data-nest-path='{$case->path}'";
|
||||
}
|
||||
elseif($case->isCase != 2)
|
||||
{
|
||||
$trClass .= ' no-nest';
|
||||
}
|
||||
$trAttrs .= " class='row-case $trClass'";
|
||||
|
||||
echo "<tr data-itype='{$case->isCase}' {$trAttrs}>";
|
||||
foreach($setting as $key => $value) $this->printCell($value, $case, $users, $branchOption, $modulePairs, $browseType, $mode, $case->isCase);
|
||||
echo '</tr>';
|
||||
|
||||
$index++;
|
||||
|
||||
if(!empty($case->children) || !empty($case->cases))
|
||||
{
|
||||
if(!empty($case->children)) $index = printRow($index, $case->children, $setting, $users, $branchOption, $modulePairs, $browseType, $mode);
|
||||
if(!empty($case->cases)) $index = printRow($index, $case->cases, $setting, $users, $branchOption, $modulePairs, $browseType, $mode);
|
||||
}
|
||||
}
|
||||
|
||||
return $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print cell data
|
||||
*
|
||||
|
||||
@@ -134,52 +134,7 @@ js::set('langNormal', $lang->testcase->normal);
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id='caseTableList'>
|
||||
<?php
|
||||
function printRow($index, $testcase, $cases, $setting, $users, $branchOption, $modulePairs, $browseType, $mode)
|
||||
{
|
||||
foreach($cases as $case)
|
||||
{
|
||||
$case->index = $index;
|
||||
|
||||
$prefix = $case->isCase == 1 ? 'case_' : 'scene_';
|
||||
$trClass = '';
|
||||
$trAttrs = "data-id='{$prefix}{$case->id}' data-auto='" . zget($case, 'auto', '') . "' data-order='{$case->sort}' data-parent='{$case->parent}' data-product='{$case->product}'";
|
||||
if($case->isCase == 2)
|
||||
{
|
||||
$trAttrs .= " data-nested='true'";
|
||||
$trClass .= $case->parent == '0' ? ' is-top-level table-nest-child-hide' : ' table-nest-hide';
|
||||
}
|
||||
|
||||
if($case->parent)
|
||||
{
|
||||
if($case->isCase != 2) $trClass .= ' is-nest-child';
|
||||
$trClass .= ' table-nest-hide';
|
||||
$trAttrs .= " data-nest-parent='{$case->parent}' data-nest-path='{$case->path}'";
|
||||
}
|
||||
elseif($case->isCase != 2)
|
||||
{
|
||||
$trClass .= ' no-nest';
|
||||
}
|
||||
$trAttrs .= " class='row-case $trClass'";
|
||||
|
||||
echo "<tr data-itype='{$case->isCase}' {$trAttrs}>";
|
||||
foreach($setting as $key => $value) $testcase->printCell($value, $case, $users, $branchOption, $modulePairs, $browseType, $mode, $case->isCase);
|
||||
echo '</tr>';
|
||||
|
||||
$index++;
|
||||
|
||||
if(!empty($case->children) || !empty($case->cases))
|
||||
{
|
||||
if(!empty($case->children)) $index = printRow($index, $testcase, $case->children, $setting, $users, $branchOption, $modulePairs, $browseType, $mode);
|
||||
if(!empty($case->cases)) $index = printRow($index, $testcase, $case->cases, $setting, $users, $branchOption, $modulePairs, $browseType, $mode);
|
||||
}
|
||||
}
|
||||
|
||||
return $index;
|
||||
}
|
||||
|
||||
printRow(1, $this->testcase, $cases, $setting, $users, $branchOption, $modulePairs, $browseType, $useDatatable ? 'datatable' : 'table');
|
||||
?>
|
||||
<?php $this->testcase->printRow(1, $cases, $setting, $users, $branchOption, $modulePairs, $browseType, $useDatatable ? 'datatable' : 'table');?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if(!$useDatatable) echo '</div>';?>
|
||||
|
||||
Reference in New Issue
Block a user