Skip to content

Commit 8d6e6aa

Browse files
authored
Merge pull request #1024 from rappasoft/develop
v2.10.0
2 parents 7281989 + e34df25 commit 8d6e6aa

File tree

21 files changed

+356
-21
lines changed

21 files changed

+356
-21
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
## [2.10.0] - 2023-01-16
8+
9+
### Added
10+
11+
- Added support for MorphOne relationships - https://github.com/rappasoft/laravel-livewire-tables/pull/844
12+
- Added MultiSelectDropdownFilter - https://github.com/rappasoft/laravel-livewire-tables/pull/1011
13+
- FilterSlideDown - Ability to set Default to Open or Closed - https://github.com/rappasoft/laravel-livewire-tables/pull/1017
14+
15+
### Changed
16+
17+
- Updated EN translations - https://github.com/rappasoft/laravel-livewire-tables/pull/999
18+
- Updated ES translations - https://github.com/rappasoft/laravel-livewire-tables/pull/1000
19+
- Bulk Actions Simple Pagination fix & typo in toolbar.blade.php - https://github.com/rappasoft/laravel-livewire-tables/pull/1015
20+
721
## [2.9.0] - 2022-12-21
822

923
### Added
@@ -705,7 +719,9 @@ Ground Up Rebuild
705719

706720
- Initial release
707721

708-
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.8.0...development
722+
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.10.0...development
723+
[2.10.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.9.0...v2.10.0
724+
[2.9.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.8.0...v2.9.0
709725
[2.8.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.7.0...v2.8.0
710726
[2.7.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.6.0...v2.7.0
711727
[2.6.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.5.0...v2.6.0

docs/columns/relationships.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Relationships
33
weight: 2
44
---
55

6-
Out of the box the columns support `hasOne` and `belongsTo` relationships for display, sorting, and searching. The component will automatically join the necessary tables.
6+
Out of the box the columns support `hasOne`, `belongsTo`, and `MorphOne` relationships for display, sorting, and searching. The component will automatically join the necessary tables.
77

88
To call these relationships, just use the relationship dot-notation string as the field name:
99

docs/filters/applying-filters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ You may wish to apply default filters i.e. current month on accessing the view i
4747

4848
```php
4949
public function mount() {
50-
$this->setFilter('created_after', date('Y-m-d', strtotime('now -1 month'));
50+
$this->setFilter('created_after', date('Y-m-d', strtotime('now -1 month')));
5151
}
5252
```
5353

docs/filters/available-methods.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,31 @@ public function configure(): void
158158
}
159159
```
160160

161+
### setFilterSlideDownDefaultStatusEnabled
162+
163+
Set the filter slide down to visible by default
164+
165+
```php
166+
public function configure(): void
167+
{
168+
// Shorthand for $this->setFilterSlideDownDefaultStatus(true)
169+
$this->setFilterSlideDownDefaultStatusEnabled();
170+
}
171+
```
172+
173+
### setFilterSlideDownDefaultStatusDisabled
174+
175+
Set the filter slide down to collapsed by default
176+
177+
```php
178+
public function configure(): void
179+
{
180+
// Shorthand for $this->setFilterSlideDownDefaultStatus(false)
181+
$this->setFilterSlideDownDefaultStatusDisabled();
182+
}
183+
```
184+
185+
161186
----
162187

163188
## Filter Methods

docs/filters/creating-filters.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ public function filters(): array
6161
25 => 'Type Y',
6262
26 => 'Type Z',
6363
],
64-
]),
64+
])
65+
->setFirstOption('All Tags'),
6566
];
6667
}
6768
```
69+
To set a defualt "All" option at the start of the dropdown, you can do so by utilising the
70+
```
71+
->SetFirstOption('NAME')
72+
```
6873

6974
## Multi-select Filters
7075

@@ -89,6 +94,30 @@ public function filters(): array
8994
}
9095
```
9196

97+
## Multi-select dropdown Filters
98+
99+
Multi-select dropdown filters are a simple dropdown list. The user can select multiple options from the list. There is also an 'All' option that will select all values
100+
101+
```php
102+
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
103+
104+
public function filters(): array
105+
{
106+
return [
107+
SelectFilter::make('Tags')
108+
->options(
109+
Tag::query()
110+
->orderBy('name')
111+
->get()
112+
->keyBy('id')
113+
->map(fn($tag) => $tag->name)
114+
->toArray()
115+
)
116+
->setFirstOption('All Tags'),
117+
];
118+
}
119+
```
120+
92121
## Date Filters
93122

94123
Date filters are HTML date elements.

resources/lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"All": "All",
3+
"All Columns": "All Columns",
34
"Applied Filters": "Applied Filters",
45
"Applied Sorting": "Applied Sorting",
56
"Bulk Actions": "Bulk Actions",

resources/lang/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"All": "Todo",
3+
"All Columns": "Todas las columnas",
34
"Applied Filters": "Filtros Aplicados",
45
"Applied Sorting": "Ordenamineto Aplicado",
56
"Bulk Actions": "Acciones Masivas",

resources/views/components/table/tr/bulk-actions.blade.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
$colspan = $component->getColspanCount();
99
$selected = $component->getSelectedCount();
1010
$selectAll = $component->selectAllIsEnabled();
11+
$simplePagination = ($component->paginationMethod == "simple") ? true : false;
1112
@endphp
1213

1314
@if ($theme === 'tailwind')
@@ -20,7 +21,7 @@ class="bg-indigo-50 dark:bg-gray-900 dark:text-white"
2021
<div wire:key="all-selected-{{ $table }}">
2122
<span>
2223
@lang('You are currently selecting all')
23-
<strong>{{ number_format($rows->total()) }}</strong>
24+
@if(!$simplePagination) <strong>{{ number_format($rows->total()) }}</strong> @endif
2425
@lang('rows').
2526
</span>
2627

@@ -39,7 +40,7 @@ class="ml-1 text-blue-600 underline text-gray-700 text-sm leading-5 font-medium
3940
@lang('You have selected')
4041
<strong>{{ $selected }}</strong>
4142
@lang('rows, do you want to select all')
42-
<strong>{{ number_format($rows->total()) }}</strong>?
43+
@if(!$simplePagination) <strong>{{ number_format($rows->total()) }}</strong> @endif
4344
</span>
4445

4546
<button
@@ -72,7 +73,7 @@ class="ml-1 text-blue-600 underline text-gray-700 text-sm leading-5 font-medium
7273
<div wire:key="all-selected-{{ $table }}">
7374
<span>
7475
@lang('You are currently selecting all')
75-
<strong>{{ number_format($rows->total()) }}</strong>
76+
@if(!$simplePagination) <strong>{{ number_format($rows->total()) }}</strong> @endif
7677
@lang('rows').
7778
</span>
7879

@@ -91,7 +92,7 @@ class="btn btn-primary btn-sm"
9192
@lang('You have selected')
9293
<strong>{{ $selected }}</strong>
9394
@lang('rows, do you want to select all')
94-
<strong>{{ number_format($rows->total()) }}</strong>?
95+
@if(!$simplePagination) <strong>{{ number_format($rows->total()) }}</strong> @endif
9596
</span>
9697

9798
<button
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@php
2+
$theme = $component->getTheme();
3+
@endphp
4+
5+
@if ($theme === 'tailwind')
6+
<div class="rounded-md shadow-sm">
7+
<select multiple
8+
wire:model.stop="{{ $component->getTableName() }}.filters.{{ $filter->getKey() }}"
9+
wire:key="{{ $component->getTableName() }}-filter-{{ $filter->getKey() }}"
10+
id="{{ $component->getTableName() }}-filter-{{ $filter->getKey() }}"
11+
class="block w-full transition duration-150 ease-in-out border-gray-300 rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:text-white dark:border-gray-600"
12+
>
13+
@if ($filter->getFirstOption() != "")
14+
<option @if($filter->isEmpty($this)) selected @endif value="all">{{ $filter->getFirstOption()}}</option>
15+
@endif
16+
@foreach($filter->getOptions() as $key => $value)
17+
@if (is_iterable($value))
18+
<optgroup label="{{ $key }}">
19+
@foreach ($value as $optionKey => $optionValue)
20+
<option value="{{ $optionKey }}">{{ $optionValue }}</option>
21+
@endforeach
22+
</optgroup>
23+
@else
24+
<option value="{{ $key }}">{{ $value }}</option>
25+
@endif
26+
@endforeach
27+
</select>
28+
</div>
29+
@elseif ($theme === 'bootstrap-4' || $theme === 'bootstrap-5')
30+
<select multiple
31+
wire:model.stop="{{ $component->getTableName() }}.filters.{{ $filter->getKey() }}"
32+
wire:key="{{ $component->getTableName() }}-filter-{{ $filter->getKey() }}"
33+
id="{{ $component->getTableName() }}-filter-{{ $filter->getKey() }}"
34+
class="{{ $theme === 'bootstrap-4' ? 'form-control' : 'form-select' }}"
35+
>
36+
@if ($filter->getFirstOption() != "")
37+
<option @if($filter->isEmpty($this)) selected @endif value="all">{{ $filter->getFirstOption()}}</option>
38+
@endif
39+
@foreach($filter->getOptions() as $key => $value)
40+
@if (is_iterable($value))
41+
<optgroup label="{{ $key }}">
42+
@foreach ($value as $optionKey => $optionValue)
43+
<option value="{{ $optionKey }}">{{ $optionValue }}</option>
44+
@endforeach
45+
</optgroup>
46+
@else
47+
<option value="{{ $key }}">{{ $value }}</option>
48+
@endif
49+
@endforeach
50+
</select>
51+
@endif

resources/views/components/tools/toolbar.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ class="form-select"
843843
@endif
844844

845845
@if ($component->hasConfigurableAreaFor('toolbar-right-end'))
846-
@include($component->getConfigurableAreaFor('toolbar-right-end'), $component->getParametersForConfigurableArea('toolbar-righ-end'))
846+
@include($component->getConfigurableAreaFor('toolbar-right-end'), $component->getParametersForConfigurableArea('toolbar-right-end'))
847847
@endif
848848
</div>
849849
</div>

0 commit comments

Comments
 (0)