Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development to Master for v3.5.3 #2068

Merged
merged 138 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
30d65ac
Add explanation of setRefreshMethod (#1857)
lrljoe Aug 16, 2024
b3137d9
Unlocking Entangled Items (#1859)
lrljoe Aug 17, 2024
b6890e9
Add dispatch on updated filter components (#1861)
lrljoe Aug 18, 2024
fb646a5
v3.4.8
lrljoe Aug 18, 2024
4a18b05
Merge branch 'master' into development
lrljoe Aug 18, 2024
8eafffe
Fix superfluous bulk actions tr < (#1868)
lrljoe Aug 21, 2024
d1a563f
Default useComputedProperties to False (#1869)
lrljoe Aug 21, 2024
da50aa1
Update ChangeLog
lrljoe Aug 21, 2024
1ff4126
Merge branch 'master' into development
lrljoe Aug 21, 2024
74c35e2
Add Action Buttons (#1864)
lrljoe Aug 21, 2024
46d2752
FixDateRangeFilter (#1872)
lrljoe Aug 23, 2024
7aa4268
Adjust Methods - useComputedProperties (#1873)
lrljoe Aug 23, 2024
3456674
Update ChangeLog
lrljoe Aug 23, 2024
6480f1a
Merge branch 'master' into development
lrljoe Aug 23, 2024
32fe628
AllowDeleteDateRangeFilter (#1875)
lrljoe Aug 23, 2024
1f0c14d
Fix ChangeLog
lrljoe Aug 23, 2024
b80be2d
Update Docs (#1876)
lrljoe Aug 23, 2024
f0c5d04
Update ChangeLog - Add Docs Update
lrljoe Aug 23, 2024
ec5401a
Add setIconLeft/setIconRight (#1877)
lrljoe Aug 23, 2024
ae019cf
Adjust ChangeLog
lrljoe Aug 23, 2024
8e33fba
Merge branch 'master' into development
lrljoe Aug 23, 2024
edc7ea3
Adjust Action Button Icon Margin (#1880)
lrljoe Aug 23, 2024
79cf988
Merge branch 'master' into development
lrljoe Aug 23, 2024
6766707
Change Order of "Getting Started" section (#1883)
lrljoe Aug 24, 2024
39c5032
Add Button with No Icon (#1887)
lrljoe Aug 25, 2024
918bd31
Add a "Recommended" approach (#1886)
lrljoe Aug 25, 2024
1d18cb2
v3.4.13
lrljoe Aug 25, 2024
683666f
Merge branch 'master' into development
lrljoe Aug 25, 2024
8cafe98
Set actions position (#1889)
lrljoe Aug 25, 2024
5007627
Update ChangeLog
lrljoe Aug 25, 2024
b927a98
Merge branch 'master' into development
lrljoe Aug 25, 2024
d0da3b1
Doc Type Fixes (#1891)
lrljoe Aug 25, 2024
2a977ec
BooleanColumn - Toggleable Callback (#1892)
lrljoe Aug 25, 2024
a61ba21
Update ChangeLog
lrljoe Aug 25, 2024
e1acab7
Merge branch 'master' into development
lrljoe Aug 25, 2024
c14692b
Enable/Disable Tools/Toolbar (#1896)
lrljoe Aug 26, 2024
84eaf9b
Use Computed Properties By Default (#1898)
lrljoe Aug 26, 2024
0b0d9cb
Fix has actions (#1901)
lrljoe Aug 26, 2024
0882827
Add icon column (#1902)
lrljoe Aug 27, 2024
6ff95af
Add Baseline - Convert phpstan.neon to tabs (#1903)
lrljoe Aug 27, 2024
ce76b40
Update ChangeLog
lrljoe Aug 27, 2024
244951b
Merge branch 'master' into development
lrljoe Aug 27, 2024
570abdc
Save filter selection to session (BETA) (#1910)
lrljoe Sep 1, 2024
1f076af
Add hide table option (#1914)
lrljoe Sep 1, 2024
bf84029
Add column select session methods (#1913)
lrljoe Sep 1, 2024
2ebaf3b
Use Core HasTheme Methods (#1915)
lrljoe Sep 1, 2024
2322e8d
Use Core Attribute Bag (#1916)
lrljoe Sep 1, 2024
ed64834
Merge branch 'master' into development
lrljoe Sep 1, 2024
a63fb44
Fix ChangeLog
lrljoe Sep 1, 2024
2fd6014
Add Polish translation by @meavric (#1925)
lrljoe Sep 4, 2024
a7b1f68
Merge branch 'master' into development
lrljoe Sep 4, 2024
3a04d51
Add Vertical Scrolling Example (#1926)
lrljoe Sep 4, 2024
2a4b2d1
Adjusting contributing
lrljoe Sep 4, 2024
f1e041e
Fix missing variable in workflow (#1933)
lrljoe Sep 8, 2024
5b326cc
Fixes for ButtonGroupColumn, ImageColumn, LinkColumn - to not default…
lrljoe Sep 8, 2024
82e6e70
Add button type to tailwind pagination blade template (#1928)
matzeschmitt Sep 8, 2024
d5bdd7b
v3.4.19 ChangeLog
lrljoe Sep 8, 2024
1be3aad
Merge branch 'master' into development
lrljoe Sep 8, 2024
6a63e9f
Revert tableName to be public (#1937)
lrljoe Sep 10, 2024
05e0221
v3.4.20 ChangeLog
lrljoe Sep 10, 2024
90d6ffb
Merge branch 'master' into development
lrljoe Sep 10, 2024
530b0bf
Migration to Core attribute management (#1943)
lrljoe Sep 12, 2024
a76ae7b
Update docs - add Action setLabelAttributes method (#1952)
lrljoe Sep 18, 2024
07e8dbc
Reset Page on "Per Page" changing (#1953)
lrljoe Sep 18, 2024
256b12d
Localisation - Avoid Conflicts With Other Packages (#1955)
lrljoe Sep 20, 2024
bb005d0
Add filterComponents into queryString (#1957)
lrljoe Sep 21, 2024
1dfaca1
Fix syntax for DateColumn outputFormat in docs (#1960)
lrljoe Sep 21, 2024
a6c150a
Fix Filter Pills Icon - Tailwind (#1961)
lrljoe Sep 22, 2024
1760c3c
Add original translation strings - for use in published views (#1959)
lrljoe Sep 22, 2024
1817b9f
Fix for Search Field Attribute Defaults (#1962)
lrljoe Sep 22, 2024
3f7898f
Change the type of LaravelLivewireTablesEvent::$user from Illuminate\…
khwadj Sep 24, 2024
74a0cc8
Remove persist from getFilterGenericData (#1966)
lrljoe Sep 24, 2024
d19dba0
Update ChangeLog
lrljoe Sep 24, 2024
5f6e5d6
Update Pint Workflow (#1967)
lrljoe Sep 24, 2024
e222c1e
Update Discord Releases Workflow (#1968)
lrljoe Sep 24, 2024
5c47e61
Update ChangeLog
lrljoe Sep 24, 2024
2f4224b
Merge branch 'master' into development
lrljoe Sep 24, 2024
2d7f705
Fix Loading Placeholder Bug - Breaking Table (#1969)
lrljoe Sep 25, 2024
71717f9
v3.4.22 ChangeLog
lrljoe Sep 25, 2024
566a039
Merge branch 'master' into development
lrljoe Sep 25, 2024
9a8436f
Update ChangeLog
lrljoe Sep 27, 2024
905b43c
Add comment on getTitle (#1976)
lrljoe Sep 29, 2024
fd13aa9
Add before-wrapper and after-wrapper configurable areas (#1977)
lrljoe Sep 29, 2024
6bf0d09
Add initial commit for setPaginationWrapperAttributes (#1978)
lrljoe Sep 29, 2024
b4a247d
Update ChangeLog
lrljoe Sep 29, 2024
8b3df64
Update ChangeLog
lrljoe Sep 29, 2024
a7b1579
Adjust ChangeLog Date
lrljoe Sep 29, 2024
cd89e9e
Add ToolsAttributes and ToolbarAttributes (#1982)
lrljoe Sep 29, 2024
cf0a41f
Add docs for the ColumnSelect lifecycle hooks (#1983)
lrljoe Sep 29, 2024
7dc5e8f
Add setToolsAttributes and setToolBarAttributes docs (#1984)
lrljoe Sep 30, 2024
61a9b66
Update ChangeLog
lrljoe Sep 30, 2024
e6f3656
Adding Tools/Toolbar Enable Tests (#1986)
lrljoe Oct 1, 2024
2fe4db1
Add lang Norwegian and Albanian (#1988)
channor Oct 5, 2024
9fc6ad8
Fix missing i18n keys for FR, IT, EN, DE (#1993)
khwadj Oct 18, 2024
c134e6a
Loading Placeholder Adjustments (#1987)
lrljoe Oct 20, 2024
c15c1d1
Livewire column doesn't have title() method (#2002)
ChrisThompsonTLDR Oct 20, 2024
e3c79b4
Add Value to BooleanColumn custom view (#2010)
lrljoe Oct 25, 2024
1275e3f
Add config option to bypass setting User on Events. (#2006)
me-julian Oct 25, 2024
9916773
Fix styling
lrljoe Oct 25, 2024
2cd0344
Improve Workflow Caches (#2013)
lrljoe Oct 25, 2024
124bac1
Add customisation for QueryString specific to Filters (#2011)
lrljoe Oct 25, 2024
ad80321
Adjust Workflow Cache for Issue (#2015)
lrljoe Oct 25, 2024
92dc8fb
Fix bug with FilterQueryString (#2014)
lrljoe Oct 25, 2024
351757e
Add Customisation for "Search" in QueryString (#2017)
lrljoe Oct 27, 2024
542e797
Add QueryStringForSort (#2018)
lrljoe Oct 30, 2024
3e18b27
BETA: Livewire Custom Filter (Array) (#2025)
lrljoe Oct 30, 2024
211b39e
Fix bug #1997 - Found the issue elsewhere also, so I fixed them too. …
mrl22 Oct 30, 2024
bce91a4
Merge branch 'master' into development
lrljoe Oct 30, 2024
f764de8
Adds Swedish translations (#2027)
Aiiion Nov 1, 2024
a7521b9
Adjust ChangeLog for 3.5.0
lrljoe Nov 6, 2024
4f09e07
Adjust Number Filter - Convert Value to Float If All Digits (#2034)
lrljoe Nov 9, 2024
c7c97bb
Fixes for Filter Pills - Ensure Invalid Options Are Removed (#2035)
lrljoe Nov 9, 2024
963fca6
Update ChangeLog & Contributors
lrljoe Nov 9, 2024
12f907e
Merge branch 'master' into development
lrljoe Nov 10, 2024
03304f2
Test Suite cleanup - migrating existing tests into "Unit" (#2037)
lrljoe Nov 10, 2024
90355f8
Migrate Localisations To PHP vs JSON (#2038)
lrljoe Nov 10, 2024
7748021
Add "save", "cancel" to Core Localisation (#2039)
lrljoe Nov 10, 2024
a6a6b05
Merge branch 'master' into development
lrljoe Nov 10, 2024
d4f62e8
Minor Localisation Tweaks (#2042)
lrljoe Nov 10, 2024
f7cd908
Remove Duplicate Item (#2043)
lrljoe Nov 10, 2024
17db9a4
Merge branch 'master' into development
lrljoe Nov 10, 2024
38966bf
Update ChangeLog
lrljoe Nov 10, 2024
ce3abe8
Adjust Readme - Reference PHPStan Level 6
lrljoe Nov 10, 2024
0769663
Add updatedPerPageTest (#2047)
lrljoe Nov 10, 2024
009155d
Remove Waiting For Tests
lrljoe Nov 10, 2024
b7e4324
Use CODECOV_TOKEN
lrljoe Nov 10, 2024
4309b8d
Fix styling
lrljoe Nov 10, 2024
4aa03fa
Update phpdoc for boot (#2055)
lrljoe Nov 12, 2024
03c7796
Add test for No Columns defined - throws correct Exception (#2057)
lrljoe Nov 12, 2024
83b3ff9
Add Simple updatedSearch tests (#2058)
lrljoe Nov 12, 2024
2ea9010
Add test for FilterApplied Event being dispatched (#2059)
lrljoe Nov 12, 2024
ff38951
Add updatedSelectedColumns test for Event (#2060)
lrljoe Nov 12, 2024
c5a3a1d
Adjustment for DateRangeFilter (#2064)
lrljoe Nov 17, 2024
eec8385
Adjust SessionStorageHelpersTest (#2065)
lrljoe Nov 17, 2024
a9afdd8
FixSetDefaultPerPage (#2067)
lrljoe Nov 17, 2024
2aeb882
Fix BooleanColumn unexpected truthy behaviour (#2066)
lrljoe Nov 17, 2024
36cd8a0
Update ChangeLog
lrljoe Nov 18, 2024
eb88797
Merge branch 'master' into development
lrljoe Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to `laravel-livewire-tables` will be documented in this file

## [v3.5.3] - 2024-11-18
## Bug Fixes
- FixSetDefaultPerPage by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2067
- Fix BooleanColumn unexpected truthy behaviour by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2066
- Adjustment for DateRangeFilter by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2064

## Testing
- Adjust SessionStorageHelpersTest by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2065
- Add updatedSelectedColumns test for Event by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2060
- Add test for FilterApplied Event being dispatched by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2059
- Add Simple updatedSearch tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2058
- Add test for No Columns defined - throws correct Exception by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2057

## [v3.5.2] - 2024-11-09
## Bug Fixes
- Migrate Localisation back to PHP Files from JSON by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2038
Expand Down
43 changes: 41 additions & 2 deletions resources/js/laravel-livewire-tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ document.addEventListener('alpine:init', () => {

}
}));


Alpine.data('booleanFilter', (wire,filterKey,tableName,defaultValue) => ({
switchOn: false,
Expand All @@ -270,6 +269,47 @@ document.addEventListener('alpine:init', () => {
}
}));

Alpine.data('newBooleanFilter', (filterKey,tableName,defaultValue) => ({
switchOn: false,
value: false,
toggleStatus()
{
let tempValue = Boolean(Number(this.$wire.get('filterComponents.'+filterKey) ?? this.value));
let newBoolean = !tempValue;
this.switchOn = this.value = newBoolean;
return Number(newBoolean);
},
toggleStatusWithUpdate()
{
let newValue = this.toggleStatus();
this.$wire.set('filterComponents.'+filterKey, newValue);
},
toggleStatusWithReset()
{
let newValue = this.toggleStatus();
this.$wire.call('resetFilter',filterKey);
},
setSwitchOn(val)
{
let number = Number(val ?? 0);
this.switchOn = Boolean(number);
},
init() {
this.$nextTick(() => {
this.value = this.$wire.get('filterComponents.'+filterKey) ?? defaultValue;
this.setSwitchOn(this.value ?? 0);
});

this.listeners.push(
Livewire.on('filter-was-set', (detail) => {
if(detail.tableName == tableName && detail.filterKey == filterKey) {
this.switchOn = detail.value ?? defaultValue;
}
})
);
}
}));

Alpine.data('numberRangeFilter', (wire, filterKey, parentElementPath, filterConfig, childElementRoot) => ({
allFilters: wire.entangle('filterComponents', false),
originalMin: 0,
Expand Down Expand Up @@ -407,7 +447,6 @@ document.addEventListener('alpine:init', () => {

}));


Alpine.data('tableWrapper', (wire, showBulkActionsAlpine) => ({
shouldBeDisplayed: wire.entangle('shouldBeDisplayed'),
listeners: [],
Expand Down
2 changes: 1 addition & 1 deletion resources/js/laravel-livewire-tables.min.js

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions resources/views/components/tools/filters/boolean.blade.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
@php($defaultValue = ($filter->hasFilterDefaultValue() ? (bool) $filter->getFilterDefaultValue() : false))
<div class="flex flex-cols"
x-data="booleanFilter($wire,'{{ $filter->getKey() }}', '{{ $tableName }}', '{{ $defaultValue }}')"
x-data="newBooleanFilter('{{ $filter->getKey() }}', '{{ $tableName }}', '{{ $defaultValue }}')"
>
<x-livewire-tables::tools.filter-label :$filter :$filterLayout :$tableName :$isTailwind :$isBootstrap4 :$isBootstrap5 :$isBootstrap />
<input id="thisId" type="checkbox" name="switch" class="hidden" :checked="switchOn" >
<input id="thisId" type="checkbox" name="switch" class="hidden" :checked="value" />

<button id="{{ $tableName }}-filter-{{ $filter->getKey() }}"
x-ref="switchButton"
type="button"
@click="switchOn = ! switchOn; value = (switchOn ? '1' : '0')"
:class="switchOn ? 'bg-blue-600' : 'bg-neutral-200'"
@click="toggleStatusWithUpdate"
:class="(value == 1 || value == true) ? 'bg-blue-600' : 'bg-neutral-200'"
class="relative inline-flex h-6 py-0.5 ml-4 focus:outline-none rounded-full w-10"
x-cloak>
<span :class="switchOn ? 'translate-x-[18px]' : 'translate-x-0.5'" class="w-5 h-5 duration-200 ease-in-out bg-white rounded-full shadow-md"></span>
<span :class="(value == 1 || value == true) ? 'translate-x-[18px]' : 'translate-x-0.5'" class="w-5 h-5 duration-200 ease-in-out bg-white rounded-full shadow-md"></span>
</button>
<template x-if="value === '1' || value === '0'">
<button
x-on:click="switchOn = {{ $defaultValue }};"
wire:click="resetFilter('{{ $filter->getKey() }}')"
type="button"
<template x-if="(value == 1 || value == true)">
<button @click="toggleStatusWithReset" type="button"
class="flex-shrink-0 ml-1 h-6 w-6 rounded-full inline-flex items-center justify-center text-indigo-400 hover:bg-indigo-200 hover:text-indigo-500 focus:outline-none focus:bg-indigo-500 focus:text-white"
>

Expand Down
15 changes: 10 additions & 5 deletions src/Traits/Configuration/PaginationConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ public function setPerPage(int $perPage): self
return $this;
}

public function unsetPerPage(): self
{
$this->perPage = null;

return $this;
}

public function setPaginationMethod(string $paginationMethod): self
{
$this->paginationMethod = $paginationMethod;
Expand Down Expand Up @@ -138,12 +145,10 @@ public function setDisplayPaginationDetailsDisabled(): self
/**
* Set a default per-page value (if not set already by session or querystring)
*/
public function setDefaultPerPage(int $perPage): self
public function setDefaultPerPage(int $defaultPerPage): self
{
$defaultPerPage = $perPage;

if ($this->perPage == 10) {
$this->setPerPage($perPage);
if (in_array((int) $defaultPerPage, $this->getPerPageAccepted())) {
$this->defaultPerPage = $defaultPerPage;
}

return $this;
Expand Down
9 changes: 7 additions & 2 deletions src/Traits/Helpers/PaginationHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ public function getComputedPageName(): string

public function getPerPage(): int
{
return $this->perPage;
return $this->perPage ?? $this->getDefaultPerPage();
}

public function getDefaultPerPage(): int
{
return in_array((int) $this->defaultPerPage, $this->getPerPageAccepted()) ? $this->defaultPerPage : ($this->getPerPageAccepted()[0] ?? 10);
}

/**
Expand Down Expand Up @@ -128,7 +133,7 @@ public function setupPagination(): void
if (in_array(session($this->getPerPagePaginationSessionKey(), $this->getPerPage()), $this->getPerPageAccepted(), true)) {
$this->setPerPage(session($this->getPerPagePaginationSessionKey(), $this->getPerPage()));
} else {
$this->setPerPage($this->getPerPageAccepted()[0] ?? 10);
$this->setPerPage($this->getDefaultPerPage());
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/Traits/WithPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

public ?string $pageName = null;

public int $perPage = 10;
public ?int $perPage;

#[Locked]
public int $defaultPerPage = 10;

#[Locked]
public array $perPageAccepted = [10, 25, 50];
Expand Down Expand Up @@ -57,9 +60,9 @@

public function mountWithPagination(): void
{
$sessionPerPage = session()->get($this->getPerPagePaginationSessionKey(), $this->getPerPageAccepted()[0] ?? 10);
$sessionPerPage = session()->get($this->getPerPagePaginationSessionKey(), $this->getPerPage());
if (! in_array((int) $sessionPerPage, $this->getPerPageAccepted(), false)) {
$sessionPerPage = $this->getPerPageAccepted()[0] ?? 10;
$sessionPerPage = $this->getDefaultPerPage();

Check warning on line 65 in src/Traits/WithPagination.php

View check run for this annotation

Codecov / codecov/patch

src/Traits/WithPagination.php#L65

Added line #L65 was not covered by tests
}
$this->setPerPage($sessionPerPage);
}
Expand All @@ -68,7 +71,7 @@
public function updatedPerPage(int|string $value): void
{
if (! in_array((int) $value, $this->getPerPageAccepted(), false)) {
$value = $this->getPerPageAccepted()[0] ?? 10;
$value = $this->getDefaultPerPage();

Check warning on line 74 in src/Traits/WithPagination.php

View check run for this annotation

Codecov / codecov/patch

src/Traits/WithPagination.php#L74

Added line #L74 was not covered by tests
}

if (in_array(session($this->getPerPagePaginationSessionKey(), (int) $value), $this->getPerPageAccepted(), true)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Views/Filters/DateRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
return ['minDate' => '', 'maxDate' => ''];
}

public function validate(array|string $values): array|bool
public function validate(array|string|null $values): array|bool
{
$this->getOptions();
$this->getConfigs();
Expand Down Expand Up @@ -74,7 +74,7 @@
{
$earliestDateString = ($this->getConfig('earliestDate') != '') ? $this->getConfig('earliestDate') : null;
$latestDateString = ($this->getConfig('latestDate') != '') ? $this->getConfig('latestDate') : null;
if ($earliestDateString != '' && ! is_null($earliestDateString) && $latestDateString != '' && ! is_null($latestDateString)) {

Check failure on line 77 in src/Views/Filters/DateRangeFilter.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.3 - L11 - prefer-dist - ubuntu-latest

Call to function is_null() with mixed will always evaluate to false.

Check failure on line 77 in src/Views/Filters/DateRangeFilter.php

View workflow job for this annotation

GitHub Actions / PHPStan - P8.3 - L11 - prefer-dist - ubuntu-latest

Call to function is_null() with mixed will always evaluate to false.
$dateLimits = ['earliest' => $earliestDateString, 'latest' => $latestDateString];
$earlyLateValidator = Validator::make($dateLimits, [
'earliest' => 'date_format:'.$dateFormat,
Expand Down Expand Up @@ -197,7 +197,7 @@
return '';
}

public function isEmpty(array|string $value): bool
public function isEmpty(array|string|null $value): bool
{
$values = [];
if (is_array($value)) {
Expand Down
18 changes: 13 additions & 5 deletions tests/Unit/Traits/Configuration/PaginationConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,18 @@ public function test_can_set_per_page_manually(): void

public function test_can_set_default_per_page(): void
{
$this->assertSame(10, $this->unpaginatedTable->getPerPage());
$this->unpaginatedTable->setDefaultPerPage(50);
$this->assertSame(50, $this->unpaginatedTable->getPerPage());
$this->unpaginatedTable->perPage = 25;
$this->assertSame(25, $this->unpaginatedTable->getPerPage());
$this->assertSame(10, $this->basicTable->getPerPage());
$this->basicTable->unsetPerPage();
$this->basicTable->setDefaultPerPage(50);
$this->assertSame(50, $this->basicTable->getDefaultPerPage());
$this->assertSame(50, $this->basicTable->getPerPage());
$this->basicTable->perPage = 25;
$this->assertSame(25, $this->basicTable->getPerPage());
$this->basicTable->setPerPage(10);
$this->assertSame(10, $this->basicTable->getPerPage());
$this->assertSame(50, $this->basicTable->getDefaultPerPage());
$this->basicTable->unsetPerPage();
$this->assertSame(50, $this->basicTable->getPerPage());

}
}
25 changes: 25 additions & 0 deletions tests/Unit/Traits/Helpers/ColumnHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers;

use Rappasoft\LaravelLivewireTables\Exceptions\NoColumnsException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Column;
Expand Down Expand Up @@ -360,4 +362,27 @@ public function test_can_check_if_column_label_has_attributes(): void
$this->assertSame(['class' => 'text-xl', 'default' => true, 'default-colors' => false, 'default-styling' => false], $column->getLabelAttributes());

}

public function test_throws_error_if_no_columns_are_defined(): void
{
$this->expectException(NoColumnsException::class);

$testTable = new class extends PetsTable
{
public function columns(): array
{
return [];
}
};

$testTable->configure();
$testTable->boot();
$testTable->bootedComponentUtilities();
$testTable->bootedWithData();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

}
}
98 changes: 98 additions & 0 deletions tests/Unit/Traits/Helpers/ColumnSelectHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers;

use Illuminate\Support\Facades\Event;
use Rappasoft\LaravelLivewireTables\Events\ColumnsSelected;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

final class ColumnSelectHelpersTest extends TestCase
Expand Down Expand Up @@ -103,4 +106,99 @@ public function test_get_currently_selected_cols_works(): void
$this->assertSame(8, count($this->basicTable->getDefaultVisibleColumns()));

}

public function test_event_fires_for_columnselect(): void
{
Event::fake();

$testTable = new class extends PetsTable
{
public function configure(): void
{
parent::configure();
}
};
$testTable->configure();
$testTable->boot();
$testTable->bootedComponentUtilities();
$testTable->bootedWithData();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);

$testTable->disableColumnSelectEvent();
$testTable->selectedColumns = ['id', 'sort', 'name', 'age', 'breed', 'other', 'rowimg'];
$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'rowimg'], $testTable->selectedColumns);
$testTable->updatedSelectedColumns();
Event::assertNotDispatched(ColumnsSelected::class);

$testTable->enableColumnSelectEvent();

$testTable->selectedColumns = ['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'];
$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
$testTable->updatedSelectedColumns();
Event::assertDispatched(ColumnsSelected::class);

}

public function test_event_does_fire_for_columnselect(): void
{
Event::fake();

$testTable = new class extends PetsTable
{
public function configure(): void
{
parent::configure();
$this->enableColumnSelectEvent();
}
};
$testTable->configure();
$testTable->boot();
$testTable->bootedComponentUtilities();
$testTable->bootedWithData();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);

$testTable->selectedColumns = ['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'];
$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
$testTable->updatedSelectedColumns();
Event::assertDispatched(ColumnsSelected::class);

}

public function test_event_does_not_fire_for_columnselect(): void
{
Event::fake();

$testTable = new class extends PetsTable
{
public function configure(): void
{
parent::configure();
$this->disableColumnSelectEvent();
}
};
$testTable->configure();
$testTable->boot();
$testTable->bootedComponentUtilities();
$testTable->bootedWithData();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
$testTable->selectedColumns = ['id', 'sort', 'name', 'age', 'breed', 'other', 'rowimg'];
$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'rowimg'], $testTable->selectedColumns);
$testTable->updatedSelectedColumns();
Event::assertNotDispatched(ColumnsSelected::class);
}
}
Loading
Loading