File tree Expand file tree Collapse file tree 9 files changed +74
-24
lines changed Expand file tree Collapse file tree 9 files changed +74
-24
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,19 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
12
12
- Make docblocks work with psalm
13
13
- Added searching method either debounce or lazy
14
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
15
17
16
18
### Changed
17
19
18
20
- Updated Livewire to 1.3
21
+ - $disableSearchOnLoading default to false
22
+ - Trim the search term when processing
19
23
20
24
### Removed
21
25
26
+ - Existing loading subview for tbody message
27
+
22
28
## [ 0.1.6] - 2020-06-15
23
29
24
30
### Changed
Original file line number Diff line number Diff line change @@ -162,10 +162,13 @@ You can override any of these in your table component:
162
162
| $searchEnabled | true | Whether or not searching is enabled |
163
163
| $searchUpdateMethod | debounce | debounce or lazy |
164
164
| $searchDebounce | 350 | Amount of time in ms to wait to send the search query and refresh the table |
165
- | $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 |
166
166
| $search | * none* | The initial search string |
167
167
| $searchLabel | Search... | The placeholder for the search box |
168
168
| $noResultsMessage | There are no results to display for this query. | The message to display when there are no results |
169
+ | $clearSearchButton | false | Adds a clear button to the search input |
170
+ | $clearSearchButtonClass | btn btn-outline-dark | The class applied to the clear button |
171
+ | $clearSearchButtonLabel | Search | The label of the search button |
169
172
170
173
#### Sorting
171
174
Original file line number Diff line number Diff line change 1
- <tbody >
1
+ @if ($loadingIndicator )
2
+ <tbody wire:loading >
3
+ <tr ><td colspan =" {{ collect ($columns )-> count () } }" >{{ $loadingMessage } } </td ></tr >
4
+ </tbody >
5
+
6
+ <tbody wire:loading.remove >
7
+ @else
8
+ <tbody >
9
+ @endif
2
10
@if ($models -> isEmpty () )
3
11
<tr ><td colspan =" {{ collect ($columns )-> count () } }" >{{ $noResultsMessage } } </td ></tr >
4
12
@else
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 20
20
21
21
@if ($searchEnabled )
22
22
<div class =" col" >
23
- <input
24
- @if (is_numeric ($searchDebounce ) && $searchUpdateMethod === ' debounce' ) wire:model.debounce.{{ $searchDebounce }}ms =" search" @endif
25
- @if ($searchUpdateMethod === ' lazy' ) wire:model.lazy =" search" @endif
26
- @if ($disableSearchOnLoading ) wire:loading.attr =" disabled" @endif
27
- class =" form-control"
28
- type =" text"
29
- placeholder =" {{ $searchLabel } }"
30
- />
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 =" {{ $searchLabel } }"
33
+ />
34
+ @if ($clearSearchButton )
35
+ <div class =" input-group-append" >
36
+ <button class =" {{ $clearSearchButtonClass } }" type =" button" wire:click =" clearSearch" >{{ $clearSearchButtonLabel } } </button >
37
+ </div >
38
+ </div >
39
+ @endif
31
40
</div >
32
41
@endif
33
42
</div >
Original file line number Diff line number Diff line change 7
7
@endif
8
8
@include (' laravel-livewire-tables::includes._offline' )
9
9
@include (' laravel-livewire-tables::includes._options' )
10
- @include (' laravel-livewire-tables::includes._loading' )
11
10
12
11
@if (is_string ($responsive ) )
13
12
<div class =" {{ $responsive } }" >
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ public function setTranslationStrings()
72
72
$ this ->noResultsMessage = __ ('There are no results to display for this query. ' );
73
73
$ this ->perPageLabel = __ ('Per Page ' );
74
74
$ this ->searchLabel = __ ('Search... ' );
75
+ $ this ->clearSearchButtonLabel = __ ('Clear ' );
75
76
}
76
77
77
78
/**
Original file line number Diff line number Diff line change @@ -16,7 +16,14 @@ trait Loading
16
16
*
17
17
* @var bool
18
18
*/
19
- public $ loadingIndicator = false ;
19
+ public $ loadingIndicator = true ;
20
+
21
+ /**
22
+ * Whether or not to disable the search bar when it is searching/loading new data.
23
+ *
24
+ * @var bool
25
+ */
26
+ public $ disableSearchOnLoading = false ;
20
27
21
28
/**
22
29
* The loading message that gets displayed.
Original file line number Diff line number Diff line change @@ -32,13 +32,6 @@ trait Search
32
32
*/
33
33
public $ searchDebounce = 350 ;
34
34
35
- /**
36
- * Whether or not to disable the search bar when it is searching/loading new data.
37
- *
38
- * @var bool
39
- */
40
- public $ disableSearchOnLoading = true ;
41
-
42
35
/**
43
36
* The initial search string.
44
37
*
@@ -59,4 +52,33 @@ trait Search
59
52
* @var string
60
53
*/
61
54
public $ noResultsMessage ;
55
+
56
+ /**
57
+ * A button to clear the search box
58
+ *
59
+ * @var bool
60
+ */
61
+ public $ clearSearchButton = false ;
62
+
63
+ /**
64
+ * The text for the clear search box button
65
+ *
66
+ * @var
67
+ */
68
+ public $ clearSearchButtonLabel ;
69
+
70
+ /**
71
+ * The classes to apply to the clear search box button
72
+ *
73
+ * @var string
74
+ */
75
+ public $ clearSearchButtonClass = 'btn btn-outline-dark ' ;
76
+
77
+ /**
78
+ * Resets the search string
79
+ */
80
+ public function clearSearch () : void
81
+ {
82
+ $ this ->search = '' ;
83
+ }
62
84
}
You can’t perform that action at this time.
0 commit comments