From b8f443b5b7b441e36ad360b0799b7331bb7d44d8 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Tue, 26 Mar 2024 15:13:34 +0800 Subject: [PATCH] * Replace with common::buildOperateMenu to get the productplan actions. --- module/productplan/config.php | 4 ++++ module/productplan/control.php | 1 - module/productplan/ui/view.html.php | 8 +++++++- module/productplan/zen.php | 32 ----------------------------- 4 files changed, 11 insertions(+), 34 deletions(-) diff --git a/module/productplan/config.php b/module/productplan/config.php index 690059b231..a2b40d97bf 100644 --- a/module/productplan/config.php +++ b/module/productplan/config.php @@ -91,3 +91,7 @@ $config->productplan->actionList['unlinkBug']['url'] = 'javascript:unlinkObject $config->productplan->actionList['unlinkStory']['icon'] = 'unlink'; $config->productplan->actionList['unlinkStory']['hint'] = $lang->productplan->unlinkStory; $config->productplan->actionList['unlinkStory']['url'] = 'javascript:unlinkObject("story", "{id}")'; + +$config->productplan->actions = new stdclass(); +$config->productplan->actions->view = array(); +$config->productplan->actions->view['mainActions'] = array('start', 'finish', 'close', 'activate', 'create', 'edit', 'delete'); diff --git a/module/productplan/control.php b/module/productplan/control.php index 672cd2631e..d22ffcfe05 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -387,7 +387,6 @@ class productplan extends control $this->view->planStories = $planStories; $this->view->planBugs = $this->loadModel('bug')->getPlanBugs($planID, 'all', $type == 'bug' ? $sort : 'id_desc', $bugPager); $this->view->summary = $this->product->summary($planStories); - $this->view->actionMenus = $this->productplanZen->buildViewActions($plan); $this->view->type = $type; $this->view->orderBy = $orderBy; $this->view->link = $link; diff --git a/module/productplan/ui/view.html.php b/module/productplan/ui/view.html.php index b70413bc00..56fb32553a 100644 --- a/module/productplan/ui/view.html.php +++ b/module/productplan/ui/view.html.php @@ -159,6 +159,12 @@ $fnGetChildrenPlans = function($childrenPlans) return $childrenPlanItems; }; +$actions = $this->loadModel('common')->buildOperateMenu($plan); +foreach($actions['mainActions'] as $key => $action) +{ + $actions['mainActions'][$key]['className'] = isset($action['className']) ? $action['className'] . ' ghost' : 'ghost'; + $actions['mainActions'][$key]['iconClass'] = isset($action['iconClass']) ? $action['iconClass'] . ' text-primary' : 'text-primary'; +} detailHeader ( to::prefix @@ -169,7 +175,7 @@ detailHeader span(setClass('label circle primary'), ($plan->begin == FUTURE_TIME || $plan->end == FUTURE_TIME) ? $lang->productplan->future : $plan->begin . '~' . $plan->end), $plan->deleted ? span(setClass('label danger'), $lang->product->deleted) : null ), - (!$plan->deleted && $actionMenus) ? to::suffix(btnGroup(set::items($actionMenus))) : null + (!$plan->deleted && $actions) ? to::suffix(btnGroup(set::items($actions['mainActions']))) : null ); detailBody diff --git a/module/productplan/zen.php b/module/productplan/zen.php index b69df5a125..d9722a50e4 100644 --- a/module/productplan/zen.php +++ b/module/productplan/zen.php @@ -331,36 +331,4 @@ class productplanZen extends productplan } $this->loadModel('search')->setSearchParams($this->config->bug->search); } - - /** - * 构造计划详情页面的操作菜单。 - * Build operate menu for plan detail page. - * - * @param object $plan - * @access public - * @return array - */ - public function buildViewActions(object $plan): array - { - $params = "planID=$plan->id"; - - $canEdit = common::hasPriv('productplan', 'edit'); - $canStart = common::hasPriv('productplan', 'start') && $this->productplan->isClickable($plan, 'start'); - $canFinish = common::hasPriv('productplan', 'finish') && $this->productplan->isClickable($plan, 'finish'); - $canClose = common::hasPriv('productplan', 'close') && $this->productplan->isClickable($plan, 'close'); - $canActivate = common::hasPriv('productplan', 'activate') && $this->productplan->isClickable($plan, 'activate'); - $canCreateChild = common::hasPriv('productplan', 'create') && $this->productplan->isClickable($plan, 'create'); - $canDelete = common::hasPriv('productplan', 'delete') && $this->productplan->isClickable($plan, 'delete'); - - $menu = array(); - if($canStart) $menu[] = array('icon' => 'play text-primary', 'class' => 'ghost', 'text' => $this->lang->productplan->startAB, 'data-url' => helper::createLink('productplan', 'start', $params), 'data-action' => 'start', 'onclick' => 'ajaxConfirmLoad(this)'); - if($canFinish) $menu[] = array('icon' => 'checked text-primary', 'class' => 'ghost', 'text' => $this->lang->productplan->finishAB, 'data-url' => helper::createLink('productplan', 'finish', $params), 'data-action' => 'finish', 'onclick' => 'ajaxConfirmLoad(this)'); - if($canClose) $menu[] = array('icon' => 'off text-primary', 'class' => 'ghost', 'text' => $this->lang->productplan->closeAB, 'url' => helper::createLink('productplan', 'close', $params, '', true), 'data-toggle' => 'modal'); - if($canActivate) $menu[] = array('icon' => 'magic text-primary', 'class' => 'ghost', 'text' => $this->lang->productplan->activateAB, 'data-url' => helper::createLink('productplan', 'activate', $params), 'data-action' => 'activate', 'onclick' => 'ajaxConfirmLoad(this)'); - if($canCreateChild) $menu[] = array('icon' => 'split text-primary', 'class' => 'ghost', 'text' => $this->lang->productplan->children, 'url' => helper::createLink('productplan', 'create', "product={$plan->product}&branch={$plan->branch}&parent={$plan->id}")); - if($canEdit) $menu[] = array('icon' => 'edit text-primary', 'class' => 'ghost', 'text' => $this->lang->edit, 'url' => helper::createLink('productplan', 'edit', $params)); - if($canDelete) $menu[] = array('icon' => 'trash text-primary', 'class' => 'ghost', 'text' => $this->lang->delete, 'data-url' => helper::createLink('productplan', 'delete', $params), 'data-action' => 'delete', 'onclick' => 'ajaxConfirmLoad(this)'); - - return $menu; - } }