* Move method to zen.php.

This commit is contained in:
caoyanyi
2023-09-26 15:30:42 +08:00
parent f5669baf35
commit c8985e95a5
4 changed files with 34 additions and 33 deletions
+1
View File
@@ -375,6 +375,7 @@ 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->buildOperateMenu($plan);
$this->view->type = $type;
$this->view->orderBy = $orderBy;
$this->view->link = $link;
-31
View File
@@ -1100,37 +1100,6 @@ class productplanModel extends model
return true;
}
/**
* Build operate menu.
*
* @param object $plan
* @access public
* @return string
*/
public function buildOperateMenu($plan)
{
$params = "planID=$plan->id";
$canStart = common::hasPriv('productplan', 'start') && static::isClickable($plan, 'start');
$canFinish = common::hasPriv('productplan', 'finish') && static::isClickable($plan, 'finish');
$canClose = common::hasPriv('productplan', 'close') && static::isClickable($plan, 'close');
$canActivate = common::hasPriv('productplan', 'activate') && static::isClickable($plan, 'activate');
$canEdit = common::hasPriv('productplan', 'edit');
$canCreateChild = common::hasPriv('productplan', 'create') && static::isClickable($plan, 'create');
$canDelete = common::hasPriv('productplan', 'delete') && static::isClickable($plan, 'delete');
$menu = array();
if($canStart) $menu[] = array('icon' => 'play', 'class' => 'ghost', 'text' => $this->lang->productplan->startAB, 'data-url' => helper::createLink('productplan', 'start', $params . '&confirm=yes'), 'data-action' => 'start', 'onclick' => 'ajaxConfirmLoad(this)');
if($canFinish) $menu[] = array('icon' => 'checked', 'class' => 'ghost', 'text' => $this->lang->productplan->finishAB, 'data-url' => helper::createLink('productplan', 'finish', $params . '&confirm=yes'), 'data-action' => 'finish', 'onclick' => 'ajaxConfirmLoad(this)');
if($canClose) $menu[] = array('icon' => 'off', 'class' => 'ghost', 'text' => $this->lang->productplan->closeAB, 'url' => helper::createLink('productplan', 'close', $params, '', true), 'data-toggle' => 'modal');
if($canActivate) $menu[] = array('icon' => 'magic', 'class' => 'ghost', 'text' => $this->lang->productplan->activateAB, 'data-url' => helper::createLink('productplan', 'activate', $params . '&confirm=yes'), 'data-action' => 'activate', 'onclick' => 'ajaxConfirmLoad(this)');
if($canCreateChild) $menu[] = array('icon' => 'split', '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', 'class' => 'ghost', 'text' => $this->lang->edit, 'url' => helper::createLink('productplan', 'edit', $params));
if($canDelete) $menu[] = array('icon' => 'trash', 'class' => 'ghost', 'text' => $this->lang->delete, 'data-url' => helper::createLink('productplan', 'delete', $params . '&confirm=yes'), 'data-action' => 'delete', 'onclick' => 'ajaxConfirmLoad(this)');
return $menu;
}
/**
* 构造计划搜索功能数据。
* Build search form for plan.
+1 -2
View File
@@ -164,7 +164,6 @@ $fnGetChildrenPlans = function($childrenPlans)
return $childrenPlanItems;
};
$menus = $this->productplan->buildOperateMenu($plan);
detailHeader
(
to::prefix
@@ -175,7 +174,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 && !isonlybody() && $menus) ? to::suffix(btnGroup(setClass('text-primary'), set::items($menus))) : null
(!$plan->deleted && !isonlybody() && $actionMenus) ? to::suffix(btnGroup(setClass('text-primary'), set::items($actionMenus))) : null
);
detailBody
+32
View File
@@ -329,4 +329,36 @@ 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 buildOperateMenu(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', 'class' => 'ghost', 'text' => $this->lang->productplan->startAB, 'data-url' => helper::createLink('productplan', 'start', $params . '&confirm=yes'), 'data-action' => 'start', 'onclick' => 'ajaxConfirmLoad(this)');
if($canFinish) $menu[] = array('icon' => 'checked', 'class' => 'ghost', 'text' => $this->lang->productplan->finishAB, 'data-url' => helper::createLink('productplan', 'finish', $params . '&confirm=yes'), 'data-action' => 'finish', 'onclick' => 'ajaxConfirmLoad(this)');
if($canClose) $menu[] = array('icon' => 'off', 'class' => 'ghost', 'text' => $this->lang->productplan->closeAB, 'url' => helper::createLink('productplan', 'close', $params, '', true), 'data-toggle' => 'modal');
if($canActivate) $menu[] = array('icon' => 'magic', 'class' => 'ghost', 'text' => $this->lang->productplan->activateAB, 'data-url' => helper::createLink('productplan', 'activate', $params . '&confirm=yes'), 'data-action' => 'activate', 'onclick' => 'ajaxConfirmLoad(this)');
if($canCreateChild) $menu[] = array('icon' => 'split', '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', 'class' => 'ghost', 'text' => $this->lang->edit, 'url' => helper::createLink('productplan', 'edit', $params));
if($canDelete) $menu[] = array('icon' => 'trash', 'class' => 'ghost', 'text' => $this->lang->delete, 'data-url' => helper::createLink('productplan', 'delete', $params . '&confirm=yes'), 'data-action' => 'delete', 'onclick' => 'ajaxConfirmLoad(this)');
return $menu;
}
}