Skip to content

Commit 1f5616d

Browse files
committed
Added selected row de-selector when not selecting full page or all.
1 parent 77993df commit 1f5616d

File tree

4 files changed

+73
-24
lines changed

4 files changed

+73
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
77
### Added
88

99
- Added hideIf for columns to hide a column with a conditional, works out of the box for cells not using rowView, if using rowView you must wrap the cells you want to hide in the same conditional. [See documentation](https://github.com/rappasoft/laravel-livewire-tables/wiki/Conditionally-hiding-columns).
10+
- Added selected row de-selector when not selecting full page or all.
1011

1112
## [1.4.0] - 2021-04-29
1213

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,26 @@
2727
</x-slot>
2828

2929
<x-slot name="body">
30-
@if (count($bulkActions) && $selectPage && $rows->total() > $rows->count())
30+
@if (count($bulkActions) && (($selectPage && $rows->total() > $rows->count()) || count($selected)))
3131
<x-livewire-tables::bs4.table.row wire:key="row-message">
3232
<x-livewire-tables::bs4.table.cell colspan="{{ count($bulkActions) ? count($columns) + 1 : count($columns) }}">
33-
@unless ($selectAll)
33+
@if (count($selected) && !$selectAll && !$selectPage)
3434
<div>
3535
<span>
3636
@lang('You have selected')
37-
<strong>{{ $rows->count() }}</strong>
38-
@lang('rows, do you want to select all')
39-
<strong>{{ number_format($rows->total()) }}</strong>?
37+
<strong>{{ count($selected) }}</strong>
38+
@lang('rows')
4039
</span>
4140

4241
<button
43-
wire:click="selectAll"
42+
wire:click="resetBulk"
4443
type="button"
4544
class="btn btn-primary btn-sm"
4645
>
47-
@lang('Select All')
46+
@lang('Unselect All')
4847
</button>
4948
</div>
50-
@else
49+
@elseif ($selectAll)
5150
<div>
5251
<span>
5352
@lang('You are currently selecting all')
@@ -63,6 +62,23 @@ class="btn btn-primary btn-sm"
6362
@lang('Unselect All')
6463
</button>
6564
</div>
65+
@else
66+
<div>
67+
<span>
68+
@lang('You have selected')
69+
<strong>{{ $rows->count() }}</strong>
70+
@lang('rows, do you want to select all')
71+
<strong>{{ number_format($rows->total()) }}</strong>?
72+
</span>
73+
74+
<button
75+
wire:click="selectAll"
76+
type="button"
77+
class="btn btn-primary btn-sm"
78+
>
79+
@lang('Select All')
80+
</button>
81+
</div>
6682
@endif
6783
</x-livewire-tables::bs4.table.cell>
6884
</x-livewire-tables::bs4.table.row>

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,26 @@ class="form-check-input"
2828
</x-slot>
2929

3030
<x-slot name="body">
31-
@if (count($bulkActions) && $selectPage && $rows->total() > $rows->count())
31+
@if (count($bulkActions) && (($selectPage && $rows->total() > $rows->count()) || count($selected)))
3232
<x-livewire-tables::bs5.table.row wire:key="row-message">
3333
<x-livewire-tables::bs5.table.cell colspan="{{ count($bulkActions) ? count($columns) + 1 : count($columns) }}">
34-
@unless ($selectAll)
34+
@if (count($selected) && !$selectAll && !$selectPage)
3535
<div>
3636
<span>
3737
@lang('You have selected')
38-
<strong>{{ $rows->count() }}</strong>
39-
@lang('rows, do you want to select all')
40-
<strong>{{ number_format($rows->total()) }}</strong>?
38+
<strong>{{ count($selected) }}</strong>
39+
@lang('rows')
4140
</span>
4241

4342
<button
44-
wire:click="selectAll"
43+
wire:click="resetBulk"
4544
type="button"
4645
class="btn btn-primary btn-sm"
4746
>
48-
@lang('Select All')
47+
@lang('Unselect All')
4948
</button>
5049
</div>
51-
@else
50+
@elseif ($selectAll)
5251
<div>
5352
<span>
5453
@lang('You are currently selecting all')
@@ -64,6 +63,23 @@ class="btn btn-primary btn-sm"
6463
@lang('Unselect All')
6564
</button>
6665
</div>
66+
@else
67+
<div>
68+
<span>
69+
@lang('You have selected')
70+
<strong>{{ $rows->count() }}</strong>
71+
@lang('rows, do you want to select all')
72+
<strong>{{ number_format($rows->total()) }}</strong>?
73+
</span>
74+
75+
<button
76+
wire:click="selectAll"
77+
type="button"
78+
class="btn btn-primary btn-sm"
79+
>
80+
@lang('Select All')
81+
</button>
82+
</div>
6783
@endif
6884
</x-livewire-tables::bs5.table.cell>
6985
</x-livewire-tables::bs5.table.row>

resources/views/tailwind/includes/table.blade.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,26 @@ class="rounded-md shadow-sm border-gray-300 block transition duration-150 ease-i
3030
</x-slot>
3131

3232
<x-slot name="body">
33-
@if (count($bulkActions) && $selectPage && $rows->total() > $rows->count())
33+
@if (count($bulkActions) && (($selectPage && $rows->total() > $rows->count()) || count($selected)))
3434
<x-livewire-tables::table.row wire:key="row-message" class="bg-indigo-50">
3535
<x-livewire-tables::table.cell :colspan="count($bulkActions) ? count($columns) + 1 : count($columns)">
36-
@unless ($selectAll)
36+
@if (count($selected) && !$selectAll && !$selectPage)
3737
<div>
3838
<span>
3939
@lang('You have selected')
40-
<strong>{{ $rows->count() }}</strong>
41-
@lang('rows, do you want to select all')
42-
<strong>{{ number_format($rows->total()) }}</strong>?
40+
<strong>{{ count($selected) }}</strong>
41+
@lang('rows')
4342
</span>
4443

4544
<button
46-
wire:click="selectAll"
45+
wire:click="resetBulk"
4746
type="button"
4847
class="ml-1 text-blue-600 underline text-gray-700 text-sm leading-5 font-medium focus:outline-none focus:text-gray-800 focus:underline transition duration-150 ease-in-out"
4948
>
50-
@lang('Select All')
49+
@lang('Unselect All')
5150
</button>
5251
</div>
53-
@else
52+
@elseif ($selectAll)
5453
<div>
5554
<span>
5655
@lang('You are currently selecting all')
@@ -66,6 +65,23 @@ class="ml-1 text-blue-600 underline text-gray-700 text-sm leading-5 font-medium
6665
@lang('Unselect All')
6766
</button>
6867
</div>
68+
@else
69+
<div>
70+
<span>
71+
@lang('You have selected')
72+
<strong>{{ $rows->count() }}</strong>
73+
@lang('rows, do you want to select all')
74+
<strong>{{ number_format($rows->total()) }}</strong>?
75+
</span>
76+
77+
<button
78+
wire:click="selectAll"
79+
type="button"
80+
class="ml-1 text-blue-600 underline text-gray-700 text-sm leading-5 font-medium focus:outline-none focus:text-gray-800 focus:underline transition duration-150 ease-in-out"
81+
>
82+
@lang('Select All')
83+
</button>
84+
</div>
6985
@endif
7086
</x-livewire-tables::table.cell>
7187
</x-livewire-tables::table.row>

0 commit comments

Comments
 (0)