From 6bdf89c2932856836f6a317ffa1fcb6b955ba404 Mon Sep 17 00:00:00 2001 From: zenggang Date: Fri, 29 Oct 2021 03:18:10 +0000 Subject: [PATCH] * Finish task#43410,43411,43413 --- module/bug/control.php | 1 + module/execution/js/kanban.js | 71 ++++++++++++++++++++--------- module/kanban/model.php | 84 +++++++++++++++++++++++++++++++++++ module/story/control.php | 2 + module/task/control.php | 1 + 5 files changed, 137 insertions(+), 22 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index c1015230f9..9a34399db4 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -843,6 +843,7 @@ class bug extends control } } } + if(isonlybody()) die(js::reload('parent.parent')); die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent')); } diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index b9ed2c827f..dec5d80d96 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -489,14 +489,27 @@ function createStoryMenu(options) { var $card = options.$trigger.closest('.kanban-item'); var story = $card.data('item'); - var items = - [ - {label: '编辑需求', icon: 'edit', url: $.createLink('story', 'edit', 'storyID=' + story.id), className: 'iframe'}, - {label: '变更需求', icon: 'change', url: $.createLink('story', 'change', 'storyID=' + story.id), className: 'iframe'}, - {label: '移除需求', icon: 'unlink', url: $.createLink('story', 'unlink', 'storyID=' + story.id), className: 'iframe'}, - {label: '分解任务', icon: 'plus', url: $.createLink('task', 'create', 'storyID=' + story.id), className: 'iframe'}, - {label: '批量分解', icon: 'pluses', url: $.createLink('task', 'batchCreate', 'storyID=' + story.id), className: 'iframe'}, - ]; + + var items = []; + $.each(story.menus, function() + { + if(this.size == 'big') + { + items.push({label: this.label, icon: this.icon, url: this.url, attrs: {'data-width': '95%', 'data-toggle': 'modal', 'data-type': 'iframe'}}); + } + else + { + if(this.icon == 'unlink') + { + items.push({label: this.label, icon: this.icon, url: this.url, attrs: {'target': 'hiddenwin'}}); + } + else + { + items.push({label: this.label, icon: this.icon, url: this.url, attrs: {'data-toggle': 'modal', 'data-type': 'iframe'}}); + } + } + }); + return items; } @@ -508,13 +521,20 @@ function createBugMenu(options) { var $card = options.$trigger.closest('.kanban-item'); var bug = $card.data('item'); - var items = - [ - {label: '编辑Bug', icon: 'edit', url: $.createLink('bug', 'edit', 'bugID=' + bug.id), className: 'iframe'}, - {label: '确认Bug', icon: 'ok', url: $.createLink('bug', 'confirm', 'bugID=' + bug.id), className: 'iframe'}, - {label: '复制Bug', icon: 'copy', url: $.createLink('bug', 'copy', 'bugID=' + bug.id), className: 'iframe'}, - {label: '转软件需求', icon: 'lightbulb', url: $.createLink('story', 'create', 'bugID=' + bug.id), className: 'iframe'}, - ]; + + var items = []; + $.each(bug.menus, function() + { + if(this.size == 'big') + { + items.push({label: this.label, icon: this.icon, url: this.url, attrs: {'data-width': '95%', 'data-toggle': 'modal', 'data-type': 'iframe'}}); + } + else + { + items.push({label: this.label, icon: this.icon, url: this.url, attrs: {'data-toggle': 'modal', 'data-type': 'iframe'}}); + } + }); + return items; } @@ -526,13 +546,20 @@ function createTaskMenu(options) { var $card = options.$trigger.closest('.kanban-item'); var task = $card.data('item'); - var items = - [ - {label: '编辑任务', icon: 'edit', url: $.createLink('task', 'edit', 'taskID=' + task.id), className: 'iframe'}, - {label: '拆分子任务', icon: 'plus', url: $.createLink('task', 'create', 'taskID=' + task.id), className: 'iframe'}, - {label: '复制任务', icon: 'copy', url: $.createLink('task', 'copy', 'taskID=' + task.id), className: 'iframe'}, - {label: '取消任务', icon: 'cancel', url: $.createLink('task', 'cancel', 'taskID=' + task.id), className: 'iframe'}, - ]; + + var items = []; + $.each(task.menus, function() + { + if(this.size == 'big') + { + items.push({label: this.label, icon: this.icon, url: this.url, attrs: {'data-width': '95%', 'data-toggle': 'modal', 'data-type': 'iframe'}}); + } + else + { + items.push({label: this.label, icon: this.icon, url: this.url, attrs: {'data-toggle': 'modal', 'data-type': 'iframe'}}); + } + }); + return items; } diff --git a/module/kanban/model.php b/module/kanban/model.php index 223869c915..be257172c4 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -50,6 +50,11 @@ class kanbanModel extends model if($browseType == 'all' or $browseType == 'bug') $objectGroup['bug'] = $this->loadModel('bug')->getExecutionBugs($executionID); if($browseType == 'all' or $browseType == 'task') $objectGroup['task'] = $this->loadModel('execution')->getKanbanTasks($executionID, "id"); + /* Get objects cards menus. */ + $storyCardMenu = $this->getExecutionCardMenu($executionID, $objectGroup['story'], 'story'); + $bugCardMenu = $this->getExecutionCardMenu($executionID, $objectGroup['bug'], 'bug'); + $taskCardMenu = $this->getExecutionCardMenu($executionID, $objectGroup['task'], 'task'); + /* Build kanban group data. */ $kanbanGroup = array(); foreach($lanes as $laneID => $lane) @@ -105,6 +110,10 @@ class kanbanModel extends model $cardData['title'] = $object->title; } + if($laneType == 'story') $cardData['menus'] = $storyCardMenu[$object->id]; + if($laneType == 'bug') $cardData['menus'] = $bugCardMenu[$object->id]; + if($laneType == 'task') $cardData['menus'] = $taskCardMenu[$object->id]; + $laneData['cards'][$column->type][] = $cardData; $cardOrder ++; } @@ -506,4 +515,79 @@ class kanbanModel extends model $changes = common::createChanges($column, $data); return $changes; } + + /** + * Get Kanban cards menus by execution id. + * + * @param int $executionID + * @param array $objects + * @param string $objecType story|bug|task + * @access public + * @return array + */ + public function getExecutionCardMenu($executionID, $objects, $objecType) + { + $menus = array(); + switch ($objecType) + { + case 'story': + if(!isset($this->story)) $this->loadModel('story'); + + $objects = $this->story->mergeReviewer($objects); + foreach($objects as $story) + { + $menu = array(); + + $toTaskPriv = strpos('draft,closed', $story->status) !== false ? false : true; + if(common::hasPriv('story', 'edit') and $this->story->isClickable($story, 'edit')) $menu[] = array('label' => $this->lang->story->edit, 'icon' => 'edit', 'url' => helper::createLink('story', 'edit', "storyID=$story->id", '', true), 'size' => 'big'); + if(common::hasPriv('story', 'change') and $this->story->isClickable($story, 'change')) $menu[] = array('label' => $this->lang->story->change, 'icon' => 'alter', 'url' => helper::createLink('story', 'change', "storyID=$story->id", '', true), 'size' => 'big'); + if(common::hasPriv('story', 'review') and $this->story->isClickable($story, 'review')) $menu[] = array('label' => $this->lang->story->review, 'icon' => 'search', 'url' => helper::createLink('story', 'review', "storyID=$story->id", '', true), 'size' => 'big'); + if(common::hasPriv('task', 'create') and $toTaskPriv) $menu[] = array('label' => $this->lang->execution->wbs, 'icon' => 'plus', 'url' => helper::createLink('task', 'create', "executionID=$executionID&storyID=$story->id&moduleID=$story->module", '', true), 'size' => 'big'); + if(common::hasPriv('task', 'batchCreate') and $toTaskPriv) $menu[] = array('label' => $this->lang->execution->batchWBS, 'icon' => 'pluses', 'url' => helper::createLink('task', 'batchCreate', "executionID=$executionID&storyID=$story->id&moduleID=0&taskID=0&iframe=true", '', true), 'size' => 'big'); + if(common::hasPriv('story', 'activate') and $this->story->isClickable($story, 'activate')) $menu[] = array('label' => $this->lang->story->change, 'icon' => 'magic', 'url' => helper::createLink('story', 'activate', "storyID=$story->id", '', true)); + if(common::hasPriv('execution', 'unlinkStory')) $menu[] = array('label' => $this->lang->execution->unlinkStory, 'icon' => 'unlink', 'url' => helper::createLink('execution', 'unlinkStory', "executionID=$executionID&storyID=$story->story&confirm=no", '', true)); + + $menus[$story->id] = $menu; + } + break; + case 'bug': + if(!isset($this->bug)) $this->loadModel('bug'); + + foreach($objects as $bug) + { + $menu = array(); + + if(common::hasPriv('bug', 'edit') and $this->bug->isClickable($bug, 'edit')) $menu[] = array('label' => $this->lang->bug->edit, 'icon' => 'edit', 'url' => helper::createLink('bug', 'edit', "bugID=$bug->id", '', true), 'size' => 'big'); + if(common::hasPriv('bug', 'confirmBug') and $this->bug->isClickable($bug, 'confirmBug')) $menu[] = array('label' => $this->lang->bug->confirmBug, 'icon' => 'ok', 'url' => helper::createLink('bug', 'confirmBug', "bugID=$bug->id", '', true)); + if(common::hasPriv('bug', 'resolve') and $this->bug->isClickable($bug, 'resolve')) $menu[] = array('label' => $this->lang->bug->resolve, 'icon' => 'checked', 'url' => helper::createLink('bug', 'resolve', "bugID=$bug->id", '', true)); + if(common::hasPriv('bug', 'close') and $this->bug->isClickable($bug, 'close')) $menu[] = array('label' => $this->lang->bug->close, 'icon' => 'plus', 'url' => helper::createLink('bug', 'close', "bugID=$bug->id", '', true)); + if(common::hasPriv('bug', 'create') and $this->bug->isClickable($bug, 'create')) $menu[] = array('label' => $this->lang->bug->copy, 'icon' => 'pluses', 'url' => helper::createLink('bug', 'create', "productID=$bug->product&branch=$bug->branch&extras=bugID=$bug->id", '', true), 'size' => 'big'); + if(common::hasPriv('bug', 'activate') and $this->bug->isClickable($bug, 'activate')) $menu[] = array('label' => $this->lang->bug->activate, 'icon' => 'magic', 'url' => helper::createLink('bug', 'activate', "bugID=$bug->id", '', true)); + if(common::hasPriv('story', 'create') and $bug->status != 'closed') $menu[] = array('label' => $this->lang->bug->toStory, 'icon' => 'unlink', 'url' => helper::createLink('story', 'create', "product=$bug->product&branch=$bug->branch&module=0&story=0&execution=0&bugID=$bug->id", '', true), 'size' => 'big'); + + $menus[$bug->id] = $menu; + } + break; + case 'task': + if(!isset($this->task)) $this->loadModel('task'); + + foreach($objects as $task) + { + $menu = array(); + + if(common::hasPriv('task', 'edit') and $this->task->isClickable($task, 'edit')) $menu[] = array('label' => $this->lang->task->edit, 'icon' => 'edit', 'url' => helper::createLink('task', 'edit', "taskID=$task->id", '', true), 'size' => 'big'); + if(common::hasPriv('task', 'pause') and $this->task->isClickable($task, 'pause')) $menu[] = array('label' => $this->lang->task->pause, 'icon' => 'ok', 'url' => helper::createLink('task', 'pause', "taskID=$task->id", '', true)); + if(common::hasPriv('task', 'restart') and $this->task->isClickable($task, 'restart')) $menu[] = array('label' => $this->lang->task->restart, 'icon' => 'play', 'url' => helper::createLink('task', 'restart', "taskID=$task->id", '', true)); + if(common::hasPriv('task', 'recordEstimate') and $this->task->isClickable($task, 'recordEstimate')) $menu[] = array('label' => $this->lang->task->recordEstimate, 'icon' => 'time', 'url' => helper::createLink('task', 'recordEstimate', "taskID=$task->id", '', true)); + if(common::hasPriv('task', 'activate') and $this->task->isClickable($task, 'activate')) $menu[] = array('label' => $this->lang->task->activate, 'icon' => 'magic', 'url' => helper::createLink('task', 'activate', "taskID=$task->id", '', true)); + if(common::hasPriv('task', 'batchCreate') and $this->task->isClickable($task, 'batchCreate')) $menu[] = array('label' => $this->lang->task->children, 'icon' => 'split', 'url' => helper::createLink('task', 'batchCreate', "execution=$task->execution&storyID=$task->story&moduleID=$task->module&taskID=$task->id", '', true), 'size' => 'big'); + if(common::hasPriv('task', 'create') and $this->task->isClickable($task, 'create')) $menu[] = array('label' => $this->lang->task->copy, 'icon' => 'copy', 'url' => helper::createLink('task', 'create', "projctID=$task->execution&storyID=$task->story&moduleID=$task->module&taskID=$task->id", '', true), 'size' => 'big'); + if(common::hasPriv('task', 'cancel') and $this->task->isClickable($task, 'cancel')) $menu[] = array('label' => $this->lang->task->cancel, 'icon' => 'ban-circle', 'url' => helper::createLink('task', 'cancel', "taskID=$task->id", '', true)); + + $menus[$task->id] = $menu; + } + break; + } + return $menus; + } } diff --git a/module/story/control.php b/module/story/control.php index 1d1f494e1e..d9cf6ad772 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -589,6 +589,7 @@ class story extends control $this->executeHooks($storyID); + if(isonlybody()) die(js::reload('parent.parent')); if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $storyID)); die(js::locate($this->createLink($this->app->rawModule, 'view', "storyID=$storyID"), 'parent')); } @@ -838,6 +839,7 @@ class story extends control $module = $this->app->tab == 'project' ? 'projectstory' : 'story'; + if(isonlybody()) die(js::reload('parent.parent')); if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); die(js::locate($this->createLink($module, 'view', "storyID=$storyID"), 'parent')); } diff --git a/module/task/control.php b/module/task/control.php index 0c39718954..06a407a729 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -408,6 +408,7 @@ class task extends control } } + if(isonlybody()) die(js::reload('parent.parent')); if(defined('RUN_MODE') && RUN_MODE == 'api') { return $this->send(array('status' => 'success', 'data' => $taskID));