File tree Expand file tree Collapse file tree 10 files changed +77
-49
lines changed Expand file tree Collapse file tree 10 files changed +77
-49
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,12 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
10
10
11
11
### Changed
12
12
13
- - Removed default padding on bootstrap tables
14
13
- Clarified where rowView looks in read me
14
+ - Null the search filter when it's empty
15
+
16
+ ### Removed
17
+
18
+ - Removed ` text-secondary ` class from sorting title
15
19
16
20
## [ 1.1.0] - 2021-04-21
17
21
Original file line number Diff line number Diff line change 10
10
wire:poll =" {{ $refresh } }"
11
11
@endif
12
12
@endif
13
+ class =" container-fluid"
13
14
>
14
15
@include (' livewire-tables::bootstrap-4.includes.offline' )
15
16
@include (' livewire-tables::bootstrap-4.includes.sorting-pills' )
Original file line number Diff line number Diff line change 1
1
@if ($showFilters && count (array_filter ($filters )) && ! (count (array_filter ($filters )) === 1 && isset ($filters [' search' ])) )
2
2
<div class =" mb-3" >
3
- <small class = " text-secondary " >@lang (' Applied Filters' ):</small >
3
+ <small >@lang (' Applied Filters' ):</small >
4
4
5
5
@foreach ($filters as $key => $value )
6
6
@if ($key !== ' search' && strlen ($value ) )
Original file line number Diff line number Diff line change 1
1
@if ($showSorting && count ($sorts ) )
2
2
<div class =" mb-3" >
3
- <small class = " text-secondary " >@lang (' Applied Sorting' ):</small >
3
+ <small >@lang (' Applied Sorting' ):</small >
4
4
5
5
@foreach ($sorts as $col => $dir )
6
6
<span
Original file line number Diff line number Diff line change 10
10
wire:poll =" {{ $refresh } }"
11
11
@endif
12
12
@endif
13
+ class =" container-fluid"
13
14
>
14
15
@include (' livewire-tables::bootstrap-5.includes.offline' )
15
16
@include (' livewire-tables::bootstrap-5.includes.sorting-pills' )
Original file line number Diff line number Diff line change 1
1
@if ($showFilters && count (array_filter ($filters )) && ! (count (array_filter ($filters )) === 1 && isset ($filters [' search' ])) )
2
2
<div class =" mb-3" >
3
- <small class = " text-secondary " >@lang (' Applied Filters' ):</small >
3
+ <small >@lang (' Applied Filters' ):</small >
4
4
5
5
@foreach ($filters as $key => $value )
6
6
@if ($key !== ' search' && strlen ($value ) )
Original file line number Diff line number Diff line change 1
1
@if ($showSorting && count ($sorts ) )
2
2
<div class =" mb-3" >
3
- <small class = " text-secondary " >@lang (' Applied Sorting' ):</small >
3
+ <small >@lang (' Applied Sorting' ):</small >
4
4
5
5
@foreach ($sorts as $col => $dir )
6
6
<span
Original file line number Diff line number Diff line change 10
10
use Rappasoft \LaravelLivewireTables \Traits \WithCustomPagination ;
11
11
use Rappasoft \LaravelLivewireTables \Traits \WithFilters ;
12
12
use Rappasoft \LaravelLivewireTables \Traits \WithPerPagePagination ;
13
+ use Rappasoft \LaravelLivewireTables \Traits \WithSearch ;
13
14
use Rappasoft \LaravelLivewireTables \Traits \WithSorting ;
14
15
15
16
/**
@@ -23,6 +24,7 @@ abstract class DataTableComponent extends Component
23
24
use WithCustomPagination;
24
25
use WithFilters;
25
26
use WithPerPagePagination;
27
+ use WithSearch;
26
28
use WithSorting;
27
29
28
30
/**
@@ -32,13 +34,6 @@ abstract class DataTableComponent extends Component
32
34
*/
33
35
public $ paginationTheme = 'tailwind ' ;
34
36
35
- /**
36
- * Show the search field.
37
- *
38
- * @var bool
39
- */
40
- public bool $ showSearch = true ;
41
-
42
37
/**
43
38
* Whether or not to refresh the table at a certain interval
44
39
* false is off
Original file line number Diff line number Diff line change @@ -30,21 +30,6 @@ trait WithFilters
30
30
'search ' => null ,
31
31
];
32
32
33
- /**
34
- * @var int|null
35
- */
36
- public ?int $ searchFilterDebounce = null ;
37
-
38
- /**
39
- * @var bool|null
40
- */
41
- public ?bool $ searchFilterDefer = null ;
42
-
43
- /**
44
- * @var bool|null
45
- */
46
- public ?bool $ searchFilterLazy = null ;
47
-
48
33
/**
49
34
* Prebuild the $filters array
50
35
*/
@@ -57,28 +42,6 @@ public function mountWithFilters(): void
57
42
}
58
43
}
59
44
60
- /**
61
- * Build Livewire model options for the search input
62
- *
63
- * @return string
64
- */
65
- public function getSearchFilterOptionsProperty (): string
66
- {
67
- if ($ this ->searchFilterDebounce ) {
68
- return '.debounce. ' . $ this ->searchFilterDebounce . 'ms ' ;
69
- }
70
-
71
- if ($ this ->searchFilterDefer ) {
72
- return '.defer ' ;
73
- }
74
-
75
- if ($ this ->searchFilterLazy ) {
76
- return '.lazy ' ;
77
- }
78
-
79
- return '' ;
80
- }
81
-
82
45
/**
83
46
* Reset the filters array but keep the value for search
84
47
*/
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Rappasoft \LaravelLivewireTables \Traits ;
4
+
5
+ /**
6
+ * Trait WithSearch.
7
+ */
8
+ trait WithSearch
9
+ {
10
+ /**
11
+ * Show the search field.
12
+ *
13
+ * @var bool
14
+ */
15
+ public bool $ showSearch = true ;
16
+
17
+ /**
18
+ * @var int|null
19
+ */
20
+ public ?int $ searchFilterDebounce = null ;
21
+
22
+ /**
23
+ * @var bool|null
24
+ */
25
+ public ?bool $ searchFilterDefer = null ;
26
+
27
+ /**
28
+ * @var bool|null
29
+ */
30
+ public ?bool $ searchFilterLazy = null ;
31
+
32
+ /**
33
+ * Remove the search filter when it's empty
34
+ */
35
+ public function updatedFilters (): void
36
+ {
37
+ if (isset ($ this ->filters ['search ' ]) && $ this ->filters ['search ' ] === '' )
38
+ {
39
+ $ this ->filters ['search ' ] = null ;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Build Livewire model options for the search input
45
+ *
46
+ * @return string
47
+ */
48
+ public function getSearchFilterOptionsProperty (): string
49
+ {
50
+ if ($ this ->searchFilterDebounce ) {
51
+ return '.debounce. ' . $ this ->searchFilterDebounce . 'ms ' ;
52
+ }
53
+
54
+ if ($ this ->searchFilterDefer ) {
55
+ return '.defer ' ;
56
+ }
57
+
58
+ if ($ this ->searchFilterLazy ) {
59
+ return '.lazy ' ;
60
+ }
61
+
62
+ return '' ;
63
+ }
64
+ }
You can’t perform that action at this time.
0 commit comments