* Refact cases page and link case page of testtask.

This commit is contained in:
liugang
2018-05-14 15:35:57 +08:00
parent 78be34984f
commit 6e08c62f81
11 changed files with 281 additions and 266 deletions
+109 -98
View File
@@ -15,115 +15,126 @@
<?php include './caseheader.html.php';?>
<?php js::set('confirmUnlink', $lang->testtask->confirmUnlinkCase)?>
<?php js::set('taskCaseBrowseType', ($browseType == 'bymodule' and $this->session->taskCaseBrowseType == 'bysearch') ? 'all' : $this->session->taskCaseBrowseType);?>
<script language="Javascript">
var browseType = '<?php echo $browseType;?>';
var moduleID = '<?php echo $moduleID;?>';
</script>
<div class='side' id='casesbox'>
<a class='side-handle' data-id='testtaskTree'><i class='icon-caret-left'></i></a>
<div class='side-body'>
<div class='panel panel-sm'>
<div class='panel-heading nobr'><?php echo html::icon($lang->icons['product']);?> <strong><?php echo $productName;?></strong></div>
<div class='panel-body'>
<?php echo $moduleTree;?>
</div>
</div>
<?php js::set('browseType', $browseType);?>
<?php js::set('moduleID', $moduleID);?>
<div id='mainContent' class='main-row'>
<div class='side-col' id='sidebar'>
<div class='cell'><?php echo $moduleTree;?></div>
</div>
</div>
<div class='main'>
<script>setTreeBox();</script>
<form method='post' name='casesform' id='casesForm'>
<?php
$vars = "taskID=$task->id&browseType=$browseType&param=$param&orderBy=%s&recToal={$pager->recTotal}&recPerPage={$pager->recPerPage}";
$datatableId = $this->moduleName . ucfirst($this->methodName);
$useDatatable = (isset($this->config->datatable->$datatableId->mode) and $this->config->datatable->$datatableId->mode == 'datatable');
<div class='main-col'>
<div class="cell" id="queryBox"></div>
<form class='main-table table-cases' data-ride='table' method='post' name='casesform' id='casesForm'>
<?php
$vars = "taskID=$task->id&browseType=$browseType&param=$param&orderBy=%s&recToal={$pager->recTotal}&recPerPage={$pager->recPerPage}";
$datatableId = $this->moduleName . ucfirst($this->methodName);
$useDatatable = (isset($this->config->datatable->$datatableId->mode) and $this->config->datatable->$datatableId->mode == 'datatable');
$canBatchEdit = common::hasPriv('testcase', 'batchEdit');
$canBatchAssign = common::hasPriv('testtask', 'batchAssign');
$canBatchRun = common::hasPriv('testtask', 'batchRun');
$hasCheckbox = ($canBatchEdit or $canBatchAssign or $canBatchRun);
$canBatchEdit = common::hasPriv('testcase', 'batchEdit');
$canBatchUnlink = common::hasPriv('testtask', 'batchUnlinkCases');
$canBatchAssign = common::hasPriv('testtask', 'batchAssign');
$canBatchRun = common::hasPriv('testtask', 'batchRun');
$hasCheckbox = ($canBatchEdit or $canBatchUnlink or $canBatchAssign or $canBatchRun);
if($useDatatable) include '../../common/view/datatable.html.php';
if(!$useDatatable) include '../../common/view/tablesorter.html.php';
if($useDatatable) include '../../common/view/datatable.html.php';
if(!$useDatatable) include '../../common/view/tablesorter.html.php';
$this->config->testcase->datatable->defaultField = $this->config->testtask->datatable->defaultField;
$this->config->testcase->datatable->fieldList['actions']['width'] = '100';
$this->config->testcase->datatable->defaultField = $this->config->testtask->datatable->defaultField;
$this->config->testcase->datatable->fieldList['actions']['width'] = '156';
$setting = $this->datatable->getSetting('testtask');
$widths = $this->datatable->setFixedFieldWidth($setting);
$columns = 0;
?>
<table class='table table-condensed table-hover table-striped tablesorter table-fixed <?php echo $useDatatable ? 'datatable' : ''?>' id='caseList' data-checkable='<?php echo $hasCheckbox?>' data-fixed-left-width='<?php echo $widths['leftWidth']?>' data-fixed-right-width='<?php echo $widths['rightWidth']?>' data-custom-menu='true' data-checkbox-name='caseIDList[]'>
<thead>
<tr>
<?php
foreach($setting as $key => $value)
{
if($value->show)
{
$this->datatable->printHead($value, $orderBy, $vars);
$columns ++;
}
}
?>
</tr>
</thead>
<tbody>
<?php foreach($runs as $run):?>
<tr class='text-center' data-id='<?php echo $run->case?>'>
<?php foreach($setting as $key => $value) $this->testtask->printCell($value, $run, $users, $task, $branches, $useDatatable ? 'datatable' : 'table');?>
</tr>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan='<?php echo $columns?>'>
<?php if($runs):?>
<div class='table-actions clearfix'>
<?php if($hasCheckbox) echo html::selectButton();?>
<div class='btn-group dropup'>
<?php
$actionLink = $this->createLink('testcase', 'batchEdit', "productID=$productID");
$misc = $canBatchEdit ? "onclick=\"setFormAction('$actionLink')\"" : "disabled='disabled'";
echo html::commonButton($lang->edit, $misc);
?>
<button type='button' class='btn dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>
<ul class='dropdown-menu'>
<?php
$actionLink = $this->createLink('testtask', 'batchUnlinkCases', "taskID=$task->id");
$misc = common::hasPriv('testtask', 'batchUnlinkCases') ? "onclick=\"setFormAction('$actionLink')\"" : "class='disabled'";
echo "<li>" . html::a('javascript:;', $lang->testtask->unlinkCase, '', $misc) . "</li>";
?>
</ul>
</div>
$setting = $this->datatable->getSetting('testtask');
$widths = $this->datatable->setFixedFieldWidth($setting);
$columns = 0;
?>
<table class='table has-sort-table' id='caseList'>
<thead>
<tr>
<?php
foreach($setting as $key => $value)
{
if($value->show)
{
$this->datatable->printHead($value, $orderBy, $vars);
$columns ++;
}
}
?>
</tr>
</thead>
<tbody>
<?php foreach($runs as $run):?>
<tr>
<?php foreach($setting as $key => $value) $this->testtask->printCell($value, $run, $users, $task, $branches, $useDatatable ? 'datatable' : 'table');?>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php if($runs):?>
<div class='table-footer'>
<?php if($hasCheckbox):?>
<div class="checkbox-primary check-all"><label><?php echo $lang->selectAll?></label></div>
<div class='table-actions btn-toolbar'>
<div class='btn-group dropup'>
<?php
$actionLink = $this->createLink('testcase', 'batchEdit', "productID=$productID");
$misc = $canBatchEdit ? "onclick=\"setFormAction('$actionLink')\"" : "disabled='disabled'";
echo html::commonButton($lang->edit, $misc);
?>
<?php if($canBatchUnlink):?>
<button type='button' class='btn dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>
<ul class='dropdown-menu'>
<?php
if($canBatchAssign)
{
$actionLink = inLink('batchAssign', "taskID=$task->id");
echo "<div class='input-group w-200px'>";
echo html::select('assignedTo', $assignedTos, '', 'class="form-control chosen"');
echo "<span class='input-group-addon'>";
echo html::a("javascript:setFormAction(\"$actionLink\")", $lang->testtask->assign);
echo '</span></div>';
}
if($canBatchRun)
{
$actionLink = inLink('batchRun', "productID=$productID&orderBy=id_desc&from=testtask&taskID=$taskID");
echo html::commonButton($lang->testtask->runCase, "onclick=\"setFormAction('$actionLink')\"");
}
$actionLink = $this->createLink('testtask', 'batchUnlinkCases', "taskID=$task->id");
$misc = "onclick=\"setFormAction('$actionLink')\"";
echo "<li>" . html::a('javascript:;', $lang->testtask->unlinkCase, '', $misc) . "</li>";
?>
</div>
</ul>
<?php endif;?>
<?php echo $pager->show();?>
</td>
</tr>
</tfoot>
</table>
</form>
</div>
<?php if($canBatchAssign):?>
<div class="btn-group dropup">
<button data-toggle="dropdown" type="button" class="btn"><?php echo $lang->testtask->assign;?> <span class="caret"></span></button>
<div class="dropdown-menu search-list" data-ride="searchList">
<?php
$withSearch = count($assignedTos) > 10;
$actionLink = inLink('batchAssign', "taskID=$task->id");
echo html::select('assignedTo', $assignedTos, '', 'class="hidden"');
if($withSearch):
?>
<div class="input-control search-box search-box-circle has-icon-left has-icon-right search-example">
<input id="userSearchBox" type="search" autocomplete="off" class="form-control search-input">
<label for="userSearchBox" class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label>
<a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a>
</div>
<?php endif;?>
<div class="list-group">
<?php foreach ($assignedTos as $key => $value):?>
<?php
if(empty($key) or $key == 'closed') continue;
echo html::a("javascript:$(\"#assignedTo\").val(\"$key\");setFormAction(\"$actionLink\", \"hiddenwin\")", $value);
?>
<?php endforeach;?>
</div>
</div>
</div>
<?php endif;?>
<?php
if($canBatchRun)
{
$actionLink = inLink('batchRun', "productID=$productID&orderBy=id_desc&from=testtask&taskID=$taskID");
echo html::commonButton($lang->testtask->runCase, "onclick=\"setFormAction('$actionLink')\"");
}
?>
</div>
<?php endif;?>
<?php echo $pager->show('right', 'pagerjs');?>
</div>
<?php endif;?>
</form>
</div>
</div>
<script>
$('#module' + moduleID).addClass('active');
$('#' + taskCaseBrowseType + 'Tab').addClass('active');
$('#' + taskCaseBrowseType + 'Tab').addClass('btn-active-text');
<?php if($browseType == 'bysearch'):?>
$shortcut = $('#QUERY<?php echo (int)$param;?>Tab');
if($shortcut.size() > 0)