* Refactor batch assigned to button.

This commit is contained in:
tianshujie
2023-10-24 10:11:53 +08:00
parent 8bc2e9d8cc
commit c85dcef772
2 changed files with 26 additions and 14 deletions
+19
View File
@@ -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);
}
});
+7 -14
View File
@@ -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),