Merge branch 'sprint/211_liumengyi_59482' into 'master'

* Finish task #59482.

See merge request easycorp/zentaopms!4395
This commit is contained in:
王怡栋
2022-07-07 01:49:35 +00:00
6 changed files with 168 additions and 93 deletions

View File

@@ -1042,7 +1042,9 @@ class execution extends control
* Execution case list.
*
* @param int $executionID
* @param int $productID
* @param string $type
* @param int $moduleID
* @param string $orderBy
* @param int $recTotal
* @param int $recPerPage
@@ -1050,28 +1052,45 @@ class execution extends control
* @access public
* @return void
*/
public function testcase($executionID = 0, $type = 'all', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function testcase($executionID = 0, $productID = 0, $type = 'all', $moduleID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$this->loadModel('testcase');
$this->loadModel('testtask');
$this->loadModel('tree');
$this->commonAction($executionID);
$uri = $this->app->getURI(true);
$this->session->set('caseList', $uri, 'execution');
$this->session->set('bugList', $uri, 'execution');
$products = $this->product->getProducts($executionID);
$productID = key($products); // Get the first product for creating testcase.
$products = $this->product->getProducts($executionID, 'all', '', false);
if(count($products) == 1) $productID = key($products);
$extra = $executionID;
$this->lang->modulePageNav = $this->product->select(array('0' => $this->lang->product->all) + $products, $productID, 'execution', 'testcase', $extra, 0, 0, '', false);
/* Load pager. */
$this->app->loadClass('pager', $static = true);
$pager = pager::init($recTotal, $recPerPage, $pageID);
$cases = $this->loadModel('testcase')->getExecutionCases($executionID, $orderBy, $pager, $type);
$cases = $this->loadModel('testcase')->getExecutionCases($executionID, $productID, $moduleID, $orderBy, $pager, $type);
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false);
$cases = $this->testcase->appendData($cases, 'case');
$cases = $this->loadModel('story')->checkNeedConfirm($cases);
$modules = $this->tree->getAllModulePairs('case');
/* Get module tree.*/
if($executionID and empty($productID))
{
$moduleTree = $this->tree->getCaseTreeMenu($executionID, $productID, 0, array('treeModel', 'createCaseLink'));
}
else
{
$moduleTree = $this->tree->getTreeMenu($productID, 'case', 0, array('treeModel', 'createCaseLink'), array('executionID' => $executionID, 'productID' => $productID), 'all');
}
$tree = $moduleID ? $this->tree->getByID($moduleID) : '';
$this->view->title = $this->lang->execution->testcase;
$this->view->executionID = $executionID;
$this->view->productID = $productID;
@@ -1081,6 +1100,10 @@ class execution extends control
$this->view->type = $type;
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->execution = $this->execution->getByID($executionID);
$this->view->moduleTree = $moduleTree;
$this->view->modules = $modules;
$this->view->moduleID = $moduleID;
$this->view->moduleName = $moduleID ? $tree->name : $this->lang->tree->all;
$this->display();
}

View File

@@ -1,2 +1,3 @@
.c-id, .c-pri {width: 50px;}
.c-result {width: 80px;}
#pageNav #dropMenu .col-left {padding-bottom: 0px;}

View File

@@ -1,87 +1,120 @@
<?php include '../../common/view/header.html.php';?>
<div id="mainMenu" class="clearfix">
<div id="mainMenu" class="clearfix main-row fade in">
<div id="sidebarHeader">
<div class="title" title="<?php echo $moduleName;?>">
<?php
echo $moduleName;
if(!empty($moduleID))
{
$removeLink = $this->createLink('execution', 'testcase', "executionID=$executionID&productID=$productID&type=all&moduleID=0&orderBy=$orderBy&recTotal=0&recPerPage={$pager->recPerPage}");
echo html::a($removeLink, "<i class='icon icon-sm icon-close'></i>", '', "class='text-muted' data-app='{$this->app->tab}'");
}
?>
</div>
</div>
<div class="btn-toolbar pull-left">
<?php echo html::a(inlink('testcase', "executionID=$executionID&type=$type&orderBy=$orderBy"), "<span class='text'>{$lang->execution->all}</span>", '', "class='btn btn-link btn-active-text'");?>
<?php echo html::a(inlink('testcase', "executionID=$executionID&productID=$productID&type=$type&moduleID=$moduleID&orderBy=$orderBy"), "<span class='text'>{$lang->execution->all}</span>", '', "class='btn btn-link btn-active-text'");?>
</div>
<div class="btn-toolbar pull-right">
<?php if(common::canModify('execution', $execution)) echo html::a(helper::createLink('testcase', 'create', "productID=$productID&branch=0&moduleID=0&from=execution&param=$execution->id", '', '', '', true), "<i class='icon icon-plus'></i> " . $lang->testcase->create, '', "class='btn btn-primary' data-app='{$this->app->tab}'");?>
</div>
</div>
<div id="mainContent">
<?php if(empty($cases)):?>
<div class="table-empty-tip">
<p>
<span class="text-muted"><?php echo $lang->testcase->noCase;?></span>
<?php if(common::canModify('execution', $execution) and common::hasPriv('testcase', 'create')):?>
<?php echo html::a(helper::createLink('testcase', 'create', "productID=$productID&branch=0&moduleID=0&from=execution&param=$execution->id", '', '', '', true), "<i class='icon icon-plus'></i> " . $lang->testcase->create, '', "class='btn btn-info' data-app='{$this->app->tab}'");?>
<div id="mainContent" class='main-row split-row fade'>
<div class="side-col" id='sidebar' data-min-width='235'>
<div class="sidebar-toggle"><i class="icon icon-angle-left"></i></div>
<div class='cell'>
<?php if(!$moduleTree):?>
<hr class="space">
<div class="text-center text-muted"><?php echo $lang->testcase->noModule;?></div>
<hr class="space">
<?php else:?>
<?php echo $moduleTree;?>
<?php endif;?>
</p>
</div>
</div>
<?php else:?>
<form class='main-table' method='post' id='executionBugForm' data-ride="table">
<table class='table has-sort-head' id='bugList'>
<?php $vars = "executionID=$executionID&type=$type&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
<thead>
<tr>
<th class='w-id'> <?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
<th class='c-pri' title=<?php echo $lang->execution->pri;?>> <?php common::printOrderLink('pri', $orderBy, $vars, $lang->priAB);?></th>
<th> <?php common::printOrderLink('title', $orderBy, $vars, $lang->testcase->title);?></th>
<th class='c-type'> <?php common::printOrderLink('type', $orderBy, $vars, $lang->typeAB);?></th>
<th class='c-user'> <?php common::printOrderLink('openedBy', $orderBy, $vars, $lang->openedByAB);?></th>
<th class='c-user'> <?php common::printOrderLink('lastRunner', $orderBy, $vars, $lang->testtask->lastRunAccount);?></th>
<th class='c-date'> <?php common::printOrderLink('lastRunDate', $orderBy, $vars, $lang->testtask->lastRunTime);?></th>
<th class='c-result'><?php common::printOrderLink('lastRunResult', $orderBy, $vars, $lang->testtask->lastRunResult);?></th>
<th class='c-status'><?php common::printOrderLink('status', $orderBy, $vars, $lang->statusAB);?></th>
<th class='c-actions-6 text-center'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach($cases as $case):?>
<?php
$caseID = $type == 'assigntome' ? $case->case : $case->id;
$runID = $type == 'assigntome' ? $case->id : 0;
?>
<tr>
<td class="c-id">
<?php echo sprintf('%03d', $case->id); ?>
</td>
<td><span class='label-pri <?php echo 'label-pri-' . $case->pri?>' title='<?php echo zget($lang->testcase->priList, $case->pri, $case->pri);?>'><?php echo zget($lang->testcase->priList, $case->pri, $case->pri)?></span></td>
<?php $params = "testcaseID=$caseID&version=$case->version";?>
<?php if($type == 'assigntome') $params .= "&from=testtask&taskID=$case->task";?>
<td class='c-title text-left' title="<?php echo $case->title?>"><?php echo html::a($this->createLink('testcase', 'view', $params, '', '', $case->project), $case->title, null, "style='color: $case->color' data-app='{$this->app->tab}'");?></td>
<td><?php echo zget($lang->testcase->typeList, $case->type);?></td>
<td><?php echo zget($users, $case->openedBy);?></td>
<td><?php echo zget($users, $case->lastRunner);?></td>
<td><?php if(!helper::isZeroDate($case->lastRunDate)) echo substr($case->lastRunDate, 5, 11);?></td>
<td class='<?php echo $case->lastRunResult;?>'><?php if($case->lastRunResult) echo $lang->testcase->resultList[$case->lastRunResult];?></td>
<td>
<div class='main-col' data-min-width='400'>
<?php if(empty($cases)):?>
<div class="table-empty-tip">
<p>
<span class="text-muted"><?php echo $lang->testcase->noCase;?></span>
<?php if(common::canModify('execution', $execution) and common::hasPriv('testcase', 'create')):?>
<?php echo html::a(helper::createLink('testcase', 'create', "productID=$productID&branch=0&moduleID=0&from=execution&param=$execution->id", '', '', '', true), "<i class='icon icon-plus'></i> " . $lang->testcase->create, '', "class='btn btn-info' data-app='{$this->app->tab}'");?>
<?php endif;?>
</p>
</div>
<?php else:?>
<form class='main-table' method='post' id='executionBugForm' data-ride="table">
<table class='table has-sort-head' id='bugList'>
<?php $vars = "executionID=$executionID&productID=$productID&type=$type&moduleID=$moduleID&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
<thead>
<tr>
<th class='w-id'> <?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
<th class='c-pri' title=<?php echo $lang->execution->pri;?>> <?php common::printOrderLink('pri', $orderBy, $vars, $lang->priAB);?></th>
<th> <?php common::printOrderLink('title', $orderBy, $vars, $lang->testcase->title);?></th>
<th class='c-type'> <?php common::printOrderLink('type', $orderBy, $vars, $lang->typeAB);?></th>
<th class='c-user'> <?php common::printOrderLink('openedBy', $orderBy, $vars, $lang->openedByAB);?></th>
<th class='c-user'> <?php common::printOrderLink('lastRunner', $orderBy, $vars, $lang->testtask->lastRunAccount);?></th>
<th class='c-date'> <?php common::printOrderLink('lastRunDate', $orderBy, $vars, $lang->testtask->lastRunTime);?></th>
<th class='c-result'><?php common::printOrderLink('lastRunResult', $orderBy, $vars, $lang->testtask->lastRunResult);?></th>
<th class='c-status'><?php common::printOrderLink('status', $orderBy, $vars, $lang->statusAB);?></th>
<th class='c-actions-6 text-center'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach($cases as $case):?>
<?php
if($case->needconfirm)
{
echo "<span class='status-story status-changed' title='{$this->lang->story->changed}'>{$this->lang->story->changed}</span>";
}
elseif(isset($case->fromCaseVersion) and $case->fromCaseVersion > $case->version and !$case->needconfirm)
{
echo "<span class='status-story status-changed' title='{$this->lang->testcase->changed}'>{$this->lang->testcase->changed}</span>";
}
else
{
echo "<span class='status-testcase status-{$case->status}'>" . $this->processStatus('testcase', $case) . "</span>";
}
$caseID = $type == 'assigntome' ? $case->case : $case->id;
$runID = $type == 'assigntome' ? $case->id : 0;
?>
</td>
<td class='c-actions'>
<tr>
<td class="c-id">
<?php echo sprintf('%03d', $case->id); ?>
</td>
<td><span class='label-pri <?php echo 'label-pri-' . $case->pri?>' title='<?php echo zget($lang->testcase->priList, $case->pri, $case->pri);?>'><?php echo zget($lang->testcase->priList, $case->pri, $case->pri)?></span></td>
<?php $params = "testcaseID=$caseID&version=$case->version";?>
<?php if($type == 'assigntome') $params .= "&from=testtask&taskID=$case->task";?>
<td class='c-title text-left' title="<?php echo $case->title?>"><?php echo html::a($this->createLink('testcase', 'view', $params, '', '', $case->project), $case->title, null, "style='color: $case->color' data-app='{$this->app->tab}'");?></td>
<td><?php echo zget($lang->testcase->typeList, $case->type);?></td>
<td><?php echo zget($users, $case->openedBy);?></td>
<td><?php echo zget($users, $case->lastRunner);?></td>
<td><?php if(!helper::isZeroDate($case->lastRunDate)) echo substr($case->lastRunDate, 5, 11);?></td>
<td class='<?php echo $case->lastRunResult;?>'><?php if($case->lastRunResult) echo $lang->testcase->resultList[$case->lastRunResult];?></td>
<td>
<?php
$case->browseType = $type;
echo $this->testcase->buildOperateMenu($case, 'browse');
if($case->needconfirm)
{
echo "<span class='status-story status-changed' title='{$this->lang->story->changed}'>{$this->lang->story->changed}</span>";
}
elseif(isset($case->fromCaseVersion) and $case->fromCaseVersion > $case->version and !$case->needconfirm)
{
echo "<span class='status-story status-changed' title='{$this->lang->testcase->changed}'>{$this->lang->testcase->changed}</span>";
}
else
{
echo "<span class='status-testcase status-{$case->status}'>" . $this->processStatus('testcase', $case) . "</span>";
}
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div class="table-footer"><?php $pager->show('right', 'pagerjs');?></div>
</form>
<?php endif;?>
</td>
<td class='c-actions'>
<?php
$case->browseType = $type;
echo $this->testcase->buildOperateMenu($case, 'browse');
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div class="table-footer"><?php $pager->show('right', 'pagerjs');?></div>
</form>
<?php endif;?>
</div>
</div>
<?php js::set('moduleID', $moduleID);?>
<script>
$(function()
{
$('#module' + moduleID).closest('li').addClass('active');
});
</script>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -93,6 +93,7 @@ class productModel extends model
}
$isMobile = $this->app->viewType == 'mhtml';
$productID = $productID == 'all' ? 0 : $productID;
setcookie("lastProduct", $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
if($productID) $currentProduct = $this->getById($productID);

View File

@@ -322,20 +322,25 @@ class testcaseModel extends model
* Get execution cases.
*
* @param int $executionID
* @param int $productID
* @param int $moduleID
* @param string $orderBy
* @param object $pager
* @param string $browseType all|wait|needconfirm
* @access public
* @return array
*/
public function getExecutionCases($executionID, $orderBy = 'id_desc', $pager = null, $browseType = '')
public function getExecutionCases($executionID, $productID = 0, $moduleID = 0, $orderBy = 'id_desc', $pager = null, $browseType = '')
{
if($browseType == 'needconfirm')
{
return $this->dao->select('distinct t1.*, t2.*')->from(TABLE_PROJECTCASE)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case=t2.id')
->leftJoin(TABLE_STORY)->alias('t3')->on('t2.story = t3.id')
->leftJoin(TABLE_MODULE)->alias('t4')->on('t2.module=t4.id')
->where('t1.project')->eq((int)$executionID)
->beginIF(!empty($productID))->andWhere('t1.product')->eq($productID)->fi()
->beginIF(!empty($moduleID))->andWhere('t4.path')->like("%,$moduleID,%")->fi()
->andWhere('t2.deleted')->eq('0')
->andWhere('t3.version > t2.storyVersion')
->andWhere("t3.status")->eq('active')
@@ -346,8 +351,11 @@ class testcaseModel extends model
return $this->dao->select('distinct t1.*, t2.*')->from(TABLE_PROJECTCASE)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case=t2.id')
->leftJoin(TABLE_MODULE)->alias('t3')->on('t2.module=t3.id')
->where('t1.project')->eq((int)$executionID)
->beginIF($browseType != 'all')->andWhere('t2.status')->eq($browseType)->fi()
->beginIF($browseType != 'all' and $browseType != 'byModule')->andWhere('t2.status')->eq($browseType)->fi()
->beginIF(!empty($productID))->andWhere('t1.product')->eq($productID)->fi()
->beginIF(!empty($moduleID))->andWhere('t3.path')->like("%,$moduleID,%")->fi()
->andWhere('t2.deleted')->eq('0')
->orderBy($orderBy)
->page($pager)

View File

@@ -404,9 +404,10 @@ class treeModel extends model
$this->loadModel('branch');
$projectID = zget($extra, 'projectID', 0);
$executionID = zget($extra, 'executionID', 0);
$branches = array($branch => '');
$executionModules = array();
if($branch and empty($projectID))
if($branch and empty($projectID) and empty($extra['executionID']))
{
$branchName = $this->branch->getById($branch);
$branches = array($branch => $branchName);
@@ -416,11 +417,16 @@ class treeModel extends model
$manage = $userFunc[1] == 'createManageLink' ? true : false;
$product = $this->loadModel('product')->getById($rootID);
$onlyGetLinked = ($projectID and $this->config->vision != 'lite');
if(strpos('story|bug|case', $type) !== false and $branch === 'all' and empty($projectID))
$onlyGetLinked = (($projectID or $executionID) and $this->config->vision != 'lite');
if(strpos('story|bug|case', $type) !== false and $branch === 'all' and empty($projectID) and empty($executionID))
{
if($product->type != 'normal') $branches = array(BRANCH_MAIN => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($rootID, 'noempty');
}
elseif($type == 'case' and $this->app->tab == 'execution')
{
if($product->type != 'normal' and $executionID) $branches += $this->branch->getPairs($product->id, 'noempty', $executionID);
if($onlyGetLinked) $executionModules = $this->getTaskTreeModules($executionID, true, $type);
}
elseif(($type == 'story' and $this->app->rawModule == 'projectstory') or ($type == 'case' and $this->app->tab == 'project'))
{
if($product->type != 'normal' and $projectID) $branches += $this->branch->getPairs($product->id, 'noempty', $projectID);
@@ -721,10 +727,10 @@ class treeModel extends model
*/
public function getCaseTreeMenu($rootID, $productID = 0, $startModule = 0, $userFunc = '', $extra = '')
{
$extra = array('projectID' => $rootID, 'productID' => $productID, 'tip' => true, 'extra' => $extra);
$extra = array('projectID' => $rootID, 'executionID' => $rootID, 'productID' => $productID, 'tip' => true, 'extra' => $extra);
/* If createdVersion <= 4.1, go to getTreeMenu(). */
$products = $this->loadModel('product')->getProductPairsByProject($rootID);
$products = $this->app->tab != 'execution' ? $this->loadModel('product')->getProductPairsByProject($rootID) : $this->loadModel('product')->getProducts($rootID);
$branchGroups = $this->dao->select('t1.product as product,branch,t3.name')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id')
->leftJoin(TABLE_BRANCH)->alias('t3')->on('t1.branch=t3.id')
@@ -734,6 +740,7 @@ class treeModel extends model
->andWhere('t2.deleted')->eq('0')
->fetchGroup('product', 'branch');
$this->app->loadLang('branch');
foreach($branchGroups as $productID => $branches)
{
foreach($branches as $branchID => $branchInfo)
@@ -756,15 +763,16 @@ class treeModel extends model
$executionModules = $this->getTaskTreeModules($rootID, true, 'case');
/* Get module according to product. */
$productNum = count($products);
$moduleName = $this->app->tab == 'project' ? 'project' : 'testcase';
$methodName = $this->app->tab == 'project' ? 'testcase' : 'browse';
$projectParam = $this->app->tab == 'project' ? "projectID={$this->session->project}&" : '';
$productNum = count($products);
$moduleName = strpos(',project,execution,', ",{$this->app->tab},") !== false ? $this->app->tab : 'testcase';
$methodName = strpos(',project,execution,', ",{$this->app->tab},") !== false ? 'testcase' : 'browse';
$param = $this->app->tab == 'project' ? "projectID={$this->session->project}&" : '';
$param = $this->app->tab == 'execution' ? "executionID={$rootID}&" : $param;
foreach($products as $id => $product)
{
$extra['productID'] = $id;
$link = helper::createLink($moduleName, $methodName, $projectParam . "productID=$id");
$menu .= "<li>" . html::a($link, $product, '_self', "id='product$id' data-app='project'");
$link = helper::createLink($moduleName, $methodName, $param . "productID=$id");
$menu .= "<li>" . html::a($link, is_object($product) ? $product->name : $product, '_self', "id='product$id' data-app='{$this->app->tab}'");
/* tree menu. */
$tree = '';
@@ -1202,10 +1210,11 @@ class treeModel extends model
*/
public function createCaseLink($type, $module, $extra = array())
{
$moduleName = $this->app->tab == 'project' ? 'project' : 'testcase';
$methodName = $this->app->tab == 'project' ? 'testcase' : 'browse';
$projectParam = $this->app->tab == 'project' ? "projectID={$this->session->project}&" : '';
return html::a(helper::createLink($moduleName, $methodName, $projectParam . "root={$module->root}&branch={$extra['branchID']}&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}' data-app='{$this->app->tab}' title='{$module->name}'");
$moduleName = strpos(',project,execution,', ",{$this->app->tab},") !== false ? $this->app->tab : 'testcase';
$methodName = strpos(',project,execution,', ",{$this->app->tab},") !== false ? 'testcase' : 'browse';
$param = $this->app->tab == 'project' ? "projectID={$this->session->project}&root={$module->root}&branch={$extra['branchID']}&" : "root={$module->root}&branch={$extra['branchID']}&";
$param = $this->app->tab == 'execution' ? "executionID={$extra['executionID']}&root={$module->root}&" : $param;
return html::a(helper::createLink($moduleName, $methodName, $param . "&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}' data-app='{$this->app->tab}' title='{$module->name}'");
}
/**