* testtask: refactor the browseUnits method and page.
This commit is contained in:
+10
-12
@@ -136,33 +136,31 @@ class testtask extends control
|
||||
*/
|
||||
public function browseUnits(int $productID = 0, string $browseType = 'newest', string $orderBy = 'id_desc', int $recTotal = 0, int $recPerPage = 20, int $pageID = 1)
|
||||
{
|
||||
/* 检查是否有权限访问测试单所属产品。*/
|
||||
/* Check if user have permission to access the product to which the testtask belongs. */
|
||||
$productID = $this->loadModel('product')->checkAccess($productID, $this->products);
|
||||
|
||||
/* Save session. */
|
||||
$this->session->set('testtaskList', $this->app->getURI(true), 'qa');
|
||||
$this->session->set('caseList', $this->app->getURI(true), $this->app->tab);
|
||||
$this->session->set('buildList', $this->app->getURI(true) . '#app=' . $this->app->tab, 'execution');
|
||||
|
||||
/* Set menu. */
|
||||
$productID = $this->loadModel('product')->checkAccess($productID, $this->products);
|
||||
$this->loadModel('qa')->setMenu($productID);
|
||||
$this->app->rawModule = 'testcase';
|
||||
|
||||
/* Load pager. */
|
||||
/* 预处理部分变量供查询使用。*/
|
||||
/* Prepare variables for query. */
|
||||
if($browseType == 'newest') $recPerPage = '10';
|
||||
$this->app->loadClass('pager', true);
|
||||
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
||||
|
||||
/* Append id for second sort. */
|
||||
$sort = common::appendOrder($orderBy);
|
||||
|
||||
$this->app->loadLang('testcase');
|
||||
$this->lang->testcase->featureBar['browseunits'] = $this->lang->testtask->unitTag;
|
||||
$sort = common::appendOrder($orderBy);
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->common;
|
||||
$this->view->productID = $productID;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->browseType = $browseType;
|
||||
$this->view->tasks = $this->testtask->getProductUnitTasks($productID, $browseType, $sort, $pager);
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter');
|
||||
$this->view->product = $this->product->getByID($productID);
|
||||
$this->view->browseType = $browseType;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->pager = $pager;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -10,11 +10,59 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
include '../../testcase/ui/header.html.php';
|
||||
$canSwitch = $this->app->tab == 'qa';
|
||||
if($canSwitch)
|
||||
{
|
||||
$caseTypeItems = array();
|
||||
foreach($lang->testcase->typeList as $type => $typeName)
|
||||
{
|
||||
if($type == 'unit')
|
||||
{
|
||||
$url = createLink('testtask', 'browseUnits', "productID={$product->id}&browseType=newest&orderBy=id_desc&recTotal=0&recPerPage=20&pageID=1");
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = createLink('testcase', 'browse', "productID={$product->id}&branch=&browseType=all¶m=0&caseType={$type}");
|
||||
}
|
||||
|
||||
$cols = $this->config->testtask->browseUnits->dtable->fieldList;
|
||||
$tasks = initTableData($tasks, $cols, $this->testtask);
|
||||
$caseTypeItems[] = array('text' => $typeName ?: $lang->testcase->allType, 'url' => $url);
|
||||
}
|
||||
}
|
||||
|
||||
$lang->testcase->featureBar['browseunits'] = $lang->testtask->featureBar['browseunits'];
|
||||
featureBar
|
||||
(
|
||||
$canSwitch ? to::before
|
||||
(
|
||||
productMenu
|
||||
(
|
||||
set::title($lang->testcase->typeList['unit']),
|
||||
set::items($caseTypeItems),
|
||||
set::activeKey('unit'),
|
||||
set::link(createLink('testcase', 'browse', "productID={$product->id}&branch=&browseType=all¶m=0&caseType={key}")),
|
||||
)
|
||||
) : null,
|
||||
set::link(createLink('testtask', 'browseUnits', "productID={$product->id}&browseType={key}"))
|
||||
);
|
||||
|
||||
$canModify = common::canModify('product', $product);
|
||||
$canImport = hasPriv('testtask', 'importUnitResult');
|
||||
if($canImport && (empty($product) || $canModify))
|
||||
{
|
||||
toolbar
|
||||
(
|
||||
btn
|
||||
(
|
||||
set::className('btn primary'),
|
||||
set::icon('import'),
|
||||
set::url(createLink('testtask', 'importUnitResult', "product={$product->id}")),
|
||||
$lang->testtask->importUnitResult,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$cols = $this->config->testtask->browseUnits->dtable->fieldList;
|
||||
$tasks = initTableData($tasks, $cols, $this->testtask);
|
||||
$summary = sprintf($lang->testtask->unitSummary, $pager->recTotal);
|
||||
|
||||
dtable
|
||||
@@ -24,14 +72,7 @@ dtable
|
||||
set::emptyTip($lang->testtask->emptyUnitTip),
|
||||
set::userMap($users),
|
||||
set::footer(array(array('html' => $summary), 'flex', 'pager')),
|
||||
set::footPager
|
||||
(
|
||||
usePager(),
|
||||
set::page($pager->pageID),
|
||||
set::recPerPage($pager->recPerPage),
|
||||
set::recTotal($pager->recTotal),
|
||||
set::linkCreator(helper::createLink('testtask', 'browseunits', "productID={$productID}&browseType={$browseType}&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={recPerPage}&page={page}"))
|
||||
),
|
||||
set::footPager(usePager())
|
||||
);
|
||||
|
||||
render();
|
||||
|
||||
Reference in New Issue
Block a user