* Add testcase browse actions.
This commit is contained in:
@@ -17,6 +17,10 @@ $config->testcase->editor->review = array('id' => 'comment', 'tools' => 'simpleT
|
||||
$config->testcase->export = new stdclass();
|
||||
$config->testcase->export->listFields = array('type', 'stage', 'pri', 'status');
|
||||
|
||||
$config->testcase->actions = new stdclass();
|
||||
$config->testcase->actions->browse = 'results,runcase,edit,review,createBug,create,showscript';
|
||||
$config->testcase->actions->view = 'results,runcase';
|
||||
|
||||
$config->testcase->exportFields = '
|
||||
id, product, branch, module, story,
|
||||
title, precondition, stepDesc, stepExpect, real, keywords,
|
||||
|
||||
@@ -1,2 +1,22 @@
|
||||
<?php
|
||||
global $lang;
|
||||
$config->testcase->dtable = new stdclass();
|
||||
$config->testcase->dtable->fieldList['id']['name'] = 'id';
|
||||
$config->testcase->dtable->fieldList['id']['title'] = $lang->idAB;
|
||||
$config->testcase->dtable->fieldList['id']['type'] = 'checkID';
|
||||
$config->testcase->dtable->fieldList['id']['align'] = 'left';
|
||||
$config->testcase->dtable->fieldList['id']['fixed'] = 'left';
|
||||
|
||||
$config->testcase->dtable->fieldList['title']['name'] = 'title';
|
||||
$config->testcase->dtable->fieldList['title']['title'] = $lang->testcase->title;
|
||||
$config->testcase->dtable->fieldList['title']['type'] = 'title';
|
||||
$config->testcase->dtable->fieldList['title']['minWidth'] = '200';
|
||||
$config->testcase->dtable->fieldList['title']['fixed'] = 'left';
|
||||
$config->testcase->dtable->fieldList['title']['link'] = helper::createLink('testcase', 'view', "caseID={id}");
|
||||
|
||||
$config->testcase->dtable->fieldList['actions']['name'] = 'actions';
|
||||
$config->testcase->dtable->fieldList['actions']['title'] = $lang->actions;
|
||||
$config->testcase->dtable->fieldList['actions']['type'] = 'actions';
|
||||
$config->testcase->dtable->fieldList['actions']['width'] = '180';
|
||||
$config->testcase->dtable->fieldList['actions']['sortType'] = false;
|
||||
$config->testcase->dtable->fieldList['actions']['fixed'] = 'right';
|
||||
|
||||
+35
-109
@@ -2635,129 +2635,55 @@ class testcaseModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Build test case menu.
|
||||
* 构造详情页或列表页需要的操作菜单。
|
||||
* Build action menu.
|
||||
*
|
||||
* @param object $case
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function buildOperateMenu($case, $type = 'view')
|
||||
public function buildOperateMenu(object $case = null, string $type = 'view'): array
|
||||
{
|
||||
$function = 'buildOperate' . ucfirst($type) . 'Menu';
|
||||
return $this->$function($case);
|
||||
}
|
||||
$caseID = $case ? $case->id : '{id}';
|
||||
$runID = $case ? $case->runID : '0';
|
||||
$version = $case ? $case->version : '';
|
||||
$currentVersion = $case ? $case->currentVersion : '{version}';
|
||||
$product = $case ? $case->product : '{product}';
|
||||
$branch = $case ? $case->branch : '{branch}';
|
||||
$module = $case ? $case->module : '{module}';
|
||||
|
||||
/**
|
||||
* Build test case view menu.
|
||||
*
|
||||
* @param object $case
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function buildOperateViewMenu($case)
|
||||
{
|
||||
if($case->deleted) return '';
|
||||
$params = "caseID={$caseID}";
|
||||
$extraParams = "runID={$runID}&{$params}";
|
||||
$editParams = $params;
|
||||
if($this->app->tab == 'project') $editParams = "{$params}&comment=false&projectID={$this->session->project}";
|
||||
if($this->app->tab == 'execution') $editParams = "{$params}&comment=false&executionID={$this->session->execution}";
|
||||
$createBugParams = "product={$product}&branch={$branch}&extra=caseID={$caseID},version={$version},runID=";
|
||||
$copyParams = "productID={$product}&branch={$branch}&moduleID={$module}&from=testcase¶m={$caseID}";
|
||||
|
||||
$menu = '';
|
||||
$params = "caseID=$case->id";
|
||||
$extraParams = "runID=$case->runID&$params";
|
||||
if(!$case->needconfirm)
|
||||
$actions = array();
|
||||
$actions['results'] = array('icon' => 'list-alt', 'text' => '结果', 'url' => helper::createLink('testcase', 'results', "{$params}&version={$version}"), 'data-toggle' => 'modal');
|
||||
$actions['runcase'] = array('icon' => 'play', 'text' => '执行', 'url' => helper::createLink('testcase', 'runCase', "{$params}&version={$currentVersion}"), 'data-toggle' => 'modal');
|
||||
$actions['edit'] = array('icon' => 'edit', 'text' => '编辑', 'url' => helper::createLink('testcase', 'edit', $editParams));
|
||||
$actions['review'] = array('icon' => 'review', 'text' => '审批', 'url' => helper::createLink('testcase', 'review', $params), 'data-toggle' => 'modal');
|
||||
$actions['createBug'] = array('icon' => 'bug', 'text' => '转Bug', 'url' => helper::createLink('testcase', 'createBug', $createBugParams), 'data-toggle' => 'modal');
|
||||
$actions['create'] = array('icon' => 'copy', 'text' => '复制', 'url' => helper::createLink('testcase', 'create', $copyParams));
|
||||
$actions['showscript'] = array('icon' => 'file-code', 'text' => '查看自动化脚本', 'url' => helper::createLink('testcase', 'showScript', $params), 'data-toggle' => 'modal');
|
||||
|
||||
foreach($actions as $action => $actionData)
|
||||
{
|
||||
if(!$case->isLibCase)
|
||||
$actionsConfig = $this->config->testcase->actions->{$type};
|
||||
if(strpos(",{$actionsConfig},", ",{$action},") === false)
|
||||
{
|
||||
if($this->app->getViewType() == 'xhtml')
|
||||
{
|
||||
$menu .= $this->buildMenu('testtask', 'runCase', "$extraParams&version=$case->currentVersion", $case, 'view', 'play', '', 'showinonlybody', false, "data-width='95%'");
|
||||
$menu .= $this->buildMenu('testtask', 'results', "$extraParams&version=$case->version", $case, 'view', '', '', 'showinonlybody', false, "data-width='95%'");
|
||||
if(!isonlybody()) $menu .= $this->buildMenu('testcase', 'importToLib', $params, $case, 'view', 'assets', '', 'showinonlybody iframe', true, "data-width='500px'");
|
||||
}
|
||||
else
|
||||
{
|
||||
$menu .= $this->buildMenu('testtask', 'runCase', "$extraParams&version=$case->currentVersion", $case, 'view', 'play', '', 'showinonlybody iframe', false, "data-width='95%'");
|
||||
$menu .= $this->buildMenu('testtask', 'results', "$extraParams&version=$case->version", $case, 'view', '', '', 'showinonlybody iframe', false, "data-width='95%'");
|
||||
if(!isonlybody()) $menu .= $this->buildMenu('testcase', 'importToLib', $params, $case, 'view', 'assets', '', 'showinonlybody iframe', true, "data-width='500px'");
|
||||
}
|
||||
if($case->caseFails > 0)
|
||||
{
|
||||
$menu .= $this->buildMenu('testcase', 'createBug', "product=$case->product&branch=$case->branch&extra=$params,version=$case->version,runID=$case->runID", $case, 'view', 'bug', '', 'iframe', '', "data-width='90%'");
|
||||
}
|
||||
unset($actions[$action]);
|
||||
continue;
|
||||
}
|
||||
if($this->config->testcase->needReview || !empty($this->config->testcase->forceReview))
|
||||
{
|
||||
$menu .= $this->buildMenu('testcase', 'review', $params, $case, 'view', '', '', 'showinonlybody iframe', '', '', $this->lang->testcase->reviewAB);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$menu .= $this->buildMenu('testcase', 'confirmstorychange', $params, $case, 'view', 'confirm', 'hiddenwin', '', '', '', $this->lang->confirm);
|
||||
$actions[$action]['hint'] = $actions[$action]['text'];
|
||||
if($type == 'browse') unset($actions[$action]['text']);
|
||||
}
|
||||
|
||||
$menu .= "<div class='divider'></div>";
|
||||
$menu .= $this->buildFlowMenu('testcase', $case, 'view', 'direct');
|
||||
$menu .= "<div class='divider'></div>";
|
||||
|
||||
if(!$case->needconfirm)
|
||||
{
|
||||
if(!isonlybody())
|
||||
{
|
||||
$editParams = $params;
|
||||
if($this->app->tab == 'project') $editParams .= "&comment=false&projectID={$this->session->project}";
|
||||
if($this->app->tab == 'execution') $editParams .= "&comment=false&executionID={$this->session->execution}";
|
||||
$menu .= $this->buildMenu('testcase', 'edit', $editParams, $case, 'view', '', '', 'showinonlybody');
|
||||
}
|
||||
if(!$case->isLibCase && $case->auto != 'unit')
|
||||
{
|
||||
$menu .= $this->buildMenu('testcase', 'create', "productID=$case->product&branch=$case->branch&moduleID=$case->module&from=testcase¶m=$case->id", $case, 'view', 'copy');
|
||||
}
|
||||
if($case->isLibCase && common::hasPriv('caselib', 'createCase'))
|
||||
{
|
||||
echo html::a(helper::createLink('caselib', 'createCase', "libID=$case->lib&moduleID=$case->module¶m=$case->id"), "<i class='icon-copy'></i>", '', "class='btn' title='{$this->lang->testcase->copy}'");
|
||||
}
|
||||
|
||||
$menu .= $this->buildMenu('testcase', 'delete', $params, $case, 'view', 'trash', 'hiddenwin', '');
|
||||
}
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build test case browse menu.
|
||||
*
|
||||
* @param object $case
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function buildOperateBrowseMenu($case)
|
||||
{
|
||||
$canBeChanged = common::canBeChanged('case', $case);
|
||||
if(!$canBeChanged) return '';
|
||||
|
||||
$menu = '';
|
||||
$params = "caseID=$case->id";
|
||||
|
||||
if($case->needconfirm || $case->browseType == 'needconfirm')
|
||||
{
|
||||
return $this->buildMenu('testcase', 'confirmstorychange', $params, $case, 'browse', 'ok', 'hiddenwin', '', '', '', $this->lang->confirm);
|
||||
}
|
||||
|
||||
$menu .= $this->buildMenu('testtask', 'runCase', "runID=0&$params&version=$case->version", $case, 'browse', 'play', '', 'runCase iframe', false, "data-width='95%'");
|
||||
$menu .= $this->buildMenu('testtask', 'results', "runID=0&$params", $case, 'browse', '', '', 'iframe', true, "data-width='95%'");
|
||||
|
||||
$editParams = $params;
|
||||
if($this->app->tab == 'project') $editParams .= "&comment=false&projectID={$this->session->project}";
|
||||
if($this->app->tab == 'execution') $editParams .= "&comment=false&executionID={$this->session->execution}";
|
||||
$menu .= $this->buildMenu('testcase', 'edit', $editParams, $case, 'browse');
|
||||
|
||||
if($this->config->testcase->needReview || !empty($this->config->testcase->forceReview))
|
||||
{
|
||||
common::printIcon('testcase', 'review', $params, $case, 'browse', 'glasses', '', 'showinonlybody iframe');
|
||||
}
|
||||
$menu .= $this->buildMenu('testcase', 'createBug', "product=$case->product&branch=$case->branch&extra=caseID=$case->id,version=$case->version,runID=", $case, 'browse', 'bug', '', 'iframe', '', "data-width='90%'");
|
||||
$menu .= $this->buildMenu('testcase', 'create', "productID=$case->product&branch=$case->branch&moduleID=$case->module&from=testcase¶m=$case->id", $case, 'browse', 'copy');
|
||||
if($case->auto == 'auto') $menu .= $this->buildMenu('testcase', 'showScript', $params, $case, 'browse', 'file-code', '', 'runCase iframe', false);
|
||||
|
||||
return $menu;
|
||||
if($type == 'browse') $this->config->testcase->dtable->fieldList['actions']['actionsMap'] = $actions;
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,11 +10,27 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
$this->testcase->buildOperateMenu(null, 'browse');
|
||||
|
||||
foreach($cases as $case)
|
||||
{
|
||||
$actions = array();
|
||||
foreach($this->config->testcase->dtable->fieldList['actions']['actionsMap'] as $actionCode => $actionMap)
|
||||
{
|
||||
$isClickable = $this->testcase->isClickable($case, $actionCode);
|
||||
|
||||
$actions[] = $isClickable ? $actionCode : array('name' => $actionCode, 'disabled' => true);
|
||||
}
|
||||
$case->actions = $actions;
|
||||
}
|
||||
|
||||
$cols = array_values($config->testcase->dtable->fieldList);
|
||||
$data = array_values($cases);
|
||||
|
||||
dtable
|
||||
(
|
||||
set::cols(),
|
||||
set::data()
|
||||
set::cols($cols),
|
||||
set::data($data),
|
||||
);
|
||||
|
||||
render();
|
||||
|
||||
Reference in New Issue
Block a user