From 6f2d0d92afb21b4bd9d673e41b30ae148dc86a22 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Fri, 28 Apr 2023 14:34:07 +0800 Subject: [PATCH] * Finish bug control view. --- module/bug/control.php | 63 +++--------------------------- module/bug/test/bug.class.php | 1 + module/bug/zen.php | 72 +++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 57 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index ff006d5554..f69e1cf777 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -313,7 +313,7 @@ class bug extends control * @access public * @return void */ - public function create(string $productID, string $branch = '', string $extras = ''): void + public function create(string $productID, string $branch = '', string $extras = '') { $productID = (int)$productID; @@ -839,14 +839,15 @@ class bug extends control } /** + * 查看一个bug。 * View a bug. * - * @param int $bugID + * @param string $bugID * @param string $form * @access public * @return void */ - public function view($bugID, $from = 'bug') + public function view(string $bugID, string $from = 'bug') { /* Judge bug exits or not. */ $bugID = (int)$bugID; @@ -860,60 +861,8 @@ class bug extends control /* Update action. */ if($bug->assignedTo == $this->app->user->account) $this->loadModel('action')->read('bug', $bugID); - /* Set menu. */ - if(!isonlybody()) - { - if($this->app->tab == 'project') $this->loadModel('project')->setMenu($bug->project); - if($this->app->tab == 'execution') $this->loadModel('execution')->setMenu($bug->execution); - if($this->app->tab == 'qa') $this->qa->setMenu($this->products, $bug->product, $bug->branch); - - if($this->app->tab == 'devops') - { - $repos = $this->loadModel('repo')->getRepoPairs('project', $bug->project); - $this->repo->setMenu($repos); - $this->lang->navGroup->bug = 'devops'; - } - - if($this->app->tab == 'product') - { - $this->loadModel('product')->setMenu($bug->product); - $this->lang->product->menu->plan['subModule'] .= ',bug'; - } - } - - /* Get product info. */ - $productID = $bug->product; - $product = $this->loadModel('product')->getByID($productID); - $branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($bug->product); - - $projects = $this->loadModel('product')->getProjectPairsByProduct($productID, $bug->branch); - $this->session->set("project", key($projects), 'project'); - - $this->executeHooks($bugID); - - /* Header and positon. */ - $this->view->title = "BUG #$bug->id $bug->title - " . $product->name; - $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $product->name); - $this->view->position[] = $this->lang->bug->view; - - /* Assign. */ - $this->view->project = $this->loadModel('project')->getByID($bug->project); - $this->view->productID = $productID; - $this->view->branches = $branches; - $this->view->modulePath = $this->tree->getParents($bug->module); - $this->view->bugModule = empty($bug->module) ? '' : $this->tree->getById($bug->module); - $this->view->bug = $bug; - $this->view->from = $from; - $this->view->branchName = $product->type == 'normal' ? '' : zget($branches, $bug->branch, ''); - $this->view->users = $this->user->getPairs('noletter'); - $this->view->actions = $this->action->getList('bug', $bugID); - $this->view->builds = $this->loadModel('build')->getBuildPairs($productID, 'all'); - $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('bug', $bugID); - $this->view->product = $product; - $this->view->linkCommits = $this->loadModel('repo')->getCommitsByObject($bugID, 'bug'); - - $this->view->projects = array('' => '') + $projects; - + if(!isonlybody()) $this->bugZen->setMenu4View($bug); + $this->bugZen->setView4View($bug, $from); $this->display(); } diff --git a/module/bug/test/bug.class.php b/module/bug/test/bug.class.php index 51a68a6381..f3aa1221f3 100644 --- a/module/bug/test/bug.class.php +++ b/module/bug/test/bug.class.php @@ -29,6 +29,7 @@ class bugTest $bug->openedBy = 'admin'; $bug->openedDate = '2023-04-20'; $bug->notifyEmail = ''; + $bug->steps = ''; foreach($param as $key => $value) $bug->$key = $value; diff --git a/module/bug/zen.php b/module/bug/zen.php index 4ad01feb25..67e38d9ce7 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -149,4 +149,76 @@ class bugZen extends bug $this->view->users = $this->user->getPairs('devfirst|noclosed|nodeleted'); $this->app->loadLang('release'); } + + /** + * 为查看bug设置导航数据。 + * Set menu for view bug page. + * + * @param object $bug + * @return void + */ + protected function setMenu4View(object $bug): void + { + if($this->app->tab == 'project') $this->loadModel('project')->setMenu($bug->project); + if($this->app->tab == 'execution') $this->loadModel('execution')->setMenu($bug->execution); + if($this->app->tab == 'qa') $this->qa->setMenu($this->products, $bug->product, $bug->branch); + + if($this->app->tab == 'devops') + { + $repos = $this->loadModel('repo')->getRepoPairs('project', $bug->project); + $this->repo->setMenu($repos); + $this->lang->navGroup->bug = 'devops'; + } + + if($this->app->tab == 'product') + { + $this->loadModel('product')->setMenu($bug->product); + $this->lang->product->menu->plan['subModule'] .= ',bug'; + } + } + + /** + * 为查看bug设置View数据。 + * Set $this->view for view bug page. + * + * @param object $bug + * @param string $from + * @return void + */ + protected function setView4View(object $bug, string $from): void + { + /* Get product info. */ + $bugID = $bug->id; + $productID = $bug->product; + $product = $this->loadModel('product')->getByID($productID); + $branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($bug->product); + + $projects = $this->loadModel('product')->getProjectPairsByProduct($productID, $bug->branch); + $this->session->set("project", key($projects), 'project'); + + $this->executeHooks($bugID); + + /* Header and positon. */ + $this->view->title = "BUG #$bug->id $bug->title - " . $product->name; + $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $product->name); + $this->view->position[] = $this->lang->bug->view; + + /* Assign. */ + $this->view->project = $this->loadModel('project')->getByID($bug->project); + $this->view->productID = $productID; + $this->view->branches = $branches; + $this->view->modulePath = $this->tree->getParents($bug->module); + $this->view->bugModule = empty($bug->module) ? '' : $this->tree->getById($bug->module); + $this->view->bug = $bug; + $this->view->from = $from; + $this->view->branchName = $product->type == 'normal' ? '' : zget($branches, $bug->branch, ''); + $this->view->users = $this->user->getPairs('noletter'); + $this->view->actions = $this->action->getList('bug', $bugID); + $this->view->builds = $this->loadModel('build')->getBuildPairs($productID, 'all'); + $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('bug', $bugID); + $this->view->product = $product; + $this->view->linkCommits = $this->loadModel('repo')->getCommitsByObject($bugID, 'bug'); + + $this->view->projects = array('' => '') + $projects; + } }