Skip to content

Commit 949478c

Browse files
committed
Ability to add 'All' to per page dropdown
Alphabetize en.json
1 parent 770b18b commit 949478c

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
99
- Added option for single column sorting only.
1010
- Ability to change empty message per table.
1111
- Added en.json lang file.
12+
- Ability to add 'All' option to per-page.
1213

1314
### Changed
1415

1516
- Modified views to support localization better where necessary (republish views).
17+
- Alphabetize en.json
1618

1719
## [1.3.1] - 2021-04-26
1820

resources/lang/en.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
2-
"You have selected": "You have selected",
3-
"rows, do you want to select all": "rows, do you want to select all",
4-
"Select All": "Select All",
5-
"You are currently selecting all": "You are currently selecting all",
6-
"rows": "rows",
7-
"Unselect All": "Unselect All",
2+
"All": "All",
3+
"Applied Filters": "Applied Filters",
84
"Applied Sorting": "Applied Sorting",
9-
"Remove sort option": "Remove sort option",
10-
"Clear": "Clear",
115
"Bulk Actions": "Bulk Actions",
6+
"Clear": "Clear",
127
"Filters": "Filters",
13-
"Applied Filters": "Applied Filters",
148
"Remove filter option": "Remove filter option",
9+
"Remove sort option": "Remove sort option",
1510
"Search": "Search",
11+
"Select All": "Select All",
1612
"Showing": "Showing",
17-
"results": "results",
13+
"Unselect All": "Unselect All",
14+
"You are currently selecting all": "You are currently selecting all",
1815
"You are not connected to the internet.": "You are not connected to the internet.",
19-
"to": "to",
20-
"of": "of"
16+
"You have selected": "You have selected",
17+
"of": "of",
18+
"results": "results",
19+
"rows": "rows",
20+
"rows, do you want to select all": "rows, do you want to select all",
21+
"to": "to"
2122
}

resources/views/bootstrap-4/includes/per-page.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class="form-control"
77
>
88
@foreach ($perPageAccepted as $item)
9-
<option value="{{ $item }}">{{ $item }}</option>
9+
<option value="{{ $item }}">{{ $item === -1 ? __('All') : $item }}</option>
1010
@endforeach
1111
</select>
1212
</div>

resources/views/bootstrap-5/includes/per-page.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class="form-select"
77
>
88
@foreach ($perPageAccepted as $item)
9-
<option value="{{ $item }}">{{ $item }}</option>
9+
<option value="{{ $item }}">{{ $item === -1 ? __('All') : $item }}</option>
1010
@endforeach
1111
</select>
1212
</div>

resources/views/tailwind/includes/per-page.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class="rounded-md shadow-sm block w-full pl-3 pr-10 py-2 text-base leading-6 border-gray-300 focus:outline-none focus:border-indigo-300 focus:shadow-outline-indigo sm:text-sm sm:leading-5"
77
>
88
@foreach ($perPageAccepted as $item)
9-
<option value="{{ $item }}">{{ $item }}</option>
9+
<option value="{{ $item }}">{{ $item === -1 ? __('All') : $item }}</option>
1010
@endforeach
1111
</select>
1212
</div>

src/Traits/WithPerPagePagination.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ trait WithPerPagePagination
1212
public bool $showPagination = true;
1313
public int $perPage = 10;
1414
public array $perPageAccepted = [10, 25, 50];
15+
public bool $perPageAll = false;
1516

1617
public function mountWithPerPagePagination(): void
1718
{
19+
if ($this->perPageAll) {
20+
$this->perPageAccepted[] = -1;
21+
}
22+
1823
if (in_array(session()->get($this->tableName.'-perPage', $this->perPage), $this->perPageAccepted, true)) {
1924
$this->perPage = session()->get($this->tableName.'-perPage', $this->perPage);
2025
} else {
@@ -42,6 +47,6 @@ public function updatedPerPage($value): void
4247
*/
4348
public function applyPagination($query)
4449
{
45-
return $query->paginate($this->perPage, ['*'], $this->pageName());
50+
return $query->paginate($this->perPage === -1 ? $query->count() : $this->perPage, ['*'], $this->pageName());
4651
}
4752
}

0 commit comments

Comments
 (0)