From c9685d4441f6ca9b6490a3275b865e389c3cbffa Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Tue, 22 Feb 2022 15:52:32 +0800 Subject: [PATCH] *Finish task 49694 49695. --- module/execution/control.php | 1 + module/execution/js/kanban.js | 33 ++++++++++++++------ module/execution/view/kanban.html.php | 45 ++++++++++++++++----------- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 65c887caee..04869fbae4 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2069,6 +2069,7 @@ class execution extends control $this->view->groupBy = $groupBy; $this->view->productID = $productID; $this->view->branchID = $branchID; + $this->view->projectID = $this->loadModel('task')->getProjectID($execution); $this->view->allPlans = $allPlans; $this->view->kanbanData = $kanbanData; $this->view->executionActions = $executionActions; diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index c746512166..b43e70754a 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -533,7 +533,7 @@ function renderBugItem(item, $item, col) if(scaleSize <= 1) { var $actions = $item.find('.actions'); - if(!$actions.length && item.menus && item.menus.length) + if(!$actions.length && (priv.canEditBug || priv.canResolveBug || priv.canConfirmBug || priv.canCopyBug || priv.canToStoryBug)) { $actions = $([ '
', @@ -597,7 +597,7 @@ function renderTaskItem(item, $item, col) if(scaleSize <= 1) { var $actions = $item.find('.actions'); - if(!$actions.length && item.menus && item.menus.length) + if(!$actions.length && (priv.canEditTask || priv.canRecordEstimateTask || priv.canCreateTask || priv.canCancelTask)) { $actions = $([ '
', @@ -1045,16 +1045,28 @@ function createTaskMenu(options) { var $card = options.$trigger.closest('.kanban-item'); var task = $card.data('item'); - var items = []; - $.each(task.menus, function() - { - var item = {label: this.label, icon: this.icon, url: this.url, attrs: {'data-toggle': 'modal', 'data-type': 'iframe'}}; - if(this.size) item.attrs['data-width'] = this.size; - - items.push(item); - }); + if(priv.canEditTask) items.push({label: taskLang.edit, icon: 'edit', url: createLink('task', 'edit', 'taskID=' + task.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + if(priv.canRecordEstimateTask) items.push({label: executionLang.effort, icon: 'time', url: createLink('task', 'recordEstimate', 'taskID=' + task.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + if(priv.canCreateTask) items.push({label: taskLang.copy, icon: 'copy', url: createLink('task', 'create', 'projectID=' + projectID + '&storyID=' + '0' + '&moduleID=' + '0' + '&taskID=' + task.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + if(priv.canCancelTask) items.push({label: taskLang.cancel, icon: 'cancel', url: createLink('task', 'cancel', 'taskID=' + task.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + return items; +} + /** + * Create bug menu + * @returns {Object[]} + */ +function createBugMenu(options) +{ + var $card = options.$trigger.closest('.kanban-item'); + var bug = $card.data('item'); + var items = []; + if(priv.canEditBug) items.push({label: bugLang.edit, icon: 'edit', url: createLink('bug', 'edit', 'bugID=' + bug.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + if(priv.canResolveBug) items.push({label: bugLang.resolve, icon: 'checked', url: createLink('bug', 'resolve', 'bugID=' + bug.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + if(priv.canConfirmBug) items.push({label: bugLang.confirmBug, icon: 'ok', url: createLink('bug', 'confirmbug', 'bugID=' + bug.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + if(priv.canCopyBug) items.push({label: bugLang.copy, icon: 'copy', url: createLink('bug', 'create', 'productID=' + productID + '&branch=' + '' + '&extras=bugID=' + bug.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); + if(priv.canToStoryBug) items.push({label: bugLang.toStory, icon: 'lightbulb', url: createLink('story', 'create', 'product=' + productID + '&branch=' + '0' + '&module=' + '0' + '&story=' + '0' + '&execution=' + '0' + '&bugID=' + bug.id, '', 'true'), className: 'iframe', attrs: {'data-toggle': 'modal', 'data-width': '80%'}}); return items; } @@ -1065,6 +1077,7 @@ window.menuCreators = column: createColumnMenu, columnCreate: createColumnCreateMenu, task: createTaskMenu, + bug: createBugMenu, }; /** diff --git a/module/execution/view/kanban.html.php b/module/execution/view/kanban.html.php index 56342f8a00..0061b92a79 100644 --- a/module/execution/view/kanban.html.php +++ b/module/execution/view/kanban.html.php @@ -46,6 +46,7 @@ js::set('displayCards', $execution->displayCards); js::set('fluidBoard', $execution->fluidBoard); js::set('colorListLang', $lang->kanbancard->colorList); js::set('colorList', $this->config->kanban->cardColorList); +js::set('projectID', $projectID); $canSortRegion = commonModel::hasPriv('kanban', 'sortRegion') && count($regions) > 1; $canEditRegion = commonModel::hasPriv('kanban', 'editRegion'); @@ -65,25 +66,31 @@ $hasBugButton = ($canCreateBug or $canBatchCreateBug); js::set('priv', array( - 'canCreateTask' => $canCreateTask, - 'canBatchCreateTask' => $canBatchCreateTask, - 'canCreateBug' => $canCreateBug, - 'canBatchCreateBug' => $canBatchCreateBug, - 'canCreateStory' => $canCreateStory, - 'canBatchCreateStory' => $canBatchCreateStory, - 'canLinkStory' => $canLinkStory, - 'canLinkStoryByPlan' => $canLinkStoryByPlan, - 'canAssignTask' => common::hasPriv('task', 'assignto'), - 'canAssignStory' => common::hasPriv('story', 'assignto'), - 'canFinishTask' => common::hasPriv('task', 'finish'), - 'canPauseTask' => common::hasPriv('task', 'pause'), - 'canCancelTask' => common::hasPriv('task', 'cancel'), - 'canCloseTask' => common::hasPriv('task', 'close'), - 'canActivateTask' => common::hasPriv('task', 'activate'), - 'canStartTask' => common::hasPriv('task', 'start'), - 'canAssignBug' => common::hasPriv('bug', 'assignto'), - 'canConfirmBug' => common::hasPriv('bug', 'confirmBug'), - 'canActivateBug' => common::hasPriv('bug', 'activate') + 'canCreateTask' => $canCreateTask, + 'canBatchCreateTask' => $canBatchCreateTask, + 'canCreateBug' => $canCreateBug, + 'canBatchCreateBug' => $canBatchCreateBug, + 'canCreateStory' => $canCreateStory, + 'canBatchCreateStory' => $canBatchCreateStory, + 'canLinkStory' => $canLinkStory, + 'canLinkStoryByPlan' => $canLinkStoryByPlan, + 'canAssignBug' => common::hasPriv('bug', 'assignto'), + 'canConfirmBug' => common::hasPriv('bug', 'confirmBug'), + 'canResolveBug' => common::hasPriv('bug', 'resolve'), + 'canCopyBug' => common::hasPriv('bug', 'create'), + 'canEditBug' => common::hasPriv('bug', 'edit'), + 'canActivateBug' => common::hasPriv('bug', 'activate'), + 'canAssignTask' => common::hasPriv('task', 'assignto'), + 'canFinishTask' => common::hasPriv('task', 'finish'), + 'canPauseTask' => common::hasPriv('task', 'pause'), + 'canCancelTask' => common::hasPriv('task', 'cancel'), + 'canCloseTask' => common::hasPriv('task', 'close'), + 'canActivateTask' => common::hasPriv('task', 'activate'), + 'canStartTask' => common::hasPriv('task', 'start'), + 'canEditTask' => common::hasPriv('task', 'edit'), + 'canRecordEstimateTask' => common::hasPriv('task', 'recordEstimate'), + 'canToStoryBug' => common::hasPriv('story', 'create'), + 'canAssignStory' => common::hasPriv('story', 'assignto'), ) ); js::set('hasStoryButton', $hasStoryButton);