* Optimize the display logic of actions on the bug view page and browse page.

This commit is contained in:
wangyuting
2023-05-19 17:23:24 +08:00
parent bbe43a801f
commit f7ee372afc
5 changed files with 85 additions and 69 deletions
+4
View File
@@ -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();
+32 -49
View File
@@ -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";
+1 -1
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
*/
namespace zin;
$this->bug->setOperateActions($view = 'browse');
$this->bug->buildOperateMenu(null, 'browse');
foreach($bugs as $bug)
{
+47 -19
View File
@@ -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'),
)
)
)
)
)
+1
View File
@@ -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;
}