* Finish bug control view.

This commit is contained in:
songchenxuan
2023-04-28 14:34:07 +08:00
parent 751c1f5845
commit 6f2d0d92af
3 changed files with 79 additions and 57 deletions
+6 -57
View File
@@ -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();
}
+1
View File
@@ -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;
+72
View File
@@ -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;
}
}