Skip to content

Commit 1b3fe44

Browse files
authored
Merge pull request #215 from rappasoft/develop
Develop
2 parents eea59ca + 58007d7 commit 1b3fe44

19 files changed

+235
-56
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7+
## [1.0.4] - 2021-04-18
8+
9+
### Added
10+
11+
- `$searchFilterDebounce`, `$searchFilterDefer`, `$searchFilterLazy`, for defining the search input data binding property. https://github.com/rappasoft/laravel-livewire-tables/pull/211
12+
- Remove ability to need to define filters if not defining defaults. https://github.com/rappasoft/laravel-livewire-tables/pull/213
13+
14+
### Changed
15+
16+
- Rearrange wire:keys
17+
718
## [1.0.3] - 2021-04-18
819

920
### Added
@@ -181,7 +192,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
181192

182193
- Initial release
183194

184-
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.3...development
195+
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.4...development
196+
[1.0.4]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.3...v1.0.4
185197
[1.0.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.2...v1.0.3
186198
[1.0.2]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.1...v1.0.2
187199
[1.0.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.0...v1.0.1

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -234,22 +234,7 @@ You will see how to get more out of this base query using filters and search bel
234234

235235
Creating filters is not required, and the filters box will be hidden if none are defined.
236236

237-
Creating filters requires a few easy steps.
238-
239-
#### Adding to the filters array
240-
241-
You must first define a filter key in the **$filters** array, this tells the component to save the filter status in the query string for page reloads, as well as let you set a default.
242-
243-
```php
244-
public array $filters = [
245-
'type' => null,
246-
'active' => null,
247-
];
248-
```
249-
250-
#### Defining the filter UI
251-
252-
After you define the filters for the component, you must specify their options using the **filters()** method.
237+
#### Defining the filters
253238

254239
Right now the only supported filter type is a select dropdown.
255240

@@ -273,10 +258,21 @@ public function filters(): array
273258
}
274259
```
275260

276-
You specify your filters array using the **key** as the filter name supplied in the **$filters** array on the component.
277-
278261
The keys of the options you supply will be validated on select to make sure they match one of the options on the backend, otherwise it will be changed to _null_ for safety.
279262

263+
#### Setting filter defaults
264+
265+
When you define the filters, a class property of $filters is generated for you.
266+
267+
```php
268+
public array $filters = [
269+
'type' => null,
270+
'active' => null,
271+
];
272+
```
273+
274+
You may overwrite this property to set defaults to your filters if you would like.
275+
280276
#### Alternate: Defining a filter view
281277

282278
If you want full control over your filters, you can omit the **filters()** method and instead add a **filtersView()** method that return the string view name, which will be included in the master component on render. This is useful when you have different types of filters than the package offers:
@@ -386,15 +382,18 @@ In the component you have access to `$this->selectedRowsQuery` which is a **Buil
386382

387383
There are some class level properties you can set:
388384

389-
| Property | Default | Usage |
390-
| -------- | ------- | ----- |
391-
| $showSearch | true | Show the search box |
392-
| $showPerPage | true | Show the per page selector |
393-
| $showPagination | true | Show the pagination |
394-
| $showSorting | true | Show the sorting pills |
395-
| $showFilters | true | Show the filter pills |
396-
| $refresh | false | Whether or not to refresh the table at a certain interval. false = off, int = ms, string = functionCall |
397-
| $offlineIndicator | true | Shows a red banner when there is no internet connection. |
385+
| Property | Default | Options | Usage |
386+
| -------- | ------- | ------- | ----- |
387+
| $showSearch | true | bool | Show the search box |
388+
| $showPerPage | true | bool | Show the per page selector |
389+
| $showPagination | true | bool | Show the pagination |
390+
| $showSorting | true | bool | Show the sorting pills |
391+
| $showFilters | true | bool | Show the filter pills |
392+
| $searchFilterDebounce | null | null/int | Adds a debounce of `$searchFilterDebounce` ms to the search input |
393+
| $searchFilterDefer | null | null/bool | Adds `.defer` to the search input |
394+
| $searchFilterLazy | null | null/bool | Adds `.lazy` to the search input |
395+
| $refresh | false | false/int/string | Whether or not to refresh the table at a certain interval. false = off, int = ms, string = functionCall |
396+
| $offlineIndicator | true | bool | Shows a red banner when there is no internet connection. |
398397

399398
#### Using more than one table on a page
400399

@@ -618,9 +617,11 @@ The final result would look like:
618617
## To-do/Roadmap
619618

620619
- [x] Bootstrap 4 Template
620+
- [x] Bootstrap 5 Template
621621
- [ ] Sorting By Relationships
622622
- [ ] Test Suite
623623
- [ ] Column Search
624+
- [ ] Greater Configurability
624625

625626
## Changelog
626627

resources/views/bootstrap-4/includes/bulk-actions.blade.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66

77
<div class="dropdown-menu dropdown-menu-right w-100" aria-labelledby="bulkActions">
88
@foreach($bulkActions as $action => $title)
9-
<a href="#" wire:click.prevent="{{ $action }}" class="dropdown-item">{{ $title }}</a>
9+
<a
10+
href="#"
11+
wire:click.prevent="{{ $action }}"
12+
wire:key="bulk-action-{{ $action }}"
13+
class="dropdown-item"
14+
>
15+
{{ $title }}
16+
</a>
1017
@endforeach
1118
</div>
1219
</div>

resources/views/bootstrap-4/includes/filter-pills.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@if ($showFilters && count(array_filter($filters)) && !(count(array_filter($filters)) === 1 && isset($filters['search'])))
2-
<div wire:key="filter-badges" class="mb-3">
2+
<div class="mb-3">
33
<small class="text-secondary">@lang('Applied Filters'):</small>
44

55
@foreach($filters as $key => $value)
66
@if ($key !== 'search' && strlen($value))
77
<span
8-
wire:key="filter-{{ $key }}"
8+
wire:key="filter-pill-{{ $key }}"
99
class="badge badge-pill badge-info d-inline-flex align-items-center"
1010
>
1111
{{ $filterNames[$key] ?? ucwords(strtr($key, ['_' => ' ', '-' => ' '])) }}: {{ ucwords(strtr($value, ['_' => ' ', '-' => ' '])) }}

resources/views/bootstrap-4/includes/filters.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@include($filtersView)
1818
@elseif (count($customFilters))
1919
@foreach ($customFilters as $key => $filter)
20-
<div class="p-2">
20+
<div wire:key="filter-{{ $key }}" class="p-2">
2121
@if ($filter->isSelect())
2222
<label for="filter-{{ $key }}" class="mb-2">
2323
{{ $filter->name() }}

resources/views/bootstrap-4/includes/search.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@if ($showSearch)
22
<div class="mb-3 mb-md-0 input-group">
33
<input
4-
wire:model.debounce.250ms="filters.search"
4+
wire:model{{ $this->searchFilterOptions }}="filters.search"
55
placeholder="{{ __('Search') }}"
66
type="text"
77
class="form-control"

resources/views/bootstrap-4/includes/sorting-pills.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@if ($showSorting && count($sorts))
2-
<div wire:key="sort-badges" class="mb-3">
2+
<div class="mb-3">
33
<small class="text-secondary">@lang('Applied Sorting'):</small>
44

55
@foreach($sorts as $col => $dir)
66
<span
7-
wire:key="sort-{{ $col }}"
7+
wire:key="sorting-pill-{{ $col }}"
88
class="badge badge-pill badge-info d-inline-flex align-items-center"
99
>
1010
<span>{{ $sortNames[$col] ?? ucwords(strtr($col, ['_' => ' ', '-' => ' '])) }}: {{ $dir === 'asc' ? 'A-Z' : 'Z-A' }}</span>

resources/views/bootstrap-5/includes/bulk-actions.blade.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66

77
<div class="dropdown-menu dropdown-menu-end w-100" aria-labelledby="bulkActions">
88
@foreach($bulkActions as $action => $title)
9-
<a href="#" wire:click.prevent="{{ $action }}" class="dropdown-item">{{ $title }}</a>
9+
<a
10+
href="#"
11+
wire:click.prevent="{{ $action }}"
12+
wire:key="bulk-action-{{ $action }}"
13+
class="dropdown-item"
14+
>
15+
{{ $title }}
16+
</a>
1017
@endforeach
1118
</div>
1219
</div>

resources/views/bootstrap-5/includes/filter-pills.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@if ($showFilters && count(array_filter($filters)) && !(count(array_filter($filters)) === 1 && isset($filters['search'])))
2-
<div wire:key="filter-badges" class="mb-3">
2+
<div class="mb-3">
33
<small class="text-secondary">@lang('Applied Filters'):</small>
44

55
@foreach($filters as $key => $value)
66
@if ($key !== 'search' && strlen($value))
77
<span
8-
wire:key="filter-{{ $key }}"
8+
wire:key="filter-pill-{{ $key }}"
99
class="badge rounded-pill bg-info d-inline-flex align-items-center"
1010
>
1111
{{ $filterNames[$key] ?? ucwords(strtr($key, ['_' => ' ', '-' => ' '])) }}: {{ ucwords(strtr($value, ['_' => ' ', '-' => ' '])) }}

resources/views/bootstrap-5/includes/filters.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@include($filtersView)
1818
@elseif (count($customFilters))
1919
@foreach ($customFilters as $key => $filter)
20-
<div class="p-2">
20+
<div wire:key="filter-{{ $key }}" class="p-2">
2121
@if ($filter->isSelect())
2222
<label for="filter-{{ $key }}" class="mb-2">
2323
{{ $filter->name() }}

0 commit comments

Comments
 (0)