Skip to content

Commit eea59ca

Browse files
authored
Merge pull request #209 from rappasoft/develop
Develop
2 parents 84e99f8 + 727f2ff commit eea59ca

27 files changed

+447
-15
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7+
## [1.0.3] - 2021-04-18
8+
9+
### Added
10+
11+
- Added Bootstrap 5 theme
12+
13+
### Changed
14+
15+
- Removed calls to custom primary color with indigo for tailwind
16+
- Updated search and row click sections of read me to be more clear.
17+
- Added resetPage to per page dropdown and filters.
18+
719
## [1.0.2] - 2021-04-17
820

921
### Changed
@@ -169,7 +181,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
169181

170182
- Initial release
171183

172-
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.2...development
184+
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.3...development
185+
[1.0.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.2...v1.0.3
173186
[1.0.2]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.1...v1.0.2
174187
[1.0.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.0...v1.0.1
175188
[1.0.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.4.0...v1.0.0

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This is the contents of the published config file:
3434

3535
return [
3636
/**
37-
* Options: tailwind | bootstrap-4.
37+
* Options: tailwind | bootstrap-4 | bootstrap-5.
3838
*/
3939
'theme' => 'tailwind',
4040
];
@@ -160,6 +160,8 @@ public function getTableRowUrl($row): string
160160
}
161161
```
162162

163+
**Note:** When you have a clickable row, you might have issues with other clickable items in your cells following the row URL instead of the items action. As of right now I'd advise against using both until there is a better solution.
164+
163165
### Using the included blade components in the row view:
164166

165167
To create cells, you should use the `<x-livewire-tables::table.cell>` table cell component, which will be rendered to:
@@ -170,7 +172,8 @@ To create cells, you should use the `<x-livewire-tables::table.cell>` table cell
170172
</td>
171173
```
172174

173-
**Note:** The default `x-livewire-tables::table.row` and `x-livewire-tables::table.cell` default to Tailwind, for Bootstrap specific versions use `x-livewire-tables::bs4.table.row` and `x-livewire-tables::bs4.table.cell`.
175+
**Note:** The default `x-livewire-tables::table.row` and `x-livewire-tables::table.cell` default to Tailwind, for Bootstrap specific versions use `x-livewire-tables::bs4.table.row` and `x-livewire-tables::bs4.table.cell` for
176+
Bootstrap 4, or `x-livewire-tables::bs5.table.row` and `x-livewire-tables::bs5.table.cell` for Bootstrap 5.
174177

175178
There is also a Tailwind alias of `x-livewire-tables::tw.table.row` and `x-livewire-tables::tw.table.cell` if you want to be specific.
176179

@@ -325,11 +328,30 @@ The search is a special built-in filter that is managed by the component, but yo
325328
public function query(): Builder
326329
{
327330
return User::query()
328-
->when($this->getFilter('search'), fn ($query, $term) => $query->search($term));
331+
->when($this->getFilter('search'), fn ($query, $term) => $query->where('name', 'like', '%'.$term.'%')->orWhere('email', 'like', '%'.$term.'%'));
332+
}
333+
```
334+
335+
You can make this even more streamlined by adding a search scope to your model like so:
336+
337+
```php
338+
public function scopeSearch($query, $term)
339+
{
340+
return $query->where(
341+
fn ($query) => $query->where('name', 'like', '%'.$term.'%')
342+
->orWhere('email', 'like', '%'.$term.'%')
343+
);
329344
}
330345
```
331346

332-
You can make this even more streamlined by adding a search scope like demonstrated above. Or you can use regular where/orWhere clauses.
347+
And then using it like this:
348+
349+
```php
350+
{
351+
return User::query()
352+
->when($this->getFilter('search'), fn ($query, $term) => $query->search($term));
353+
}
354+
```
333355

334356
### Creating Bulk Actions
335357

config/livewire-tables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
return [
44
/**
5-
* Options: tailwind | bootstrap-4.
5+
* Options: tailwind | bootstrap-4 | bootstrap-5.
66
*/
77
'theme' => 'tailwind',
88
];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class="badge badge-pill badge-info d-inline-flex align-items-center"
1515
wire:click.prevent="removeFilter('{{ $key }}')"
1616
class="text-white ml-2"
1717
>
18-
<span class="sr-only">@lang('Remove sort option')</span>
18+
<span class="sr-only">@lang('Remove filter option')</span>
1919
<svg style="width:.5em;height:.5em" stroke="currentColor" fill="none" viewBox="0 0 8 8">
2020
<path stroke-linecap="round" stroke-width="1.5" d="M1 1l6 6m0-6L1 7" />
2121
</svg>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<td {{ $attributes }}>
2+
{{ $slot }}
3+
</td>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@props([
2+
'column',
3+
'sortable' => null,
4+
'direction' => null,
5+
'text' => null,
6+
])
7+
8+
@unless ($sortable)
9+
<th {{ $attributes->only('class') }}>
10+
{{ $text ?? $slot }}
11+
</th>
12+
@else
13+
<th
14+
wire:click="sortBy('{{ $column }}', '{{ $text ?? $column }}')"
15+
{{ $attributes->only('class') }}
16+
style="cursor:pointer;"
17+
>
18+
<div class="d-flex align-items-center">
19+
<span>{{ $text }}</span>
20+
21+
<span class="relative d-flex align-items-center">
22+
@if ($direction === 'asc')
23+
<svg xmlns="http://www.w3.org/2000/svg" class="ms-1" style="width:1em;height:1em;" fill="none" viewBox="0 0 24 24" stroke="currentColor">
24+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
25+
</svg>
26+
@elseif ($direction === 'desc')
27+
<svg xmlns="http://www.w3.org/2000/svg" class="ms-1" style="width:1em;height:1em;" fill="none" viewBox="0 0 24 24" stroke="currentColor">
28+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
29+
</svg>
30+
@else
31+
<svg xmlns="http://www.w3.org/2000/svg" class="ms-1" style="width:1em;height:1em;" fill="none" viewBox="0 0 24 24" stroke="currentColor">
32+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4" />
33+
</svg>
34+
@endif
35+
</span>
36+
</div>
37+
</th>
38+
@endif
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@foreach($columns as $column)
2+
<td>
3+
@if ($column->asHtml)
4+
{{ new \Illuminate\Support\HtmlString($column->formatted($row)) }}
5+
@else
6+
{{ $column->formatted($row) }}
7+
@endif
8+
</td>
9+
@endforeach
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@props(['url' => null])
2+
3+
<tr
4+
{{ $attributes }}
5+
6+
@if ($url)
7+
onclick="window.location='{{ $url }}';"
8+
style="cursor:pointer"
9+
@endif
10+
>
11+
{{ $slot }}
12+
</tr>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="table-responsive">
2+
<table class="table table-striped">
3+
<thead>
4+
<tr>
5+
{{ $head }}
6+
</tr>
7+
</thead>
8+
9+
<tbody>
10+
{{ $body }}
11+
</tbody>
12+
</table>
13+
</div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div
2+
@if (is_numeric($refresh)) wire:poll.{{ $refresh }}ms @elseif(is_string($refresh)) wire:poll="{{ $refresh }}" @endif
3+
class="container-fluid"
4+
>
5+
@include('livewire-tables::bootstrap-5.includes.offline')
6+
@include('livewire-tables::bootstrap-5.includes.sorting-pills')
7+
@include('livewire-tables::bootstrap-5.includes.filter-pills')
8+
9+
<div class="d-md-flex justify-content-between mb-3">
10+
<div class="d-md-flex">
11+
@include('livewire-tables::bootstrap-5.includes.search')
12+
13+
<div class="ms-0 ms-md-3 mb-3 mb-md-0">
14+
@include('livewire-tables::bootstrap-5.includes.filters')
15+
</div>
16+
</div>
17+
18+
<div class="d-md-flex">
19+
@include('livewire-tables::bootstrap-5.includes.bulk-actions')
20+
21+
<div class="ms-0 ms-md-3">
22+
@include('livewire-tables::bootstrap-5.includes.per-page')
23+
</div>
24+
</div>
25+
</div>
26+
27+
@include('livewire-tables::bootstrap-5.includes.table')
28+
@include('livewire-tables::bootstrap-5.includes.pagination')
29+
</div>

0 commit comments

Comments
 (0)