This commit is contained in:
tianshujie
2022-04-21 15:52:57 +08:00
parent 9240a007d7
commit edbc8e5d0b
9 changed files with 212 additions and 179 deletions
+1
View File
@@ -563,6 +563,7 @@ class productModel extends model
if($currentModule == 'product' and strpos($this->config->product->showBranchMethod, $currentMethod) !== false) $isShowBranch = true;
if($this->app->tab == 'qa' and strpos(',testsuite,testreport,testtask,', ",$currentModule,") === false) $isShowBranch = true;
if($this->app->tab == 'qa' and $currentModule == 'testtask' and strpos(',create,edit,browseunits,importunitresult,unitcases,', ",$currentMethod,") === false) $isShowBranch = true;
if($currentModule == 'testcase' and $currentMethod == 'showimport') $isShowBranch = false;
if($isShowBranch)
{
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$currentProduct->type]);
+2 -2
View File
@@ -2093,7 +2093,7 @@ class testcase extends control
$this->view->stories = $stories;
$this->view->modules = $modules;
$this->view->cases = $this->dao->select('id, module, story, stage, status, pri, type')->from(TABLE_CASE)->where('product')->eq($productID)->andWhere('deleted')->eq(0)->fetchAll('id');
$this->view->cases = $this->testcase->getByProduct($productID);
$this->view->caseData = $caseData;
$this->view->stepData = $stepData;
$this->view->productID = $productID;
@@ -2103,7 +2103,7 @@ class testcase extends control
$this->view->allPager = $allPager;
$this->view->pagerID = $pagerID;
$this->view->branch = $branch;
$this->view->product = $this->products[$productID];
$this->view->product = $this->product->getByID($productID);
$this->view->maxImport = $maxImport;
$this->view->dataInsert = $insert;
+2
View File
@@ -1,8 +1,10 @@
.table table td,.outer .table table tbody > tr:last-child td {padding: 2px 0 2px 5px !important; border: none !important;}
.c-branch {width: 120px;}
.c-line-number {width: 50px;}
.c-id {width: 40px;}
.c-story, .c-module, .c-type {width: 120px;}
.c-stage {width: 160px;}
.c-condition {width: 80px;}
.c-step {width: 300px;}
.form-actions .btn {margin-right: 20px;}
.table td textarea {height: 32px;}
-35
View File
@@ -27,38 +27,3 @@ $(document).ready(function()
}
});
});
/**
* Set modules.
*
* @param int $branchID
* @param int $productID
* @param int $num
* @access public
* @return void
*/
function setModules(branchID, productID, num)
{
moduleLink = createLink('tree', 'ajaxGetModules', 'productID=' + productID + '&viewType=story&branch=' + branchID + '&num=' + num);
$.get(moduleLink, function(modules)
{
if(!modules) modules = '<select id="module' + num + '" name="module[' + num + ']" class="form-control"></select>';
$('#module' + num).replaceWith(modules);
$("#module" + num + "_chosen").remove();
$("#module" + num).next('.picker').remove();
$("#module" + num).attr('onchange', "loadStories("+ productID + ", this.value, " + num + ")").chosen();
});
loadStories(productID, 0, num);
/* If the branch of the current row is inconsistent with the one below, clear the module and story of the nex row. */
var nextBranchID = $('#branch' + (num + 1)).val();
if(nextBranchID != branchID)
{
$('#module' + (num + 1)).find("option[value='ditto']").remove();
$('#module' + (num + 1)).trigger("chosen:updated");
$('#plan' + (num + 1)).find("option[value='ditto']").remove();
$('#plan' + (num + 1)).trigger("chosen:updated");
}
}
+35
View File
@@ -390,3 +390,38 @@ function loadStories(productID, moduleID, num)
}
});
}
/**
* Set modules.
*
* @param int $branchID
* @param int $productID
* @param int $num
* @access public
* @return void
*/
function setModules(branchID, productID, num)
{
moduleLink = createLink('tree', 'ajaxGetModules', 'productID=' + productID + '&viewType=story&branch=' + branchID + '&num=' + num);
$.get(moduleLink, function(modules)
{
if(!modules) modules = '<select id="module' + num + '" name="module[' + num + ']" class="form-control"></select>';
$('#module' + num).replaceWith(modules);
$("#module" + num + "_chosen").remove();
$("#module" + num).next('.picker').remove();
$("#module" + num).attr('onchange', "loadStories("+ productID + ", this.value, " + num + ")").chosen();
});
loadStories(productID, 0, num);
/* If the branch of the current row is inconsistent with the one below, clear the module and story of the nex row. */
var nextBranchID = $('#branch' + (num + 1)).val();
if(nextBranchID != branchID)
{
$('#module' + (num + 1)).find("option[value='ditto']").remove();
$('#module' + (num + 1)).trigger("chosen:updated");
$('#plan' + (num + 1)).find("option[value='ditto']").remove();
$('#plan' + (num + 1)).trigger("chosen:updated");
}
}
+12
View File
@@ -10,6 +10,12 @@ $("[name^='branch']").each(function()
$(this).attr('id', 'branch' + id.match(/\d+/));
});
$("[name^='module']").each(function()
{
var id = $(this).attr('id');
$(this).attr('id', 'module' + id.match(/\d+/));
});
$("[name^='story']").each(function()
{
var id = $(this).attr('id');
@@ -19,6 +25,7 @@ $("[name^='story']").each(function()
var moduleID = $('#module' + num).val();
var storyID = $("#story" + num).val();
var storyLink = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branchID + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50&type=full&hasParent=1&executionID=0&number=' + num);
$.get(storyLink, function(stories)
{
if(!stories) stories = '<select id="story' + num + '" name="story[' + num + ']" class="form-control"></select>';
@@ -29,3 +36,8 @@ $("[name^='story']").each(function()
$('#story' + num).val(storyID).trigger('chosen:updated');
});
});
$(function()
{
if(parseInt($('.c-name').css('width')) < 90) $('.c-name').css('width', '90px');
});
+15
View File
@@ -643,6 +643,21 @@ class testcaseModel extends model
return $this->appendData($cases);
}
/**
* Get cases by product id.
*
* @param int $productID
* @access public
* @return array
*/
public function getByProduct($productID)
{
return $this->dao->select('*')->from(TABLE_CASE)
->where('deleted')->eq(0)
->andWhere('product')->eq($productID)
->fetchAll('id');
}
/**
* Get cases of a story.
*
+4 -10
View File
@@ -133,21 +133,15 @@
</div>
<?php endif;?>
<?php if(empty($productID) or common::canModify('product', $product)):?>
<?php if(!empty($productID)): ?>
<?php if(!empty($productID) and (common::hasPriv('testcase', 'import') or common::hasPriv('testcase', 'importFromLib'))): ?>
<div class='btn-group'>
<button type='button' class='btn btn-link dropdown-toggle' data-toggle='dropdown' id='importAction'><i class='icon icon-import muted'></i> <?php echo $lang->import ?><span class='caret'></span></button>
<ul class='dropdown-menu pull-right' id='importActionMenu'>
<?php
$printImportBtn = (common::hasPriv('testcase', 'import') and $branch !== 'all') ? true : false;
$class = $printImportBtn ? '' : "class=disabled";
$misc = $printImportBtn ? "class='export'" : "class=disabled";
$link = $printImportBtn ? $this->createLink('testcase', 'import', "productID=$productID&branch=$branch") : '#';
echo "<li $class>" . html::a($link, $lang->testcase->fileImport, '', $misc . "data-app={$this->app->tab}") . "</li>";
if(common::hasPriv('testcase', 'import')) echo "<li>" . html::a($this->createlink('testcase', 'import', "productID=$productID&branch=$branch"), $lang->testcase->fileImport, '', "class='export' data-app={$app->tab}") . "</li>";
$class = common::hasPriv('testcase', 'importFromLib') ? '' : "class=disabled";
$misc = common::hasPriv('testcase', 'importFromLib') ? "data-app='{$this->app->tab}'" : "class=disabled";
$link = common::hasPriv('testcase', 'importFromLib') ? $this->createLink('testcase', 'importFromLib', "productID=$productID&branch=$branch&libID=0&orderBy=id_desc&browseType=&queryID=10&recTotal=0&recPerPage=20&pageID=1&projectID=$projectID") : '#';
echo "<li $class>" . html::a($link, $lang->testcase->importFromLib, '', $misc . "data-app={$this->app->tab}") . "</li>";
$link = $this->createLink('testcase', 'importFromLib', "productID=$productID&branch=$branch&libID=0&orderBy=id_desc&browseType=&queryID=10&recTotal=0&recPerPage=20&pageID=1&projectID=$projectID");
if(common::hasPriv('testcase', 'importFromLib')) echo "<li>" . html::a($link, $lang->testcase->importFromLib, '', "data-app={$app->tab}") . "</li>";
?>
</ul>
</div>
+141 -132
View File
@@ -18,149 +18,158 @@ $(function()
{
if(parseInt($('#maxImport').val())) $('#times').html(Math.ceil(parseInt($('#allCount').html()) / parseInt($('#maxImport').val())));
});
$('#import').click(function(){location.href = createLink('testcase', 'showImport', "productID=<?php echo $productID;?>&branch=<?php echo $branch?>&pageID=1&maxImport=" + $('#maxImport').val())})
$('#import').click(function(){location.href = createLink('testcase', 'showImport', "productID=<?php echo $productID;?>&branch=<?php echo $branch?>&pageID=1&maxImport=" + $('#maxImport').val())});
});
</script>
<?php else:?>
<div id="mainContent" class="main-content">
<div id="mainContent" class="main-content fade">
<div class="main-header clearfix">
<h2><?php echo $lang->testcase->import;?></h2>
</div>
<form target='hiddenwin' method='post'>
<table class='table table-form' id='showData'>
<thead>
<tr>
<th class='c-line-number'><?php echo $lang->lineNumber?></th>
<th class='c-id'><?php echo $lang->idAB?></th>
<th class='required'><?php echo $lang->testcase->title?></th>
<th class='c-module'><?php echo $lang->testcase->module?></th>
<th class='c-story'><?php echo $lang->testcase->story?></th>
<th class='c-pri-box'><?php echo $lang->testcase->pri?></th>
<th class='c-type required'><?php echo $lang->testcase->type?></th>
<th class='c-stage'><?php echo $lang->testcase->stage?></th>
<th><?php echo $lang->testcase->precondition?></th>
<?php if(!empty($appendFields)):?>
<?php foreach($appendFields as $appendField):?>
<th class='c-extend'><?php echo $lang->testcase->{$appendField->field}?></th>
<?php endforeach;?>
<?php endif;?>
<th class='c-step'>
<table class='w-p100 table-borderless'>
<tr>
<th class="no-padding"><?php echo $lang->testcase->stepDesc?></th>
<th class="no-padding"><?php echo $lang->testcase->stepExpect?></th>
</tr>
</table>
</th>
</tr>
</thead>
<tbody>
<?php
$insert = true;
$addID = 1;
?>
<?php foreach($caseData as $key => $case):?>
<?php if(empty($case->title)) continue;?>
<tr valign='top' class='text-left'>
<td><?php echo $addID;?></td>
<td>
<?php
if(!empty($case->id))
{
echo $case->id . html::hidden("id[$key]", $case->id);
$insert = false;
}
else
{
echo "<sub class='gray' style='vertical-align:sub;'>{$lang->testcase->new}</sub>";
}
echo html::hidden("product[$key]", $productID);
if(!empty($branches))
{
$branchID = $branch;
if(isset($case->branch)) $branchID = $case->branch;
if(!empty($case->id) and !empty($cases[$case->id]->branch)) $branchID = $cases[$case->id]->branch;
echo html::hidden("branch[$key]", $branchID);
}
echo html::hidden("keywords[$key]", isset($case->keywords) ? $case->keywords : "");
?>
</td>
<td><?php echo html::input("title[$key]", htmlSpecialString($case->title, ENT_QUOTES), "class='form-control'")?></td>
<td style='overflow:visible'>
<?php $caseModules = (isset($case->branch) and $case->branch != 0) ? $modules[BRANCH_MAIN] + $modules[$case->branch] : $modules[BRANCH_MAIN];?>
<?php echo html::select("module[$key]", $caseModules, isset($case->module) ? $case->module : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->module : ''), "class='form-control chosen moduleChange' onchange='loadStories($productID, this.value, $key)'")?>
</td>
<td style='overflow:visible'>
<?php $storyID = isset($case->story) ? $case->story : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->story : '');?>
<?php echo html::select("story[$key]", array($storyID => zget($stories, $storyID, '')), $storyID, "class='form-control chosen storyChange'")?></td>
<td><?php echo html::select("pri[$key]", $lang->testcase->priList, isset($case->pri) ? $case->pri : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->pri : ''), "class='form-control chosen'")?></td>
<td><?php echo html::select("type[$key]", $lang->testcase->typeList, isset($case->type) ? $case->type : '', "class='form-control chosen'")?></td>
<td style='overflow:visible'><?php echo html::select("stage[$key][]", $lang->testcase->stageList, !empty($case->stage) ? $case->stage : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->stage : ''), "multiple='multiple' class='form-control chosen'")?></td>
<td><?php echo html::textarea("precondition[$key]", isset($case->precondition) ? htmlSpecialString($case->precondition) : "", "class='form-control'")?></td>
<?php if(!empty($appendFields)):?>
<?php $this->loadModel('flow');?>
<?php foreach($appendFields as $appendField):?>
<td><?php echo $this->flow->buildControl($appendField, zget($case, $appendField->field, ''), "{$appendField->field}[$key]");?></td>
<?php endforeach;?>
<?php endif;?>
<td>
<?php if(isset($stepData[$key]['desc'])):?>
<table class='w-p100 bd-0'>
<?php $hasStep = false;?>
<?php foreach($stepData[$key]['desc'] as $id => $desc):?>
<?php if(empty($desc['content'])) continue;?>
<tr class='step'>
<?php $hasStep = true;?>
<td><?php echo $id . html::hidden("stepType[$key][$id]", $desc['type'])?></td>
<td><?php echo html::textarea("desc[$key][$id]", htmlSpecialString($desc['content']), "class='form-control'")?></td>
<td><?php if($desc['type'] != 'group') echo html::textarea("expect[$key][$id]", isset($stepData[$key]['expect'][$id]['content']) ? htmlSpecialString($stepData[$key]['expect'][$id]['content']) : '', "class='form-control'")?></td>
</tr>
<div class="table-responsive">
<table class='table table-form' id='showData'>
<thead>
<tr>
<th class='c-line-number'><?php echo $lang->lineNumber?></th>
<th class='c-id'><?php echo $lang->idAB?></th>
<?php if($product->type != 'normal'):?>
<th class='c-branch'><?php echo $lang->testcase->branch?></th>
<?php endif;?>
<th class='c-name required'><?php echo $lang->testcase->title?></th>
<th class='c-module'><?php echo $lang->testcase->module?></th>
<th class='c-story'><?php echo $lang->testcase->story?></th>
<th class='c-pri-box'><?php echo $lang->testcase->pri?></th>
<th class='c-type required'><?php echo $lang->testcase->type?></th>
<th class='c-stage'><?php echo $lang->testcase->stage?></th>
<th class='c-condition'><?php echo $lang->testcase->precondition?></th>
<?php if(!empty($appendFields)):?>
<?php foreach($appendFields as $appendField):?>
<th class='c-extend'><?php echo $lang->testcase->{$appendField->field}?></th>
<?php endforeach;?>
<?php if(!$hasStep):?>
<tr class='step'>
<td><?php echo '1' . html::hidden("stepType[$key][1]", 'step')?></td>
<td><?php echo html::textarea("desc[$key][1]", '', "class='form-control'")?></td>
<td><?php echo html::textarea("expect[$key][1]", '', "class='form-control'")?></td>
</tr>
<?php endif;?>
</table>
<?php else:?>
<table class='w-p100 bd-0'>
<tr class='step'>
<td><?php echo '1' . html::hidden("stepType[$key][1]", 'step')?></td>
<td><?php echo html::textarea("desc[$key][1]", '', "class='form-control'")?></td>
<td><?php echo html::textarea("expect[$key][1]", '', "class='form-control'")?></td>
</tr>
</table>
<?php endif;?>
</td>
</tr>
<?php $addID ++;?>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan='10' class='text-center form-actions'>
<th class='c-step'>
<table class='w-p100 table-borderless'>
<tr>
<th class="no-padding"><?php echo $lang->testcase->stepDesc?></th>
<th class="c-expect no-padding"><?php echo $lang->testcase->stepExpect?></th>
</tr>
</table>
</th>
</tr>
</thead>
<tbody>
<?php
$insert = true;
$addID = 1;
?>
<?php foreach($caseData as $key => $case):?>
<?php if(empty($case->title)) continue;?>
<tr valign='top' class='text-left'>
<td><?php echo $addID;?></td>
<td>
<?php
if(!empty($case->id))
{
echo $case->id . html::hidden("id[$key]", $case->id);
$insert = false;
}
else
{
echo "<sub class='gray' style='vertical-align:sub;'>{$lang->testcase->new}</sub>";
}
echo html::hidden("product[$key]", $productID);
echo html::hidden("keywords[$key]", isset($case->keywords) ? $case->keywords : "");
?>
</td>
<?php $branchID = $branch;?>
<?php if($product->type != 'normal'):?>
<?php
$submitText = $isEndPage ? $this->lang->save : $this->lang->file->saveAndNext;
if(!$insert and $dataInsert === '')
{
echo "<button type='button' data-toggle='modal' data-target='#importNoticeModal' class='btn btn-primary btn-wide'>{$submitText}</button>";
}
else
{
echo html::submitButton($submitText);
if($dataInsert !== '') echo html::hidden('insert', $dataInsert);
}
echo html::hidden('isEndPage', $isEndPage ? 1 : 0);
echo html::hidden('pagerID', $pagerID);
echo html::linkButton($lang->goback, $this->inlink('browse', "productID=$productID"), 'self', '', 'btn btn-wide');
echo sprintf($lang->file->importPager, $allCount, $pagerID, $allPager);
if(isset($case->branch)) $branchID = $case->branch;
if(!empty($case->id) and !empty($cases[$case->id]->branch)) $branchID = $cases[$case->id]->branch;
if(!isset($branches[$branchID])) $branchID = $branch;
?>
</td>
</tr>
</tfoot>
</table>
<td><?php echo html::select("branch[$key]", $branches, $branchID, "class='form-control chosen' onchange='setModules(this.value, $productID, $key)'");?></td>
<?php endif;?>
<td><?php echo html::input("title[$key]", htmlSpecialString($case->title, ENT_QUOTES), "class='form-control'")?></td>
<td style='overflow:visible'>
<?php
$caseModules = ($branchID and isset($modules[$branchID])) ? $modules[BRANCH_MAIN] + $modules[$branchID] : $modules[BRANCH_MAIN];
?>
<?php echo html::select("module[$key]", $caseModules, isset($case->module) ? $case->module : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->module : ''), "class='form-control chosen moduleChange' onchange='loadStories($productID, this.value, $key)'")?>
</td>
<td style='overflow:visible'>
<?php $storyID = isset($case->story) ? $case->story : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->story : '');?>
<?php echo html::select("story[$key]", array($storyID => zget($stories, $storyID, '')), $storyID, "class='form-control chosen storyChange'")?></td>
<td><?php echo html::select("pri[$key]", $lang->testcase->priList, isset($case->pri) ? $case->pri : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->pri : ''), "class='form-control chosen'")?></td>
<td><?php echo html::select("type[$key]", $lang->testcase->typeList, isset($case->type) ? $case->type : '', "class='form-control chosen'")?></td>
<td style='overflow:visible'><?php echo html::select("stage[$key][]", $lang->testcase->stageList, !empty($case->stage) ? $case->stage : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->stage : ''), "multiple='multiple' class='form-control chosen'")?></td>
<td><?php echo html::textarea("precondition[$key]", isset($case->precondition) ? htmlSpecialString($case->precondition) : "", "class='form-control'")?></td>
<?php if(!empty($appendFields)):?>
<?php $this->loadModel('flow');?>
<?php foreach($appendFields as $appendField):?>
<td><?php echo $this->flow->buildControl($appendField, zget($case, $appendField->field, ''), "{$appendField->field}[$key]");?></td>
<?php endforeach;?>
<?php endif;?>
<td>
<?php if(isset($stepData[$key]['desc'])):?>
<table class='w-p100 bd-0'>
<?php $hasStep = false;?>
<?php foreach($stepData[$key]['desc'] as $id => $desc):?>
<?php if(empty($desc['content'])) continue;?>
<tr class='step'>
<?php $hasStep = true;?>
<td><?php echo $id . html::hidden("stepType[$key][$id]", $desc['type'])?></td>
<td><?php echo html::textarea("desc[$key][$id]", htmlSpecialString($desc['content']), "class='form-control'")?></td>
<td><?php if($desc['type'] != 'group') echo html::textarea("expect[$key][$id]", isset($stepData[$key]['expect'][$id]['content']) ? htmlSpecialString($stepData[$key]['expect'][$id]['content']) : '', "class='form-control'")?></td>
</tr>
<?php endforeach;?>
<?php if(!$hasStep):?>
<tr class='step'>
<td><?php echo '1' . html::hidden("stepType[$key][1]", 'step')?></td>
<td><?php echo html::textarea("desc[$key][1]", '', "class='form-control'")?></td>
<td><?php echo html::textarea("expect[$key][1]", '', "class='form-control'")?></td>
</tr>
<?php endif;?>
</table>
<?php else:?>
<table class='w-p100 bd-0'>
<tr class='step'>
<td><?php echo '1' . html::hidden("stepType[$key][1]", 'step')?></td>
<td><?php echo html::textarea("desc[$key][1]", '', "class='form-control'")?></td>
<td><?php echo html::textarea("expect[$key][1]", '', "class='form-control'")?></td>
</tr>
</table>
<?php endif;?>
</td>
</tr>
<?php $addID ++;?>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan='10' class='text-center form-actions'>
<?php
$submitText = $isEndPage ? $this->lang->save : $this->lang->file->saveAndNext;
if(!$insert and $dataInsert === '')
{
echo "<button type='button' data-toggle='modal' data-target='#importNoticeModal' class='btn btn-primary btn-wide'>{$submitText}</button>";
}
else
{
echo html::submitButton($submitText);
if($dataInsert !== '') echo html::hidden('insert', $dataInsert);
}
echo html::hidden('isEndPage', $isEndPage ? 1 : 0);
echo html::hidden('pagerID', $pagerID);
echo html::linkButton($lang->goback, $this->inlink('browse', "productID=$productID"), 'self', '', 'btn btn-wide');
echo sprintf($lang->file->importPager, $allCount, $pagerID, $allPager);
?>
</td>
</tr>
</tfoot>
</table>
</div>
<?php if(!$insert and $dataInsert === '') include '../../common/view/noticeimport.html.php';?>
</form>
</div>