Skip to content

Commit b6e4961

Browse files
committed
Merge branch 'develop'
2 parents 6d3c5d7 + e12ba41 commit b6e4961

22 files changed

+179
-105
lines changed

.php_cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->notPath('bootstrap/*')
5+
->notPath('storage/*')
6+
->notPath('resources/view/mail/*')
7+
->in([
8+
__DIR__ . '/src',
9+
__DIR__ . '/tests',
10+
])
11+
->name('*.php')
12+
->notName('*.blade.php')
13+
->ignoreDotFiles(true)
14+
->ignoreVCS(true);
15+
16+
return PhpCsFixer\Config::create()
17+
->setRules([
18+
'@PSR2' => true,
19+
'array_syntax' => ['syntax' => 'short'],
20+
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
21+
'no_unused_imports' => true,
22+
'not_operator_with_successor_space' => true,
23+
'trailing_comma_in_multiline_array' => true,
24+
'phpdoc_scalar' => true,
25+
'unary_operator_spaces' => true,
26+
'binary_operator_spaces' => true,
27+
'blank_line_before_statement' => [
28+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
29+
],
30+
'phpdoc_single_line_var_spacing' => true,
31+
'phpdoc_var_without_name' => true,
32+
'method_argument_space' => [
33+
'on_multiline' => 'ensure_fully_multiline',
34+
'keep_multiple_spaces_after_comma' => true,
35+
]
36+
])
37+
->setFinder($finder);

CHANGELOG.md

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

55
## [Unreleased]
66

7-
## [0.1.6] - 2020-06-15
7+
### Added
8+
9+
- Add pagination reset for perPage updates
10+
- Add second parameter to view method for the name of the model variable available in the view.
11+
- Allow publishing of views
12+
- Make docblocks work with psalm
13+
- Added searching method either debounce or lazy
14+
- Allow dot notation for customer attributes
15+
- Added loading message to table body if $loadingIndicator is true
16+
- Add clear button option to search box
817

918
### Changed
1019

20+
- Updated Livewire to 1.3
21+
- $disableSearchOnLoading default to false
22+
- Trim the search term when processing
23+
- Added language to publishable translation file
24+
25+
### Removed
26+
27+
- Existing loading subview for tbody message
28+
29+
## [0.1.6] - 2020-06-15
30+
31+
### Changed
1132
- Add second parameter to view method for the name of the model variable available in the view.
1233

1334
## [0.1.5] - 2020-05-26

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ You can override any of these in your table component:
160160
| Property | Default | Usage |
161161
| -------- | ------- | ----- |
162162
| $searchEnabled | true | Whether or not searching is enabled |
163+
| $searchUpdateMethod | debounce | debounce or lazy |
163164
| $searchDebounce | 350 | Amount of time in ms to wait to send the search query and refresh the table |
164-
| $disableSearchOnLoading | true | Whether or not to disable the search bar when it is searching/loading new data |
165+
| $disableSearchOnLoading | false | Whether or not to disable the search bar when it is searching/loading new data |
165166
| $search | *none* | The initial search string |
166-
| $searchLabel | Search... | The placeholder for the search box |
167-
| $noResultsMessage | There are no results to display for this query. | The message to display when there are no results |
167+
| $clearSearchButton | false | Adds a clear button to the search input |
168+
| $clearSearchButtonClass | btn btn-outline-dark | The class applied to the clear button |
168169

169170
#### Sorting
170171

@@ -181,21 +182,18 @@ You can override any of these in your table component:
181182
| $perPageEnabled | true | Displays per page |
182183
| $perPageOptions | [10, 25, 50] | The options to limit the amount of results per page |
183184
| $perPage | 25 | Amount of items to show per page |
184-
| $perPageLabel | Per Page | The label for the per page filter |
185185

186186
#### Loading
187187

188188
| Property | Default | Usage |
189189
| -------- | ------- | ----- |
190190
| $loadingIndicator | false | Whether or not to show a loading indicator when searching |
191-
| $loadingMessage | Loading... | The loading message that gets displayed |
192191

193192
#### Offline
194193

195194
| Property | Default | Usage |
196195
| -------- | ------- | ----- |
197196
| $offlineIndicator | true | Whether or not to display an offline message when there is no connection |
198-
| $offlineMessage | You are not currently connected to the internet. | The message to display when offline |
199197

200198
#### Checkboxes
201199

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
],
2121
"require": {
2222
"php": "^7.2.5",
23-
"livewire/livewire": "^1.0"
23+
"livewire/livewire": "^1.3"
2424
},
2525
"require-dev": {
26+
"friendsofphp/php-cs-fixer": "^2.16",
27+
"orchestra/testbench": "^5.0",
2628
"phpunit/phpunit": "^8.0|^9.0"
2729
},
2830
"autoload": {
@@ -37,7 +39,8 @@
3739
},
3840
"scripts": {
3941
"test": "vendor/bin/phpunit",
40-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
42+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
43+
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
4144
},
4245
"config": {
4346
"sort-packages": true

resources/lang/en/strings.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
return [
4+
'clear' => 'Clear',
5+
'loading' => 'Loading...',
6+
'no_results' => 'There are no results to display for this query.',
7+
'offline' => 'You are not currently connected to the internet.',
8+
'per_page' => 'Per Page',
9+
'results' => 'Showing :first to :last out of :total results',
10+
'search' => 'Search...',
11+
];

resources/views/includes/_body.blade.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
<tbody>
1+
@if ($loadingIndicator)
2+
<tbody wire:loading>
3+
<tr><td colspan="{{ collect($columns)->count() }}">@lang('laravel-livewire-tables::strings.loading')</td></tr>
4+
</tbody>
5+
6+
<tbody wire:loading.remove>
7+
@else
8+
<tbody>
9+
@endif
210
@if($models->isEmpty())
3-
<tr><td colspan="{{ collect($columns)->count() }}">{{ $noResultsMessage }}</td></tr>
11+
<tr><td colspan="{{ collect($columns)->count() }}">@lang('laravel-livewire-tables::strings.no_results')</td></tr>
412
@else
513
@foreach($models as $model)
614
<tr
@@ -41,19 +49,19 @@ class="{{ $this->setTableDataClass($column->attribute, Arr::get($model->toArray(
4149
@else
4250
@if ($column->isHtml())
4351
@if ($column->isCustomAttribute())
44-
{{ new \Illuminate\Support\HtmlString($model->{$column->attribute}) }}
52+
{{ new \Illuminate\Support\HtmlString(data_get($model, $column->attribute)) }}
4553
@else
4654
{{ new \Illuminate\Support\HtmlString(Arr::get($model->toArray(), $column->attribute)) }}
4755
@endif
4856
@elseif ($column->isUnescaped())
4957
@if ($column->isCustomAttribute())
50-
{!! $model->{$column->attribute} !!}
58+
{!! data_get($model, $column->attribute) !!}
5159
@else
5260
{!! Arr::get($model->toArray(), $column->attribute) !!}
5361
@endif
5462
@else
5563
@if ($column->isCustomAttribute())
56-
{{ $model->{$column->attribute} }}
64+
{{ data_get($model, $column->attribute) }}
5765
@else
5866
{{ Arr::get($model->toArray(), $column->attribute) }}
5967
@endif

resources/views/includes/_loading.blade.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

resources/views/includes/_offline.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="row">
33
<div class="col-12">
44
<div wire:offline class="alert alert-danger">
5-
<i class="fa fa-info-circle"></i> {{ $offlineMessage }}
5+
<i class="fa fa-info-circle"></i> @lang('laravel-livewire-tables::strings.offline')
66
</div>
77
</div>
88
</div>

resources/views/includes/_options.blade.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="row mb-4">
33
@if ($paginationEnabled && $perPageEnabled)
44
<div class="col form-inline">
5-
{{ $perPageLabel }}: &nbsp;
5+
@lang('laravel-livewire-tables::strings.per_page'): &nbsp;
66

77
<select wire:model="perPage" class="form-control">
88
@if (is_array($perPageOptions))
@@ -20,13 +20,23 @@
2020

2121
@if ($searchEnabled)
2222
<div class="col">
23-
<input
24-
@if (is_numeric($searchDebounce)) wire:model.debounce.{{ $searchDebounce }}ms="search" @endif
25-
@if ($disableSearchOnLoading) wire:loading.attr="disabled" @endif
26-
class="form-control"
27-
type="text"
28-
placeholder="{{ $searchLabel }}"
29-
/>
23+
@if ($clearSearchButton)
24+
<div class="input-group">
25+
@endif
26+
<input
27+
@if (is_numeric($searchDebounce) && $searchUpdateMethod === 'debounce') wire:model.debounce.{{ $searchDebounce }}ms="search" @endif
28+
@if ($searchUpdateMethod === 'lazy') wire:model.lazy="search" @endif
29+
@if ($disableSearchOnLoading) wire:loading.attr="disabled" @endif
30+
class="form-control"
31+
type="text"
32+
placeholder="{{ __('laravel-livewire-tables::strings.search') }}"
33+
/>
34+
@if ($clearSearchButton)
35+
<div class="input-group-append">
36+
<button class="{{ $clearSearchButtonClass }}" type="button" wire:click="clearSearch">@lang('laravel-livewire-tables::strings.clear')</button>
37+
</div>
38+
</div>
39+
@endif
3040
</div>
3141
@endif
3242
</div>

resources/views/includes/_pagination.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
</div>
66

77
<div class="col text-right text-muted">
8-
{{ __('Showing :first to :last out of :total results', ['first' => $models->count() ? $models->firstItem() : 0, 'last' => $models->count() ? $models->lastItem() : 0, 'total' => $models->total()]) }}
8+
@lang('laravel-livewire-tables::strings.results', [
9+
'first' => $models->count() ? $models->firstItem() : 0,
10+
'last' => $models->count() ? $models->lastItem() : 0,
11+
'total' => $models->total()
12+
])
913
</div>
1014
</div>
1115
@endif

0 commit comments

Comments
 (0)