diff --git a/module/testtask/control.php b/module/testtask/control.php index 3759ccd385..5c6ff693ec 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -325,7 +325,7 @@ class testtask extends control } elseif($this->app->tab == 'qa') { - $this->loadModel('qa')->setMenu($this->products, $productID, $task->branch, $taskID); + $this->testtask->setMenu($this->products, $productID, $task->branch, $taskID); } $this->executeHooks($taskID); @@ -488,7 +488,7 @@ class testtask extends control } else { - $this->loadModel('qa')->setMenu($this->products, $productID, $task->branch, $taskID); + $this->testtask->setMenu($this->products, $productID, $task->branch, $taskID); } setcookie('preTaskID', $taskID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); @@ -619,7 +619,7 @@ class testtask extends control } else { - $this->loadModel('qa')->setMenu($this->products, $productID, $branchID, $taskID); + $this->testtask->setMenu($this->products, $productID, $branchID, $taskID); } unset($this->lang->testtask->report->charts['bugStageGroups']); unset($this->lang->testtask->report->charts['bugHandleGroups']); @@ -683,7 +683,7 @@ class testtask extends control } else { - $this->loadModel('qa')->setMenu($this->products, $productID, $task->branch, $taskID); + $this->testtask->setMenu($this->products, $productID, $task->branch, $taskID); } /* Determines whether an object is editable. */ @@ -1069,7 +1069,7 @@ class testtask extends control } else { - $this->loadModel('qa')->setMenu($this->products, $productID, $task->branch, $taskID); + $this->testtask->setMenu($this->products, $productID, $task->branch, $taskID); } /* Load pager. */ @@ -1527,4 +1527,29 @@ class testtask extends control $pairs = $this->loadModel('testreport')->getPairs($productID); return print(html::select('testreport', array('') + $pairs, '', "class='form-control chosen'")); } + + /** + * Drop menu page. + * + * @param int $productID + * @param int $branch + * @param int $taskID + * @access public + * @return void + */ + public function ajaxGetDropMenu($productID, $branch, $taskID, $module, $method) + { + $testtasks = $this->testtask->getProductTasks($productID, $branch, 'id_desc', null, array('local', 'totalStatus')); + $namePairs = array_column($testtasks, 'name'); + + $this->view->currentTaskID = $taskID; + $this->view->testtasks = $testtasks; + $this->view->module = $module; + $this->view->method = $method; + $this->view->productID = $productID; + $this->view->branch = $branch; + $this->view->testtasksPinyin = common::convert2Pinyin($namePairs); + + $this->display(); + } } diff --git a/module/testtask/model.php b/module/testtask/model.php index 7cc03c9f26..e73e1dbf8a 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -2287,4 +2287,45 @@ class testtaskModel extends model } return $menu; } + + /** + * Set menu. + * + * @param array $products + * @param int $productID + * @param int|string $branch + * @param int $taskID + * @access public + * @return void + */ + public function setMenu($products, $productID, $branch = '', $taskID = 0) + { + if(!$this->app->user->admin and strpos(",{$this->app->user->view->products},", ",$productID,") === false and $productID != 0 and !defined('TUTORIAL')) + { + $this->app->loadLang('product'); + return print(js::error($this->lang->product->accessDenied) . js::locate('back')); + } + + $branch = ($this->cookie->preBranch !== '' and $branch === '') ? $this->cookie->preBranch : $branch; + setcookie('preBranch', $branch, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); + + $product = $this->loadModel('product')->getById($productID); + if($product and $product->type != 'normal') $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); + + $selectHtml = $this->product->getSwitcher($productID, $taskID, $branch); + + if($taskID and $this->app->viewType != 'mhtml') + { + $testtask = $this->getById($taskID); + $module = $this->app->rawModule; + $method = $this->app->rawMethod; + $dropMenuLink = helper::createLink('testtask', 'ajaxGetDropMenu', "productID=$productID&branch=$branch&taskID=$taskID&module=$module&method=$method"); + $selectHtml .= "
"; + } + + $this->lang->switcherMenu = $selectHtml; + common::setMenuVars('qa', $productID); + } } diff --git a/module/testtask/view/ajaxgetdropmenu.html.php b/module/testtask/view/ajaxgetdropmenu.html.php new file mode 100644 index 0000000000..693eccefe0 --- /dev/null +++ b/module/testtask/view/ajaxgetdropmenu.html.php @@ -0,0 +1,26 @@ + + * @package testtask + * @version $Id: ajaxgetdropmenu.html.php 935 2022-06-27 16:44:24Z $ + * @link https://www.zentao.net + */ +?> + $testtask) +{ + $selected = (string)$testtaskID == $currentTaskID ? 'selected' : ''; + $param = $method == 'report' ? "productID=$productID&taskID=$testtaskID&browseType=all&branch=$branch" : "taskID=$testtaskID"; + $selectHtml .= html::a($this->createLink($module, $method, $param), $testtask->name, '', "class='$selected' data-key='{$testtasksPinyin[$testtask->name]}' data-app='{$this->app->tab}'"); +} +?> +
+
+
+
+