Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/config/backpack/operations/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
// Nest action buttons within a dropdown in actions column
'lineButtonsAsDropdown' => false,

// What is the minimum threshold of action buttons for nesting into a dropdown
'lineButtonsAsDropdownThreshold' => 1,

// Show a "Reset" button next to the List operation subheading
// (Showing 1 to 25 of 9999 entries. Reset)
// that allows the user to erase local storage for that datatable,
Expand Down
6 changes: 5 additions & 1 deletion src/resources/views/crud/inc/datatables_logic.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,20 @@ function formatActionColumnAsDropdown() {
const actionColumnIndex = $('#crudTable').find('th[data-action-column=true]').index();
if (actionColumnIndex === -1) return;

const minimumThreshold = $('#crudTable').data('line-buttons-as-dropdown-threshold');

$('#crudTable tbody tr').each(function (i, tr) {
const actionCell = $(tr).find('td').eq(actionColumnIndex);
const actionButtons = actionCell.find('a.btn.btn-link');
if(actionCell.find('.actions-buttons-column').length) return;
if(actionButtons.length < minimumThreshold) return;

// Wrap the cell with the component needed for the dropdown
actionCell.wrapInner('<div class="nav-item dropdown"></div>');
actionCell.wrapInner('<div class="dropdown-menu dropdown-menu-left"></div>');

// Prepare buttons as dropdown items
actionCell.find('a.btn.btn-link').each((index, action) => {
actionButtons.each((index, action) => {
$(action).addClass('dropdown-item').removeClass('btn btn-sm btn-link');
$(action).find('i').addClass('me-2 text-primary');
});
Expand Down
1 change: 1 addition & 0 deletions src/resources/views/crud/list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class="{{ backpack_theme_config('classes.table') ?? 'table table-striped table-h
data-has-details-row="{{ (int) $crud->getOperationSetting('detailsRow') }}"
data-has-bulk-actions="{{ (int) $crud->getOperationSetting('bulkActions') }}"
data-has-line-buttons-as-dropdown="{{ (int) $crud->getOperationSetting('lineButtonsAsDropdown') }}"
data-line-buttons-as-dropdown-threshold="{{ (int) $crud->getOperationSetting('lineButtonsAsDropdownThreshold') }}"
cellspacing="0">
<thead>
<tr>
Expand Down