File tree Expand file tree Collapse file tree 13 files changed +75
-67
lines changed
Expand file tree Collapse file tree 13 files changed +75
-67
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,14 @@ Name|Description|Type|Value
9999model|Model instance for this card|||
100100actions|Actions defined in this view class|Array
101101hasDefaultAction|Checks if the Grid View has defined a ` onCardClick ` method|Boolean|true,false
102+ selected|Defines if the item was selected when the grid view has bulk actions|Boolean|true,false
102103
103- With all this data you can build your own card component as you need, remember to include the ` actions ` component.
104+ With all this data you can build your own card component as you need, remember to include an ` actions ` component.
104105
105106``` html
106107<x-lv-actions :actions =" $actions" :model =" $model" />
108+ <!-- Or -->
109+ <x-lv-actions .drop-down :actions =" $actions" :model =" $model" />
107110```
108111
109112
Original file line number Diff line number Diff line change 1+ @props ([' actions' => [], ' model' => null ] )
2+
3+ <x-lv-drop-down >
4+ <x-slot name =" trigger" >
5+ <x-lv-icon-button icon =" more-horizontal" size =" sm" />
6+ </x-slot >
7+ <x-lv-actions .icon-and-title :actions =" $actions" :model =" $model" />
8+ </x-lv-drop-down >
Original file line number Diff line number Diff line change 1- @props ([' actions' , ' model' ] )
1+ @props ([' actions' => [] , ' model' => null ] )
22
33<div >
44 @if (count ($actions ) )
55 {{-- Mobile actions dropdown --}}
66 <div class =" lg:hidden text-right relative" >
7- <x-lv-drop-down >
8- <x-slot name =" trigger" >
9- <x-lv-icon-button icon =" more-horizontal" size =" sm" />
10- </x-slot >
11-
12- <x-lv-actions .icon-and-title :actions =" $actions" :model =" $model" />
13- </x-lv-drop-down >
7+ <x-lv-actions .drop-down :actions =" $actions" :model =" $model" />
148 </div >
159
1610 {{-- Desktop action buttons --}}
Original file line number Diff line number Diff line change 1+ <input type =" checkbox" {{ $attributes -> merge ([' class' => ' w-4 h-4 rounded' ]) } } >
Original file line number Diff line number Diff line change 1515 @if ($this -> hasBulkActions )
1616 <th class =" px-3 pr-0" >
1717 <span class =" flex items-center justify-center" >
18- <input type = " checkbox" wire:model =" allSelected" >
18+ <x-lv- checkbox wire:model =" allSelected" / >
1919 </span >
2020 </th >
2121 @endif
5555 @if ($this -> hasBulkActions )
5656 <td class =" pr-0 px-3" >
5757 <span class =" flex items-center justify-center" >
58- <input wire:model = " selected " type = " checkbox" value =" {{ $item -> getKey () } }" >
58+ <x-lv- checkbox value =" {{ $item -> getKey () } }" wire:model = " selected " / >
5959 </span >
6060 </td >
6161 @endif
Original file line number Diff line number Diff line change 11@props ([
2- ' image' ,
3- ' title' ,
4- ' subtitle' ,
5- ' description' ,
6- ' withBackground' ,
2+ ' image' => ' ' ,
3+ ' title' => ' ' ,
4+ ' subtitle' => ' ' ,
5+ ' description' => ' ' ,
6+ ' withBackground' => false ,
77 ' model' ,
8- ' actions' ,
9- ' hasDefaultAction'
8+ ' actions' => [],
9+ ' hasDefaultAction' => false ,
10+ ' selected' => false
1011] )
1112
1213<div class =" {{ $withBackground ? ' rounded-md shadow-md' : ' ' } }" >
1314 @if ($hasDefaultAction )
1415 <a href =" #!" wire:click.prevent =" onCardClick({{ $model -> id } } )" >
15- <img src =" {{ $image } }" alt =" {{ $image } }" class =" hover:shadow-lg cursor-pointer rounded-md h-48 w-full object-cover {{ $withBackground ? ' rounded-b-none' : ' ' } }" >
16+ <img src =" {{ $image } }" alt =" {{ $image } }" class =" hover:shadow-lg cursor-pointer rounded-md h-48 w-full object-cover {{ $withBackground ? ' rounded-b-none' : ' ' } } {{ $selected ? " border-2 border-blue-500 " : " " } } " >
1617 </a >
1718 @else
18- <img src =" {{ $image } }" alt =" {{ $image } }" class =" rounded-md h-48 w-full object-cover {{ $withBackground ? ' rounded-b-none' : ' ' } }" >
19+ <img src =" {{ $image } }" alt =" {{ $image } }" class =" rounded-md h-48 w-full object-cover {{ $withBackground ? ' rounded-b-none' : ' ' } } {{ $selected ? " border-2 border-blue-500 " : " " } } " >
1920 @endif
2021
2122 <div class =" pt-4 {{ $withBackground ? ' bg-white rounded-b-md p-4' : ' ' } }" >
3839 </div >
3940
4041 <div class =" flex justify-end items-center" >
41- <x-lv-drop-down >
42- <x-slot name =" trigger" >
43- <x-lv-icon-button icon =" more-horizontal" size =" sm" />
44- </x-slot >
45- <x-lv-actions .icon-and-title :actions =" $actions" :model =" $model" />
46- </x-lv-drop-down >
42+ <x-lv-actions .drop-down :actions =" $actions" :model =" $model" />
4743 </div >
4844 </div >
4945
Original file line number Diff line number Diff line change 1515
1616 <div class =" grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-{{ $maxCols } } gap-8 md:gap-8" >
1717 @foreach ($items as $item )
18- <x-lv-dynamic-component
18+ <div class =" relative" >
19+ @if ($this -> hasBulkActions )
20+ <div class =" absolute top-0 lef-0 p-2" >
21+ <x-lv-checkbox wire:model =" selected" value =" {{ $item -> getKey () } }" />
22+ </div >
23+ @endif
24+ <x-lv-dynamic-component
1925 :view =" $cardComponent"
2026 :data =" array_merge($this->card($item), [
2127 'withBackground' => $withBackground,
2228 'model' => $item,
2329 'actions' => $actionsByRow,
24- 'hasDefaultAction' => $this->hasDefaultAction])"
30+ 'hasDefaultAction' => $this->hasDefaultAction,
31+ 'selected' => in_array($item->getKey(), $selected)
32+ ])"
2533 />
34+ </div >
2635 @endforeach
2736 </div >
2837
Original file line number Diff line number Diff line change 2727
2828 {{-- Empty data message --}}
2929 <div class =" flex justify-center items-center p-4" >
30- <h1 > There are no items in this table</ h1 >
30+ <h3 > {{ __ ( ' There are no items in this table' ) } } </ h3 >
3131 </div >
3232
3333 @endif
Original file line number Diff line number Diff line change @@ -20,15 +20,17 @@ public function components()
2020 'buttons.button ' => 'button ' ,
2121 'dropdown.drop-down ' => 'drop-down ' ,
2222 'dropdown.header ' => 'drop-down.header ' ,
23- 'actions.actions ' => 'actions ' ,
23+ 'actions.responsive ' => 'actions ' ,
24+ 'actions.drop-down ' => 'actions.drop-down ' ,
2425 'actions.icon-and-title ' => 'actions.icon-and-title ' ,
2526 'actions.icon ' => 'actions.icon ' ,
2627 'attributes-list ' => 'attributes-list ' ,
2728 'alert ' => 'alert ' ,
2829 'alerts-handler ' => 'alerts-handler ' ,
2930 'form.input-group ' => 'form.input-group ' ,
3031 'icon ' => 'icon ' ,
31- 'modal ' => 'modal '
32+ 'modal ' => 'modal ' ,
33+ 'form.checkbox ' => 'checkbox '
3234 ];
3335 }
3436
Original file line number Diff line number Diff line change 22
33namespace LaravelViews \Views ;
44
5- use LaravelViews \Actions \WithActions ;
65use LaravelViews \Data \Contracts \Filterable ;
76use LaravelViews \Data \Contracts \Searchable ;
87use LaravelViews \Data \Contracts \Sortable ;
98use LaravelViews \Data \QueryStringData ;
9+ use LaravelViews \Views \Traits \WithActions ;
1010use Livewire \WithPagination ;
1111
1212abstract class DataView extends View
@@ -131,14 +131,6 @@ public function updatedAllSelected($value)
131131 }) : [];
132132 }
133133
134- /**
135- * Computed properties
136- */
137- public function getHasBulkActionsProperty ()
138- {
139- return method_exists ($ this , 'bulkActions ' ) && count ($ this ->bulkActions ) > 0 ;
140- }
141-
142134 /**
143135 * Returns the items from the database regarding to the filters selected by the user
144136 * applies the search query, the filters used and the total of items found
You can’t perform that action at this time.
0 commit comments