From 2de4e4729bbf8dc63a87c4314674c65df3669a72 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 16 Jan 2025 16:00:54 +0800 Subject: [PATCH] * [task#136556,done,2h] add pager for test case list. --- module/testtask/control.php | 14 ++++++++++++-- module/testtask/ui/unitcases.html.php | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/module/testtask/control.php b/module/testtask/control.php index 0ec3744b5b..65844b6ec2 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -307,10 +307,13 @@ class testtask extends control * * @param int $testtaskID * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function unitCases(int $testtaskID, string $orderBy = 't1.id_asc') + public function unitCases(int $testtaskID, string $orderBy = 't1.id_asc', int $recTotal = 0, int $recPerPage = 20, int $pageID = 1) { $testtask = $this->testtask->getByID($testtaskID); @@ -336,13 +339,20 @@ class testtask extends control foreach($suiteRuns as $run) $runs[$run->id] = $run; $runs = $this->loadModel('testcase')->appendData($runs, 'testrun'); - $runs = $this->testtaskZen->processRowspanForUnitCases($runs); + + /* Process runs. */ + $this->app->loadClass('pager', $static = true); + $pager = pager::init(count($runs), $recPerPage, $pageID); + $runs = array_chunk($runs, $pager->recPerPage, true); + $runs = empty($runs) ? $runs : (isset($runs[$pageID - 1]) ? $runs[$pageID - 1] : current($runs)); + $runs = $this->testtaskZen->processRowspanForUnitCases($runs); $this->view->title = $this->products[$productID] . $this->lang->hyphen . $this->lang->testcase->common; $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->runs = $runs; $this->view->productID = $productID; $this->view->taskID = $testtaskID; + $this->view->pager = $pager; $this->display(); } diff --git a/module/testtask/ui/unitcases.html.php b/module/testtask/ui/unitcases.html.php index 91d8c7a1e8..8b2b9ea234 100644 --- a/module/testtask/ui/unitcases.html.php +++ b/module/testtask/ui/unitcases.html.php @@ -47,7 +47,12 @@ dtable set::data($runs), set::plugins(array('cellspan')), set::onRenderCell(jsRaw('window.onRenderCell')), - set::getCellSpan(jsRaw('window.getCellSpan')) + set::getCellSpan(jsRaw('window.getCellSpan')), + set::footPager(usePager(array + ( + 'recPerPage' => $pager->recPerPage, + 'recTotal' => $pager->recTotal + ))) ); render();