File tree Expand file tree Collapse file tree 6 files changed +45
-26
lines changed
app/Library/CrudPanel/Traits
public/packages/backpack/crud/css Expand file tree Collapse file tree 6 files changed +45
-26
lines changed Original file line number Diff line number Diff line change @@ -366,6 +366,7 @@ public function makeSureColumnHasNeededAttributes($column)
366366 $ column = $ this ->makeSureColumnHasLabel ($ column );
367367 $ column = $ this ->makeSureColumnHasType ($ column );
368368 $ column = $ this ->makeSureColumnHasKey ($ column );
369+ $ column = $ this ->makeSureColumnHasPriority ($ column );
369370 $ column = $ this ->makeSureColumnHasModel ($ column );
370371
371372 // check if the column exists in the database (as a db column)
@@ -387,6 +388,21 @@ public function makeSureColumnHasNeededAttributes($column)
387388 return $ column ;
388389 }
389390
391+ /**
392+ * Count the number of columns added so far.
393+ *
394+ * It will not take into account the action
395+ * columns (columns with buttons, checkbox).
396+ *
397+ * @return integer
398+ */
399+ public function countColumnsWithoutActions ()
400+ {
401+ return collect ($ this ->columns ())->filter (function ($ column , $ key ) {
402+ return !isset ($ column ['hasActions ' ]) || $ column ['hasActions ' ] == false ;
403+ })->count ();
404+ }
405+
390406 /**
391407 * Create and return a CrudColumn object for that column name.
392408 *
Original file line number Diff line number Diff line change @@ -18,15 +18,23 @@ protected function addColumnToOperationSettings($column)
1818 $ allColumns = Arr::add ($ allColumns , $ column ['key ' ], $ column );
1919
2020 $ this ->setOperationSetting ('columns ' , $ allColumns );
21+ }
2122
22- // make sure the column has a priority in terms of visibility
23- // if no priority has been defined, use the order in the array plus one
24- if (! array_key_exists ('priority ' , $ column )) {
25- $ position_in_columns_array = (int ) array_search ($ column ['key ' ], array_keys ($ this ->columns ()));
26- $ allColumns [$ column ['key ' ]]['priority ' ] = $ position_in_columns_array + 1 ;
27- }
2823
29- $ this ->setOperationSetting ('columns ' , $ allColumns );
24+ /**
25+ * If a column priority has not been defined, provide a default one.
26+ *
27+ * @param array $column Column definition array.
28+ * @return array Proper array defining the column.
29+ */
30+ protected function makeSureColumnHasPriority ($ column )
31+ {
32+ $ columns_count = $ this ->countColumnsWithoutActions ();
33+ $ assumed_priority = $ columns_count ? $ columns_count : 0 ;
34+
35+ $ column ['priority ' ] = $ column ['priority ' ] ?? $ assumed_priority ;
36+
37+ return $ column ;
3038 }
3139
3240 /**
Original file line number Diff line number Diff line change @@ -143,26 +143,28 @@ public function enableBulkActions()
143143 'type ' => 'checkbox ' ,
144144 'name ' => 'bulk_actions ' ,
145145 'label ' => ' <input type="checkbox" class="crud_bulk_actions_main_checkbox" style="width: 16px; height: 16px;" /> ' ,
146- 'priority ' => 1 ,
146+ 'priority ' => $ this -> getActionsColumnPriority () ,
147147 'searchLogic ' => false ,
148148 'orderable ' => false ,
149149 'visibleInTable ' => true ,
150150 'visibleInModal ' => false ,
151151 'visibleInExport ' => false ,
152152 'visibleInShow ' => false ,
153+ 'hasActions ' => true ,
153154 ])->makeFirstColumn ();
154155
155156 $ this ->addColumn ([
156157 'type ' => 'custom_html ' ,
157158 'name ' => 'blank_first_column ' ,
158159 'label ' => ' ' ,
159- 'priority ' => 1 ,
160+ 'priority ' => $ this -> getActionsColumnPriority () ,
160161 'searchLogic ' => false ,
161162 'orderable ' => false ,
162163 'visibleInTabel ' => true ,
163164 'visibleInModal ' => false ,
164165 'visibleInExport ' => false ,
165166 'visibleInShow ' => false ,
167+ 'hasActions ' => true ,
166168 ])->makeFirstColumn ();
167169 }
168170
Original file line number Diff line number Diff line change 5454 }
5555
5656 /* DataTables Loading State Visual Improvements */
57-
57+ table .dataTable .dtr-inline .collapsed > tbody > tr [role = "row" ]> td .dtr-control : before ,
58+ table .dataTable .dtr-inline .collapsed > tbody > tr [role = "row" ]> th .dtr-control : before ,
5859 # crudTable .dataTable .dtr-inline .collapsed > tbody > tr [role = "row" ]> td : first-child : before ,
5960 # crudTable .dataTable .dtr-inline .collapsed > tbody > tr [role = "row" ]> th : first-child : before {
6061 background-color : transparent;
Original file line number Diff line number Diff line change @@ -111,7 +111,8 @@ function moveExportButtonsToTopRight() {
111111 }
112112 })
113113 $ (" .dt-buttons" ).appendTo ($ (' #datatable_button_stack' ));
114- $ (' .dt-buttons' ).addClass (' d-sm-inline-block' )
114+ $ (' .dt-buttons' ).addClass (' d-xs-block' )
115+ .addClass (' d-sm-inline-block' )
115116 .addClass (' d-md-inline-block' )
116117 .addClass (' d-lg-inline-block' );
117118 }
Original file line number Diff line number Diff line change 7474 data-visible-in-modal =" false"
7575 data-visible-in-export =" true"
7676 data-force-export =" true"
77-
7877 @else
79-
8078 data-visible-in-table =" {{ var_export ($column [' visibleInTable' ] ?? false )} }"
8179 data-visible =" {{ var_export ($column [' visibleInTable' ] ?? true )} }"
8280 data-can-be-visible-in-table =" true"
8381 data-visible-in-modal =" {{ var_export ($column [' visibleInModal' ] ?? true )} }"
84- @if (isset ($column [' visibleInExport' ]) )
85- @if ($column [' visibleInExport' ] === false )
86- data-visible-in-export =" false"
87- data-force-export =" false"
88- @else
89- data-visible-in-export =" true"
90- data-force-export =" true"
91- @endif
92- @else
93- data-visible-in-export =" true"
94- data-force-export =" false"
95- @endif
82+ data-visible-in-export =" {{ var_export ($column [' visibleInExport' ] ?? true )} }"
83+ data-force-export =" {{ var_export ($column [' visibleInExport' ] ?? true )} }"
9684 @endif
9785 >
9886 {!! $column [' label' ] ! !}
9987 </th >
10088 @endforeach
10189
10290 @if ( $crud -> buttons ()-> where (' stack' , ' line' )-> count () )
103- <th data-orderable =" false" data-priority =" {{ $crud -> getActionsColumnPriority () } }" data-visible-in-export =" false" >{{ trans (' backpack::crud.actions' ) } } </th >
91+ <th data-orderable =" false"
92+ data-priority =" {{ $crud -> getActionsColumnPriority () } }"
93+ data-visible-in-export =" false"
94+ >{{ trans (' backpack::crud.actions' ) } } </th >
10495 @endif
10596 </tr >
10697 </thead >
You can’t perform that action at this time.
0 commit comments