From f7ee372afc5d4451cdcdc1d3739b1eb16e9442a6 Mon Sep 17 00:00:00 2001 From: wangyuting Date: Fri, 19 May 2023 17:23:24 +0800 Subject: [PATCH] * Optimize the display logic of actions on the bug view page and browse page. --- module/bug/config.php | 4 ++ module/bug/model.php | 81 ++++++++++++++--------------------- module/bug/ui/browse.html.php | 2 +- module/bug/ui/view.html.php | 66 ++++++++++++++++++++-------- module/bug/zen.php | 1 + 5 files changed, 85 insertions(+), 69 deletions(-) diff --git a/module/bug/config.php b/module/bug/config.php index 359c74508b..a55dd9ab32 100755 --- a/module/bug/config.php +++ b/module/bug/config.php @@ -11,6 +11,10 @@ $config->bug->create->requiredFields = 'title,openedBuild'; $config->bug->edit->requiredFields = $config->bug->create->requiredFields; $config->bug->resolve->requiredFields = 'resolution'; +$config->bug->actions = new stdclass(); +$config->bug->actions->browse = 'confirm,resolve,close,edit,copy'; +$config->bug->actions->view = 'confirm,assignTo,resolve,close,activate'; + $config->bug->browseTypeList = array('all', 'bymodule', 'assigntome', 'openedbyme', 'resolvedbyme', 'assigntonull', 'unconfirmed', 'unresolved', 'unclosed', 'toclosed', 'longlifebugs', 'postponedbugs', 'overduebugs', 'assignedbyme', 'review', 'needconfirm'); $config->bug->list = new stdclass(); diff --git a/module/bug/model.php b/module/bug/model.php index 1be0d49e86..104f7768a5 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -2818,62 +2818,45 @@ class bugModel extends model } /** - * 设置操作按钮。 - * Set operate actions. - * - * @param string $type browse|view - * @access public - * @return void - */ - public function setOperateActions(string $type = 'browse'): void - { - $params = 'bugID={id}'; - - $actions = array(); - $actions['confirm']['icon'] = 'icon-ok'; - $actions['confirm']['hint'] = $this->lang->bug->confirm; - $actions['confirm']['url'] = inlink('confirm', $params); - $actions['confirm']['data-toggle'] = 'modal'; - - $actions['resolve']['icon'] = 'icon-checked'; - $actions['resolve']['hint'] = $this->lang->bug->resolve; - $actions['resolve']['url'] = inlink('resolve', $params); - $actions['resolve']['data-toggle'] = 'modal'; - - $actions['close']['icon'] = 'icon-off'; - $actions['close']['hint'] = $this->lang->bug->close; - $actions['close']['url'] = inlink('close', $params); - $actions['close']['data-toggle'] = 'modal'; - - $actions['edit']['icon'] = 'icon-edit'; - $actions['edit']['hint'] = $this->lang->bug->edit; - $actions['edit']['url'] = inlink('edit', $params); - - if($this->app->tab != 'product') - { - $extraParams = "extras=$params"; - if($this->app->tab == 'project') $extraParams .= ',projectID={project}'; - if($this->app->tab == 'execution') $extraParams .= ',executionID={execution}'; - $copyParams = "productID={product}&branch={branch}&$extraParams"; - - $actions['copy']['icon'] = 'icon-copy'; - $actions['copy']['hint'] = $this->lang->bug->copy; - $actions['copy']['url'] = inlink('create', $copyParams); - } - - $this->config->bug->dtable->fieldList['actions']['actionsMap'] = $actions; - } - - /** - * Build bug menu. + * 构造详情页或列表页需要的操作菜单。 + * Build action menu. * * @param object $bug * @param string $type * @access public * @return string */ - public function buildOperateMenu($bug, $type = 'view') + public function buildOperateMenu(object $bug = null, $type = 'view'): array { + $defaultParams = $bug ? "bugID={$bug->id}" : 'bugID={id}'; + $copyParams = $bug ? "productID={$bug->product}&branch={$bug->branch}&extra=bugID={$bug->id}" : 'productID={product}&branch={branch}&extra=bugID={id}'; + if($this->app->tab == 'project') $copyParams .= ',projectID={project}'; + if($this->app->tab == 'execution') $copyParams .= ',executionID={execution}'; + + $actions = array(); + $actions['confirm'] = array('icon' => 'ok', 'text' => $this->lang->bug->confirmedAB, 'url' => helper::createLink('bug', 'confirmBug', $defaultParams), 'data-toggle' => 'modal'); + $actions['assignTo'] = array('icon' => 'hand-right', 'text' => $this->lang->bug->assignTo, 'url' => helper::createLink('bug', 'assignTo', $defaultParams), 'data-toggle' => 'modal'); + $actions['resolve'] = array('icon' => 'checked', 'text' => $this->lang->bug->resolve, 'url' => helper::createLink('bug', 'resolve', $defaultParams), 'data-toggle' => 'modal'); + $actions['close'] = array('icon' => 'off', 'text' => $this->lang->bug->close, 'url' => helper::createLink('bug', 'close', $defaultParams), 'data-toggle' => 'modal'); + $actions['activate'] = array('icon' => 'magic', 'text' => $this->lang->bug->activate, 'url' => helper::createLink('bug', 'activate', $defaultParams), 'data-toggle' => 'modal'); + $actions['edit'] = array('icon' => 'edit', 'text' => $this->lang->bug->edit, 'url' => helper::createLink('bug', 'edit', $defaultParams)); + $actions['copy'] = array('icon' => 'copy', 'text' => $this->lang->bug->copy, 'url' => helper::createLink('bug', 'create', $copyParams)); + + foreach($actions as $action => $actionData) + { + $actionsConfig = $this->config->bug->actions->{$type}; + if(strpos(",{$actionsConfig},", ",{$action},") === false) + { + unset($actions[$action]); + continue; + } + $actions[$action]['hint'] = $actions[$action]['text']; + if($type == 'browse') unset($actions[$action]['text']); + } + + if($type == 'browse') $this->config->bug->dtable->fieldList['actions']['actionsMap'] = $actions; + return $actions; + $menu = ''; $params = "bugID=$bug->id"; $extraParams = "extras=bugID=$bug->id"; diff --git a/module/bug/ui/browse.html.php b/module/bug/ui/browse.html.php index 323fae5e13..218e130a98 100644 --- a/module/bug/ui/browse.html.php +++ b/module/bug/ui/browse.html.php @@ -10,7 +10,7 @@ declare(strict_types=1); */ namespace zin; -$this->bug->setOperateActions($view = 'browse'); +$this->bug->buildOperateMenu(null, 'browse'); foreach($bugs as $bug) { diff --git a/module/bug/ui/view.html.php b/module/bug/ui/view.html.php index f89fcf6bf1..9794f23385 100644 --- a/module/bug/ui/view.html.php +++ b/module/bug/ui/view.html.php @@ -12,32 +12,60 @@ declare(strict_types=1); namespace zin; panel ( - div('This is a rudimentary bug view page.'), - history(), - floatToolbar + div ( - set::prefix + set('class', 'flex'), + cell ( - array(array('icon' => 'back', 'text' => $lang->goback)) - ), - set::main - ( - array + set('width', '70%'), + set('class', 'border-r'), + history(), + center ( - array('icon' => 'ok', 'text' => $lang->bug->confirmBug, 'url' => helper::createLink('bug', 'confirmBug', "bugID=$bug->id"), 'data-toggle' => 'modal'), - array('icon' => 'hand-right', 'text' => $lang->bug->assignTo, 'url' => helper::createLink('bug', 'assignTo', "bugID=$bug->id"), 'data-toggle' => 'modal'), - array('icon' => 'checked', 'text' => $lang->bug->resolve, 'url' => helper::createLink('bug', 'resolve', "bugID=$bug->id"), 'data-toggle' => 'modal'), - array('icon' => 'close', 'text' => $lang->bug->close, 'url' => helper::createLink('bug', 'close', "bugID=$bug->id"), 'data-toggle' => 'modal'), - array('icon' => 'magic', 'text' => $lang->bug->activate, 'url' => helper::createLink('bug', 'activate', "bugID=$bug->id"), 'data-toggle' => 'modal'), + floatToolbar + ( + set::prefix + ( + array(array('icon' => 'back', 'text' => $lang->goback)) + ), + set::main($actionList), + set::suffix + ( + array + ( + array('icon' => 'edit', 'url' => helper::createLink('bug', 'edit', "bugID={$bug->id}")), + array('icon' => 'copy', 'url' => helper::createLink('bug', 'create', "productID={$bug->product}&branch={$bug->branch}&extras=bugID={$bug->id}")), + array('icon' => 'trash', 'url' => helper::createLink('bug', 'delete', "bugID={$bug->id}")), + ) + ) + ) ) ), - set::suffix + cell ( - array + set('width', '30%'), + set('class', 'px-4'), + tabs ( - array('icon' => 'edit', 'url' => helper::createLink('bug', 'edit', "bugID=$bug->id")), - array('icon' => 'copy'), - array('icon' => 'delete'), + set::items + ( + array + ( + array('id' => 'legendBasicInfo', 'label' => $lang->bug->legendBasicInfo, 'data' => '123', 'active' => true), + array('id' => 'legendLife', 'label' => $lang->bug->legendMisc, 'data' => '456'), + ) + ) + ), + tabs + ( + set::items + ( + array + ( + array('id' => 'legendExecStoryTask', 'label' => (!empty($project->multiple) ? $lang->bug->legendPRJExecStoryTask : $lang->bug->legendExecStoryTask), 'data' => '123', 'active' => true), + array('id' => 'legendMisc', 'label' => $lang->bug->legendMisc, 'data' => '456'), + ) + ) ) ) ) diff --git a/module/bug/zen.php b/module/bug/zen.php index f231410302..0ed8b358a2 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -1487,6 +1487,7 @@ class bugZen extends bug $this->view->preAndNext = $this->common->getPreAndNextObject('bug', $bugID); $this->view->product = $product; $this->view->linkCommits = $this->repo->getCommitsByObject($bugID, 'bug'); + $this->view->actionList = $this->bug->buildOperateMenu($bug, 'view'); $this->view->projects = array('' => '') + $projects; }