diff --git a/config/zentaopms.php b/config/zentaopms.php index aaf2fe9714..89512f783a 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -663,5 +663,5 @@ $config->hasDropmenuApps = array('program', 'project', 'product', 'executio $config->hasBranchMenuModules = array('product', 'story', 'release', 'bug', 'testcase', 'testtask'); $config->excludeDropmenuList = array('program-browse', 'program-productview', 'product-all', 'product-index', 'execution-all', 'project-browse', 'project-batchedit', 'product-batchedit', 'admin-index', 'product-create', 'project-create', 'execution-create', 'program-create', 'execution-batchedit'); $config->hasSwitcherModules = array('design'); -$config->hasSwitcherMethods = array('project-bug'); +$config->hasSwitcherMethods = array('project-bug', 'project-testcase'); $config->excludeSwitcherList = array(); diff --git a/lib/zin/wg/featurebar/v1.php b/lib/zin/wg/featurebar/v1.php index de87cfa2f8..adc534c649 100644 --- a/lib/zin/wg/featurebar/v1.php +++ b/lib/zin/wg/featurebar/v1.php @@ -15,7 +15,8 @@ class featureBar extends wg 'module?:string', 'method?:string', 'load?: string="table"', - 'loadID?: string' + 'loadID?: string', + 'app?: string=""' ); protected static array $defineBlocks = array @@ -46,6 +47,7 @@ class featureBar extends wg $link = $this->prop('link'); $loadID = $this->prop('loadID'); $load = $this->prop('load'); + $tab = $this->prop('app'); data('activeFeature', $current); @@ -75,7 +77,7 @@ class featureBar extends wg $subItem['text'] = $text; $subItem['active'] = $key == $current; $subItem['url'] = ($callback instanceof \Closure) ? $callback($key, $text) : str_replace('{key}', (string)$key, $link); - $subItem['attrs'] = ['data-id' => $key, 'data-load' => $load, 'data-target' => $loadID]; + $subItem['attrs'] = ['data-id' => $key, 'data-load' => $load, 'data-target' => $loadID, 'data-app' => $tab]; if($item->name == 'QUERY') { @@ -116,7 +118,7 @@ class featureBar extends wg 'active' => $isActive, 'url' => str_replace('{key}', strval($item->name), $link), 'badge' => $isActive && $recTotal != '' ? array('text' => $recTotal, 'class' => 'size-sm rounded-full white') : null, - 'props' => array('data-id' => $item->name, 'data-load' => $load, 'data-target' => $loadID) + 'props' => array('data-id' => $item->name, 'data-load' => $load, 'data-target' => $loadID, 'data-app' => $tab) ); } diff --git a/lib/zin/wg/mainnavbar/v1.php b/lib/zin/wg/mainnavbar/v1.php index e053c395b8..4055c2b3d6 100644 --- a/lib/zin/wg/mainnavbar/v1.php +++ b/lib/zin/wg/mainnavbar/v1.php @@ -135,6 +135,7 @@ class mainNavbar extends nav if(in_array($moduleName, is_array($config->hasSwitcherModules) ? $config->hasSwitcherModules : array()) || in_array("$moduleName-$methodName", is_array($config->hasSwitcherMethods) ? $config->hasSwitcherMethods : array())) { + if($moduleName == 'testcase' && $app->tab == 'project') $moduleName = 'project'; $fetcher = createLink($moduleName, 'ajaxSwitcherMenu', data('switcherParams')); return array(zui::dropmenu ( diff --git a/module/project/control.php b/module/project/control.php index 2007cdf9c9..b746af56a0 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -1555,10 +1555,14 @@ class project extends control */ public function ajaxSwitcherMenu(int $projectID, int $productID, string $currentMethod = '') { - $this->view->link = helper::createLink('project', $currentMethod, "projectID=$projectID&productID={id}"); - $this->view->productID = $productID; - $this->view->products = $this->loadModel('product')->getProducts($projectID); - $this->view->projectID = $projectID; + $currentModule = $currentMethod == 'zerocase' ? 'testcase' : 'project'; + $params = $currentMethod == 'zerocase' ? "productID={id}&branchID=0&orderBy=id_desc&projectID={$projectID}" : "projectID={$projectID}&productID={id}"; + + $this->view->link = helper::createLink($currentModule, $currentMethod, $params); + $this->view->productID = $productID; + $this->view->products = $this->loadModel('product')->getProducts($projectID); + $this->view->projectID = $projectID; + $this->view->currentMethod = $currentMethod; $this->display(); } } diff --git a/module/project/ui/ajaxswitchermenu.html.php b/module/project/ui/ajaxswitchermenu.html.php index aa514f8783..6e9e1496b7 100644 --- a/module/project/ui/ajaxswitchermenu.html.php +++ b/module/project/ui/ajaxswitchermenu.html.php @@ -15,22 +15,28 @@ namespace zin; * Define the grouped data list. */ -$defaultItem = array(); -$defaultItem['id'] = 0; -$defaultItem['text'] = $lang->product->all; -$defaultItem['active'] = $productID == 0; -$defaultItem['type'] = 'product'; +$data = array('normal' => array(), 'closed' => array()); +if($currentMethod != 'zerocase') +{ + $defaultItem = array(); + $defaultItem['id'] = 0; + $defaultItem['text'] = $lang->product->all; + $defaultItem['active'] = $productID == 0; + $defaultItem['type'] = 'product'; + $defaultItem['data-app'] = $app->tab; -$data = array('normal' => array($defaultItem), 'closed' => array()); + $data['normal'][] = $defaultItem; +} foreach($products as $product) { $item = array(); - $item['id'] = $product->id; - $item['text'] = $product->name; - $item['active'] = $productID == $product->id; - $item['type'] = 'product'; - $item['keys'] = zget(common::convert2Pinyin(array($product->name)), $product->name, ''); + $item['id'] = $product->id; + $item['text'] = $product->name; + $item['active'] = $productID == $product->id; + $item['type'] = 'product'; + $item['keys'] = zget(common::convert2Pinyin(array($product->name)), $product->name, ''); + $item['data-app'] = $app->tab; if($product->status == 'closed') { diff --git a/module/testcase/control.php b/module/testcase/control.php index 8752652f1a..4be3333b16 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -179,6 +179,11 @@ class testcase extends control $this->loadModel('project')->setMenu($this->session->project); $products = $this->product->getProducts($this->session->project, 'all', '', false); $productID = $this->product->checkAccess($productID, $products); + $this->config->hasSwitcherMethods[] = 'testcase-zerocase'; + + $productPairs = $this->project->getMultiLinkedProducts($this->session->project); + $this->view->switcherParams = "projectID={$this->session->project}&productID={$productID}¤tMethod=zerocase"; + $this->view->switcherText = zget($productPairs, $productID, $this->lang->product->all); } else { diff --git a/module/testcase/ui/header.html.php b/module/testcase/ui/header.html.php index 70d60e7717..b403c5e2b3 100644 --- a/module/testcase/ui/header.html.php +++ b/module/testcase/ui/header.html.php @@ -99,22 +99,16 @@ if($canDisplaySuite) $linkParams = $projectParam . "productID=$productID&branch=$branch&browseType={key}¶m=0&caseType={$caseType}"; $browseLink = createLink('testcase', 'browse', $linkParams); +if($app->tab == 'project') $browseLink = createLink('project', 'testcase', $linkParams); if($rawMethod == 'browseunits') $browseLink = createLink('testtask', 'browseUnits', "productID=$productID&browseType={key}"); -$productMenuLink = createLink('project', 'testcase', array('projectID' => $projectID, 'productID' => '{key}', 'branch' => $branch, 'browseType' => $browseType, 'param' => $param, 'caseType' => $caseType, 'orderBy' => $orderBy,)); featureBar ( - !empty($hasProduct) && !empty($projectID) ? to::before(productMenu(set - ([ - 'items' => $products, - 'activeKey' => $productID, - 'closeLink' => '#', - 'link' => $productMenuLink - ]))) : null, set::linkParams($rawMethod == 'zerocase' || $rawMethod == 'browseunits' ? null : $linkParams), set::link($rawMethod == 'zerocase' || $rawMethod == 'browseunits' ? $browseLink : null), set::current($rawMethod == 'browse' ? $this->session->caseBrowseType : null), set::load($load), + set::app($app->tab), $canSwitchCaseType ? to::leading ( dropdown @@ -173,7 +167,7 @@ featureBar $lang->testcase->onlyAutomated ) ) : null, - $rawMethod != 'browseunits' && $rawMethod != 'groupcase' ? (searchToggle(set::open($browseType == 'bysearch'))) : null + !in_array($rawMethod, array('browseunits', 'groupcase', 'zerocase'))? (searchToggle(set::open($browseType == 'bysearch'))) : null ); $viewItems = array(array('text' => $lang->testcase->listView, 'url' => $app->tab == 'project' ? createLink('project', 'testcase', "projectID={$projectID}") : inlink('browse', "productID=$productID&branch=$branch&browseType=all"), 'active' => $rawMethod != 'groupcase' ? true : false)); diff --git a/module/testcase/zen.php b/module/testcase/zen.php index 29ee5b6b24..7610449297 100644 --- a/module/testcase/zen.php +++ b/module/testcase/zen.php @@ -575,6 +575,14 @@ class testcaseZen extends testcase $this->view->libraries = $this->loadModel('caselib')->getLibraries(); $this->view->stories = array('') + $this->loadModel('story')->getPairs($productID); $this->view->automation = $this->loadModel('zanode')->getAutomationByProduct($productID); + + if($projectID) + { + $productPairs = $this->project->getMultiLinkedProducts($projectID); + + $this->view->switcherParams = "projectID={$projectID}&productID={$productID}¤tMethod=testcase"; + $this->view->switcherText = zget($productPairs, $productID, $this->lang->product->all); + } } /** @@ -2361,7 +2369,7 @@ class testcaseZen extends testcase $this->config->testcase->search['actionURL'] = $actionURL; $this->config->testcase->search['queryID'] = $queryID; - $this->config->testcase->search['module'] = $this->app->rawModule; + $this->config->testcase->search['module'] = 'testcase'; $this->loadModel('search')->setSearchParams($this->config->testcase->search); } diff --git a/module/tree/model.php b/module/tree/model.php index 72048229f1..c2d2361400 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -439,7 +439,7 @@ class treeModel extends model } 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($product->type != 'normal' and $projectID) $branches += $this->branch->getPairs((int)$product->id, 'noempty', $projectID); if($onlyGetLinked) $executionModules = $this->getTaskTreeModules($projectID, true, $type, $type == 'story' ? array() : array('branchID' => $branch)); }