Skip to content

Commit 13f6fc4

Browse files
authored
Merge pull request #5719 from Laravel-Backpack/separate-responsive-controls-from-first-column
Separate responsive controls from first column contents
2 parents dee2eec + 5160036 commit 13f6fc4

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

src/app/Library/CrudPanel/Traits/Search.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ public function getRowViews($entry, $rowNumber = false)
288288
$row_items[0] = $details_row_button.$row_items[0];
289289
}
290290

291+
if ($this->getResponsiveTable()) {
292+
$responsiveTableTrigger = '<div class="dtr-control d-none cursor-pointer"></div>';
293+
$row_items[0] = $responsiveTableTrigger.$row_items[0];
294+
}
295+
291296
return $row_items;
292297
}
293298

src/resources/assets/css/common.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,22 @@ form .select2.select2-container {
9494
margin-top: 0 !important;
9595
}
9696

97-
#crudTable_wrapper #crudTable.dtr-inline.collapsed > tbody > tr > .dtr-control:before,
98-
#crudTable_wrapper table.dataTable.dtr-inline.collapsed > tbody > tr > .dtr-control:before {
97+
#crudTable_wrapper #crudTable .crud_bulk_actions_line_checkbox {
98+
vertical-align: text-top;
99+
}
100+
101+
#crudTable_wrapper #crudTable.dtr-none > tbody > tr > td > div.dtr-control:before,
102+
#crudTable_wrapper table.dataTable.dtr-none > tbody > tr > td > div.dtr-control:before {
99103
background-color: transparent;
100104
color: #636161;
101105
font-family: "Line Awesome Free";
102106
font-weight: 900;
103-
width: 16px;
107+
width: 1rem;
104108
content: "\f142";
105109
font-size: 21px;
106110
box-shadow: none;
107111
border: none;
108-
display: inline;
112+
display: inline-block;
109113
position: relative;
110114
top: 0;
111115
left: 0;

src/resources/views/crud/inc/datatables_logic.blade.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ functionsToRunOnDataTablesDrawEvent: [],
155155
// return data[0];
156156
return '';
157157
}
158-
} ),
158+
}),
159+
type: 'none',
160+
target: '.dtr-control',
159161
renderer: function ( api, rowIdx, columns ) {
160162
161163
var data = $.map( columns, function ( col, i ) {
@@ -377,8 +379,11 @@ functionsToRunOnDataTablesDrawEvent: [],
377379
// the table should have the has-hidden-columns class
378380
crud.table.on( 'responsive-resize', function ( e, datatable, columns ) {
379381
if (crud.table.responsive.hasHidden()) {
380-
$("#crudTable").removeClass('has-hidden-columns').addClass('has-hidden-columns');
382+
$('.dtr-control').removeClass('d-none');
383+
$('.dtr-control').addClass('d-inline');
384+
$("#crudTable").removeClass('has-hidden-columns').addClass('has-hidden-columns');
381385
} else {
386+
$('.dtr-control').removeClass('d-none').removeClass('d-inline').addClass('d-none');
382387
$("#crudTable").removeClass('has-hidden-columns');
383388
}
384389
} );

src/resources/views/crud/inc/details_row_logic.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function registerDetailsRowButtonAction() {
1313
1414
// Add event listener for opening and closing details
1515
$('#crudTable tbody td .details-control').on('click', function (e) {
16-
e.stopPropagation();
16+
e.stopPropagation();
1717
1818
var tr = $(this).closest('tr');
1919
var btn = $(this).find('.details-row-button');

src/resources/views/crud/inc/filters_navbar.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ function updateDatatablesOnFilterChange(filterName, filterValue, update_url = fa
8585
*
8686
* FROM: https://stackoverflow.com/questions/27787768/debounce-function-in-jquery
8787
*/
88-
function callFunctionOnce(func, within = 300, timerId = null) {
88+
if(typeof callFunctionOnce !== 'function') {
89+
function callFunctionOnce(func, within = 300, timerId = null) {
8990
window.callOnceTimers = window.callOnceTimers || {};
9091
timerId = timerId || func;
9192
if (window.callOnceTimers[timerId]) {
9293
clearTimeout(window.callOnceTimers[timerId]);
9394
}
9495
window.callOnceTimers[timerId] = setTimeout(func, within);
96+
}
9597
}
9698
9799
function refreshDatatablesOnFilterChange(url)

src/resources/views/crud/list.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class="{{ backpack_theme_config('classes.table') ?? 'table table-striped table-h
9898
>
9999
{{-- Bulk checkbox --}}
100100
@if($loop->first && $crud->getOperationSetting('bulkActions'))
101-
{!! View::make('crud::columns.inc.bulk_actions_checkbox')->render() !!}
101+
{!! View::make('crud::columns.inc.bulk_actions_checkbox')->render() !!}
102102
@endif
103103
{!! $column['label'] !!}
104104
</th>
@@ -122,7 +122,7 @@ class="{{ backpack_theme_config('classes.table') ?? 'table table-striped table-h
122122
<th>
123123
{{-- Bulk checkbox --}}
124124
@if($loop->first && $crud->getOperationSetting('bulkActions'))
125-
{!! View::make('crud::columns.inc.bulk_actions_checkbox')->render() !!}
125+
{!! View::make('crud::columns.inc.bulk_actions_checkbox')->render() !!}
126126
@endif
127127
{!! $column['label'] !!}
128128
</th>

0 commit comments

Comments
 (0)