From b8642a335067a55cfcb4f0ad52bca27298bff57d Mon Sep 17 00:00:00 2001 From: liumengyi Date: Mon, 11 Jul 2022 14:49:36 +0800 Subject: [PATCH 1/2] * Finish task #60395. --- module/branch/control.php | 2 +- module/execution/control.php | 10 ++++++---- module/execution/css/testcase.css | 1 + module/execution/view/testcase.html.php | 6 +++--- module/product/model.php | 7 ++++++- module/project/control.php | 4 ++-- module/testcase/control.php | 3 +-- module/testcase/css/browse.css | 1 + module/testcase/model.php | 5 ++++- module/tree/model.php | 21 ++++++++++++--------- 10 files changed, 37 insertions(+), 23 deletions(-) diff --git a/module/branch/control.php b/module/branch/control.php index ae9090bde2..e0816d28ff 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -211,7 +211,7 @@ class branch extends control public function ajaxGetDropMenu($productID, $branch, $module, $method, $extra = '') { parse_str($extra, $output); - $isQaModule = (strpos(',project,execution,', ",{$this->app->tab},") !== false and strpos(',bug,', ",$method,") !== false and !empty($productID)) ? true : false; + $isQaModule = (strpos(',project,execution,', ",{$this->app->tab},") !== false and strpos(',bug,testcase,', ",$method,") !== false and !empty($productID)) ? true : false; $param = $isQaModule ? $extra : 0; $param = isset($output['projectID']) ? $output['projectID'] : $param; $branches = $this->branch->getPairs($productID, 'all', $param); diff --git a/module/execution/control.php b/module/execution/control.php index 74884ff20c..d5532135a4 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1072,6 +1072,7 @@ class execution extends control * * @param int $executionID * @param int $productID + * @param int $branchID * @param string $type * @param int $moduleID * @param string $orderBy @@ -1081,7 +1082,7 @@ class execution extends control * @access public * @return void */ - public function testcase($executionID = 0, $productID = 0, $type = 'all', $moduleID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function testcase($executionID = 0, $productID = 0, $branchID = 0, $type = 'all', $moduleID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $this->loadModel('testcase'); $this->loadModel('testtask'); @@ -1095,13 +1096,13 @@ class execution extends control 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); + $this->lang->modulePageNav = $this->product->select(array('0' => $this->lang->product->all) + $products, $productID, 'execution', 'testcase', $extra, $branchID); /* Load pager. */ $this->app->loadClass('pager', $static = true); $pager = pager::init($recTotal, $recPerPage, $pageID); - $cases = $this->loadModel('testcase')->getExecutionCases($executionID, $productID, $moduleID, $orderBy, $pager, $type); + $cases = $this->loadModel('testcase')->getExecutionCases($executionID, $productID, $branchID, $moduleID, $orderBy, $pager, $type); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); $cases = $this->testcase->appendData($cases, 'case'); @@ -1116,7 +1117,7 @@ class execution extends control } else { - $moduleTree = $this->tree->getTreeMenu($productID, 'case', 0, array('treeModel', 'createCaseLink'), array('executionID' => $executionID, 'productID' => $productID), 'all'); + $moduleTree = $this->tree->getTreeMenu($productID, 'case', 0, array('treeModel', 'createCaseLink'), array('executionID' => $executionID, 'productID' => $productID), $branchID); } $tree = $moduleID ? $this->tree->getByID($moduleID) : ''; @@ -1133,6 +1134,7 @@ class execution extends control $this->view->modules = $modules; $this->view->moduleID = $moduleID; $this->view->moduleName = $moduleID ? $tree->name : $this->lang->tree->all; + $this->view->branchID = $branchID; $this->display(); } diff --git a/module/execution/css/testcase.css b/module/execution/css/testcase.css index 3f05682eb7..485a750a3d 100644 --- a/module/execution/css/testcase.css +++ b/module/execution/css/testcase.css @@ -1,3 +1,4 @@ .c-id, .c-pri {width: 50px;} .c-result {width: 80px;} #pageNav #dropMenu .col-left {padding-bottom: 0px;} +#currentBranch + #dropMenu .col-left {padding-bottom: 30px;} diff --git a/module/execution/view/testcase.html.php b/module/execution/view/testcase.html.php index b64a7ffdf7..cf13103010 100644 --- a/module/execution/view/testcase.html.php +++ b/module/execution/view/testcase.html.php @@ -6,14 +6,14 @@ 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}"); + $removeLink = $this->createLink('execution', 'testcase', "executionID=$executionID&productID=$productID&branchID=$branchID&type=all&moduleID=0&orderBy=$orderBy&recTotal=0&recPerPage={$pager->recPerPage}"); echo html::a($removeLink, "", '', "class='text-muted' data-app='{$this->app->tab}'"); } ?>
- {$lang->execution->all}", '', "class='btn btn-link btn-active-text'");?> + {$lang->execution->all}", '', "class='btn btn-link btn-active-text'");?>
id", '', '', '', true), " " . $lang->testcase->create, '', "class='btn btn-primary' data-app='{$this->app->tab}'");?> @@ -45,7 +45,7 @@
- recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?> + recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?> diff --git a/module/product/model.php b/module/product/model.php index 8f546b0f7d..dfb0b92a18 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -2272,7 +2272,12 @@ class productModel extends model elseif($module == 'project' and $method == 'testcase') { $params = explode(',', $extra); - return helper::createLink('project', 'testcase', "projectID={$params[0]}&productID=%s&branch=all&browseType={$params[1]}"); + return helper::createLink('project', 'testcase', "projectID={$params[0]}&productID=%s&branch=" . ($branch ? "%s" : '0') . "&browseType={$params[1]}"); + } + elseif($module == 'execution' and $method == 'testcase') + { + $params = explode(',', $extra); + return helper::createLink('execution', 'testcase', "executionID={$params[0]}&productID=%s" . ($branch ? "&branch=%s" : '')); } elseif($module == 'project' or $module == 'execution') { diff --git a/module/project/control.php b/module/project/control.php index e1f3870f6a..d0aa65a093 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -1138,7 +1138,7 @@ class project extends control * @access public * @return void */ - public function testcase($projectID = 0, $productID = 0, $branch = 'all', $browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function testcase($projectID = 0, $productID = 0, $branch = 0, $browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $this->loadModel('product'); $this->session->set('bugList', $this->app->getURI(true), 'project'); @@ -1147,7 +1147,7 @@ class project extends control $products = array('0' => $this->lang->product->all) + $this->product->getProducts($projectID, 'all', '', false); $extra = "$projectID,$browseType"; - $this->lang->modulePageNav = $this->product->select($products, $productID, 'project', 'testcase', $extra, $branch, 0, '', false); + $this->lang->modulePageNav = $this->product->select($products, $productID, 'project', 'testcase', $extra, $branch); echo $this->fetch('testcase', 'browse', "productID=$productID&branch=$branch&browseType=$browseType¶m=$param&orderBy=$orderBy&recTotal=$orderBy&recPerPage=$recPerPage&pageID=$pageID&projectID=$projectID"); } diff --git a/module/testcase/control.php b/module/testcase/control.php index 88e7b1853b..2806380aac 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -119,7 +119,6 @@ class testcase extends control $this->products = count($linkedProducts) > 1 ? array('0' => $this->lang->product->all) + $linkedProducts : $linkedProducts; $productID = count($linkedProducts) > 1 ? $productID : key($linkedProducts); - $branch = 'all'; $this->loadModel('project')->setMenu($projectID); } else @@ -175,7 +174,7 @@ class testcase extends control } else { - $moduleTree = $this->tree->getTreeMenu($productID, 'case', 0, array('treeModel', 'createCaseLink'), array('projectID' => $projectID, 'productID' => $productID), $projectID ? '' : $branch); + $moduleTree = $this->tree->getTreeMenu($productID, 'case', 0, array('treeModel', 'createCaseLink'), array('projectID' => $projectID, 'productID' => $productID), $branch); } $product = $this->product->getById($productID); diff --git a/module/testcase/css/browse.css b/module/testcase/css/browse.css index a70f0e221f..8b43d91f06 100644 --- a/module/testcase/css/browse.css +++ b/module/testcase/css/browse.css @@ -26,3 +26,4 @@ tbody > tr > td .icon-share {font-size: 9px;} .table td.c-title > a:first-child {display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} #importToLib .select-lib {width: 100px; text-align: right;} +#subHeader #currentBranch + #dropMenu .col-left {padding-bottom: 30px;} diff --git a/module/testcase/model.php b/module/testcase/model.php index 200fda3bcf..0c58f2582e 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -323,6 +323,7 @@ class testcaseModel extends model * * @param int $executionID * @param int $productID + * @param int $branchID * @param int $moduleID * @param string $orderBy * @param object $pager @@ -330,7 +331,7 @@ class testcaseModel extends model * @access public * @return array */ - public function getExecutionCases($executionID, $productID = 0, $moduleID = 0, $orderBy = 'id_desc', $pager = null, $browseType = '') + public function getExecutionCases($executionID, $productID = 0, $branchID = 0, $moduleID = 0, $orderBy = 'id_desc', $pager = null, $browseType = '') { if($browseType == 'needconfirm') { @@ -341,6 +342,7 @@ class testcaseModel extends model ->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.branch')->eq($branchID) ->andWhere('t2.deleted')->eq('0') ->andWhere('t3.version > t2.storyVersion') ->andWhere("t3.status")->eq('active') @@ -356,6 +358,7 @@ class testcaseModel extends model ->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.branch')->eq($branchID) ->andWhere('t2.deleted')->eq('0') ->orderBy($orderBy) ->page($pager) diff --git a/module/tree/model.php b/module/tree/model.php index 0afab36314..bd576bae3d 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -407,7 +407,7 @@ class treeModel extends model $executionID = zget($extra, 'executionID', 0); $branches = array($branch => ''); $executionModules = array(); - if($branch and empty($projectID) and empty($extra['executionID'])) + if($branch and empty($projectID) and empty($executionID)) { $branchName = $this->branch->getById($branch); $branches = array($branch => $branchName); @@ -425,12 +425,12 @@ class treeModel extends model elseif(strpos(',case,bug,', ",$type,") !== false 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, $type == 'bug' ? array('branchID' => $branch) : array()); + if($onlyGetLinked) $executionModules = $this->getTaskTreeModules($executionID, true, $type, array('branchID' => $branch)); } elseif(($type == 'story' and $this->app->rawModule == 'projectstory') or (strpos(',case,bug,', ",$type,") !== false and $this->app->tab == 'project')) { if($product->type != 'normal' and $projectID) $branches += $this->branch->getPairs($product->id, 'noempty', $projectID); - if($onlyGetLinked) $executionModules = $this->getTaskTreeModules($projectID, true, $type, $type == 'bug' ? array('branchID' => $branch) : array()); + if($onlyGetLinked) $executionModules = $this->getTaskTreeModules($projectID, true, $type, $type == 'story' ? array() : array('branchID' => $branch)); } /* Add for task #1945. check the module has case or no. */ @@ -696,7 +696,6 @@ class treeModel extends model ->get(); $treeMenu = array(); $stmt = $this->dbh->query($query); - $extra['branchID'] = $branch; while($module = $stmt->fetch()) { if(isset($executionModules[$module->id])) $this->buildTree($treeMenu, $module, 'bug', $userFunc, $extra, $branch); @@ -786,7 +785,7 @@ class treeModel extends model $stmt = $this->dbh->query($query); while($module = $stmt->fetch()) { - if(isset($executionModules[$module->id])) $this->buildTree($treeMenu, $module, 'case', $userFunc, $extra); + if(isset($executionModules[$module->id])) $this->buildTree($treeMenu, $module, 'case', $userFunc, $extra, $branch); } $tree .= isset($treeMenu[0]) ? $treeMenu[0] : ''; } @@ -979,8 +978,12 @@ class treeModel extends model $paths = $this->dao->select('DISTINCT t3.' . $field)->from($table1)->alias('t1') ->leftJoin($table2)->alias('t2')->on('t1.' . $linkObject . ' = t2.id') ->leftJoin(TABLE_MODULE)->alias('t3')->on('t2.module = t3.id') - ->where('t1.project')->eq($executionID) + ->leftJoin(TABLE_PROJECT)->alias('t4')->on('t1.project = t4.id') + ->where('(t1.project')->eq($executionID) + ->orWhere('t4.project')->eq($executionID)->markRight(1) ->andWhere('t3.deleted')->eq(0) + ->andWhere('t2.deleted')->eq(0) + ->beginIF(isset($extra['branchID']))->andWhere('t2.branch')->eq(zget($extra, 'branchID', 0))->fi() ->fetchPairs(); } elseif($linkObject == 'bug' and strpos(',project,execution,', ",{$this->app->tab},") !== false) @@ -1236,9 +1239,9 @@ class treeModel extends model { $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¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}' data-app='{$this->app->tab}' title='{$module->name}'"); + $param = $this->app->tab == 'project' ? "projectID={$this->session->project}&" : ""; + $param = $this->app->tab == 'execution' ? "executionID={$extra['executionID']}&" : $param; + return html::a(helper::createLink($moduleName, $methodName, $param . "root={$module->root}&branch={$extra['branchID']}&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}' data-app='{$this->app->tab}' title='{$module->name}'"); } /** From 38a91dba028aebfb37f39a942d7c9bb017efad29 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Mon, 11 Jul 2022 14:52:26 +0800 Subject: [PATCH 2/2] * Optimize code for task#60395. --- module/tree/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/tree/model.php b/module/tree/model.php index bd576bae3d..f1c2a3db9f 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -694,8 +694,8 @@ class treeModel extends model ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`, type') ->get(); - $treeMenu = array(); - $stmt = $this->dbh->query($query); + $treeMenu = array(); + $stmt = $this->dbh->query($query); while($module = $stmt->fetch()) { if(isset($executionModules[$module->id])) $this->buildTree($treeMenu, $module, 'bug', $userFunc, $extra, $branch);
idAB);?>