diff --git a/module/project/js/bug.ui.js b/module/project/js/bug.ui.js new file mode 100644 index 0000000000..1919eca1d6 --- /dev/null +++ b/module/project/js/bug.ui.js @@ -0,0 +1,19 @@ +$(document).off('click', '.batch-btn').on('click', '.batch-btn', function() +{ + const dtable = zui.DTable.query($(this).target); + const checkedList = dtable.$.getChecks(); + if(!checkedList.length) return; + + const url = $(this).data('url'); + const form = new FormData(); + checkedList.forEach((id) => form.append('bugIdList[]', id)); + + if($(this).hasClass('ajax-btn')) + { + $.ajaxSubmit({url, data:form}); + } + else + { + postAndLoadPage(url, form); + } +}); diff --git a/module/project/ui/bug.html.php b/module/project/ui/bug.html.php index c5650638ca..ef55771c90 100644 --- a/module/project/ui/bug.html.php +++ b/module/project/ui/bug.html.php @@ -67,20 +67,14 @@ if(!$canBatchAssignTo) $config->bug->dtable->fieldList['id']['type'] = 'id'; foreach($bugs as $bug) $bug->canBeChanged = common::canBeChanged('bug', $bug); -$assignedToItems = array(); -foreach ($memberPairs as $key => $value) $assignedToItems[] = array('text' => $value, 'class' => 'batch-btn ajax-btn', 'data-url' => helper::createLink('bug', 'batchAssignTo', "assignedTo=$key&projectID={$project->id}&type=project")); +$footToolbar = array(); +if($canBatchAssignTo) +{ + $assignedToItems = array(); + foreach ($memberPairs as $key => $value) $assignedToItems[] = array('text' => $value, 'innerClass' => 'batch-btn ajax-btn', 'data-url' => createLink('bug', 'batchAssignTo', "assignedTo=$key&projectID={$project->id}&type=project")); -menu -( - set::id('navAssignedTo'), - set::className('dropdown-menu'), - set::items($assignedToItems) -); - -$footToolbar = $canBatchAssignTo ? array('items' => array -( - array('caret' => 'up', 'text' => $lang->bug->assignedTo, 'btnType' => 'secondary', 'url' => '#navAssignedTo','data-toggle' => 'dropdown', 'data-placement' => 'top'), -)) : null; + $footToolbar['items'][] = array('caret' => 'up', 'text' => $lang->bug->assignedTo, 'className' => 'btn btn-caret size-sm secondary', 'items' => $assignedToItems, 'type' => 'dropdown', 'data-placement' => 'top'); +} $cols = $this->loadModel('datatable')->getSetting('project'); $bugs = initTableData($bugs, $cols, $this->bug); @@ -91,7 +85,6 @@ dtable set::data(array_values($bugs)), set::userMap($users), set::customCols(true), - set::footToolbar($footToolbar), set::checkable($canBatchAssignTo), set::canRowCheckable(jsRaw('function(rowID){return this.getRowInfo(rowID).data.canBeChanged;}')), set::orderBy($orderBy),