Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
01b6824
Add Tests
lrljoe Dec 16, 2024
d235860
Add Missing Test
lrljoe Dec 16, 2024
1e5d809
Add label fixes
lrljoe Dec 16, 2024
1f889cb
Fix styling
lrljoe Dec 16, 2024
493959c
Merge pull request #2130 from LowerRockLabs/AddIsSortableTestTweak
lrljoe Dec 16, 2024
4bb6b3d
Add Custom FIlter Input Attributes, Cleanup Filter Tests (#2131)
lrljoe Dec 24, 2024
ab35e6c
Enable InputAttributes for SelectFilter (#2133)
lrljoe Dec 24, 2024
eda4c5e
Tidy ComponentUtilities, Migrate ColumnSelectQueryString (#2135)
lrljoe Dec 26, 2024
c67247b
TH Fixes - Clean-up, efficiency, and Sort Icons fixes (#2140)
lrljoe Dec 31, 2024
1d991b2
Ensure Default Sorting Is Shown in Pills (#2138)
lrljoe Dec 31, 2024
660c061
Add hasCollapsedColumns as Computed (#2141)
lrljoe Dec 31, 2024
fe3abd6
Separate the Unit and Visuals Test Suites (#2144)
lrljoe Jan 4, 2025
b819109
Tidy up Blade Class Definitions (#2145)
lrljoe Jan 4, 2025
4125285
Move Filters Before Query (#2143)
lrljoe Jan 4, 2025
d17464b
Migrate Filter Code Appropriately (#2146)
lrljoe Jan 4, 2025
567b9da
Migrate Filter Status into Own Trait (#2147)
lrljoe Jan 4, 2025
15e18fb
Update PCOV Workflow (#2148)
lrljoe Jan 4, 2025
3f71383
Add configurable area test (#2149)
lrljoe Jan 5, 2025
41c0bd0
Tidy ColumnSelectHelpers & displayToolbarFilters Method (#2150)
lrljoe Jan 6, 2025
16a3590
Add SortingConfiguration Missing Test (#2151)
lrljoe Jan 6, 2025
50226f7
Add Missing Search Tests (#2152)
lrljoe Jan 6, 2025
3d279b9
Adjust SearchHelpersTest (#2153)
lrljoe Jan 6, 2025
8910778
Add test queryStringWithQueryString (#2154)
lrljoe Jan 6, 2025
940e0ac
Add missing tests (#2157)
lrljoe Jan 7, 2025
26f094b
Tidy & Improve Collapsed Columns Behaviour (#2159)
lrljoe Jan 8, 2025
f17a0d8
Tidy computed properties behaviour (#2160)
lrljoe Jan 8, 2025
2368708
Add queryStringAliasTest (#2161)
lrljoe Jan 8, 2025
a57de60
Add missing Columns Non Computed Test (#2162)
lrljoe Jan 8, 2025
6d7b59b
WithSearch Tweaks (#2163)
lrljoe Jan 8, 2025
2ecd092
Optimize Header/Footer (#2164)
lrljoe Jan 8, 2025
1d83e0e
Migrate LivewireComponentColumn methods and add some missing basic te…
lrljoe Jan 11, 2025
19b3723
Clean up Column Component View and Slot behaviours (#2169)
lrljoe Jan 11, 2025
8dc509c
Add initial tests for LivewireComponentArrayFilter (#2170)
lrljoe Jan 11, 2025
d1f6a2e
Update ChangeLog (#2171)
lrljoe Jan 11, 2025
4761dfe
Tweak tests - centralised (#2172)
lrljoe Jan 11, 2025
fe00cff
Adjustments for ComponentColumn (#2173)
lrljoe Jan 11, 2025
6598b25
Update ChangeLog
lrljoe Jan 11, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests-pcov-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run Unit Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml
run: php ./vendor/bin/phpunit --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml --testsuite "Laravel Livewire Tables Unit Test Suite","Laravel Livewire Tables Visuals Test Suite"

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/run-tests-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 3
max-parallel: 2
matrix:
os: [ubuntu-latest]
php: [8.1, 8.2, 8.3, 8.4]
php: [8.2, 8.3, 8.4]
laravel: [10.*]
stability: [prefer-dist]

Expand Down Expand Up @@ -85,8 +85,10 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run Unit Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage
run: php ./vendor/bin/paratest --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage

- name: Run Visuals Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Visuals Test Suite" --no-coverage

test-laravel11:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -166,4 +168,7 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run Unit Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage
run: php ./vendor/bin/paratest --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage

- name: Run Visuals Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Visuals Test Suite" --no-coverage
13 changes: 9 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 3
max-parallel: 2
matrix:
os: [ubuntu-24.04]
php: [8.1, 8.2, 8.3, 8.4]
php: [8.2, 8.3, 8.4]
laravel: [10.*]
stability: [prefer-dist]

Expand Down Expand Up @@ -87,8 +87,10 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run Unit Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage
run: php ./vendor/bin/paratest --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage

- name: Run Visuals Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Visuals Test Suite" --no-coverage

test-laravel11:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -168,4 +170,7 @@ jobs:
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run Unit Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage
run: php ./vendor/bin/paratest --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage

- name: Run Visuals Tests
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Visuals Test Suite" --no-coverage
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

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


## [v3.6.0] - UNRELEASED

### Bug Fixes
- Ensure Default Sorting Is Shown in Pills by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2138
- Filters
- Find Filters Before Query by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2143
- Migrate Filter Code Appropriately by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2146
- Migrate Filter Status into Own Trait by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2147

### Tweaks
- Enable InputAttributes for SelectFilter by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2133
- Tidy ComponentUtilities, Migrate ColumnSelectQueryString by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2135
- TH Fixes - Clean-up, efficiency, and Sort Icons fixes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2140
- Add hasCollapsedColumns as Computed by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2141
- Tidy up Blade Class Definitions by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2145
- Tidy ColumnSelectHelpers & displayToolbarFilters Method by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2150
- Tidy & Improve Collapsed Columns Behaviour by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2159
- Tidy computed properties behaviour by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2160
- WithSearch Tweaks by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2163
- Optimize Header/Footer by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2164
- Clean up Column Component View and Slot behaviours by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2169
- Adjustments for ComponentColumn - cleaning up behaviours by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2173

### Testing
- Add Missing Test for getCustomSortingPillDirectionsLabel with invalid direction by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2130
- Add Custom FIlter Input Attributes, Cleanup Filter Tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2131
- Separate the Unit and Visuals Test Suites by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2144
- Update PCOV Workflow by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2148
- Add configurable area test by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2149
- Add SortingConfiguration Missing Test by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2151
- Add Missing Search Tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2152
- Adjust SearchHelpersTest by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2153
- Add test queryStringWithQueryString by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2154
- Add missing tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2157
- Add queryStringAliasTest by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2161
- Migrate LivewireComponentColumn methods and add some missing basic tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2168
- Add initial tests for LivewireComponentArrayFilter by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2170
- Improve centralisation of tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2172

## [v3.5.10] - 2024-12-11
### Tweaks
- Migrate additional Styling into separate traits by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2127
Expand Down
46 changes: 46 additions & 0 deletions docs/filter-types/filters-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ weight: 9

Number filters are just HTML number inputs.

```php
public function filters(): array
{
return [
NumberFilter::make('Amount')
->filter(function(Builder $builder, string $value) {
$builder->where('amount', '<', $value);
}),
];
}
```

Historically, min/max/placeholders were set using the "config" option, which is still available. However, it is strongly recommended to use the new setInputAttributes for enhanced customisation.

## Old Behaviour
The following would:
- Set a min of 0
- Set a max of 100
- Add a placeholder
- Keep the default colors & styling

```php
public function filters(): array
{
Expand All @@ -21,3 +42,28 @@ public function filters(): array
];
}
```

## New Behaviour
The following would:
- Set a min of 5
- Set a max of 20
- Set steps to be 0.5
- Add a placeholder
- Keep the default colors & styling

```php
public function filters(): array
{
return [
NumberFilter::make('Age')
->setInputAttributes([
'min' => '5', // Minimum Value Accepted
'max' => '20', // Maximum Value Accepted
'step' => '0.5', // Set step
'placeholder' => 'Enter Number 0 - 100', // A placeholder value
'default-colors' => true,
'default-styling' => true,
]),
];
}
```
52 changes: 52 additions & 0 deletions docs/filters/available-filter-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,58 @@ TextFilter::make('Name')
),
```

## setInputAttributes
Allows for customising the attributes that will apply to the input field for the filter.

By default, this replaces the default classes on the Filter Input, if you would like to keep them, set the default-styling and/or default-colors flags to true.

### TextFilter Example
The following would:
- Set a maxlength of 75
- Set a placeholder of "Enter a Name"
- Replace the default colors
- Retain the default styling (e.g. rounding/shadow)

```php
public function filters(): array
{
return [
TextFilter::make('Name')
->setInputAttributes([
'maxlength' => '75',
'placeholder' => 'Enter a Name',
'class' => 'text-white bg-red-500 dark:bg-red-500',
'default-colors' => false,
'default-styling' => true,
]),
];
}
```

### NumberFilter Example
The following would:
- Set a min of 5
- Set a max of 20
- Set steps to be 0.5
- Keep the default colors & styling

```php
public function filters(): array
{
return [
NumberFilter::make('Age')
->setInputAttributes([
'min' => '5',
'max' => '20',
'step' => '0.5',
'default-colors' => true,
'default-styling' => true,
]),
];
}
```


## setCustomView
Use a fully custom view for a filter. This will utilise solely your view when rendering this filter. Note that the following methods will no longer apply to a filter using this:
- setCustomFilterLabel
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<testsuite name="Laravel Livewire Tables Unit Test Suite">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Laravel Livewire Tables Visuals Test Suite">
<directory>tests/Visuals</directory>
</testsuite>
<testsuite name="Laravel Livewire Tables Localisations Unit">
<directory>tests/Localisations/Unit</directory>
</testsuite>
Expand Down
20 changes: 11 additions & 9 deletions resources/views/components/includes/actions.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<div {{ $attributes
->merge($this->getActionWrapperAttributes)
->class(['flex flex-cols py-2 space-x-2' => $this->isTailwind && $this->getActionWrapperAttributes['default-styling'] ?? true])
->class(['' => $this->isTailwind && $this->getActionWrapperAttributes['default-colors'] ?? true])
->class(['d-flex flex-cols py-2 space-x-2' => $this->isBootstrap && $this->getActionWrapperAttributes['default-styling'] ?? true])
->class(['' => $this->isBootstrap && $this->getActionWrapperAttributes['default-colors'] ?? true])
->class(['justify-start' => $this->getActionsPosition === 'left'])
->class(['justify-center' => $this->getActionsPosition === 'center'])
->class(['justify-end' => $this->getActionsPosition === 'right'])
->class(['pl-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'left'])
->class(['pr-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'right'])
->class([
'flex flex-cols py-2 space-x-2' => $this->isTailwind && ($this->getActionWrapperAttributes['default-styling'] ?? true),
'' => $this->isTailwind && ($this->getActionWrapperAttributes['default-colors'] ?? true),
'd-flex flex-cols py-2 space-x-2' => $this->isBootstrap && ($this->getActionWrapperAttributes['default-styling'] ?? true),
'' => $this->isBootstrap && ($this->getActionWrapperAttributes['default-colors'] ?? true),
'justify-start' => $this->getActionsPosition === 'left',
'justify-center' => $this->getActionsPosition === 'center',
'justify-end' => $this->getActionsPosition === 'right',
'pl-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'left',
'pr-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'right',
])
->except(['default','default-styling','default-colors'])
}} >
@foreach($this->getActions as $action)
Expand Down
18 changes: 12 additions & 6 deletions resources/views/components/includes/loading.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@

<tr wire:key="{{ $tableName }}-loader" wire:loading.class.remove="hidden d-none" {{
$attributes->merge($loaderRow)
->class(['hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderRow['default'] ?? true)])
->class(['d-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderRow['default'] ?? true)])
->class([
'hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderRow['default'] ?? true),
'd-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderRow['default'] ?? true),
])
->except(['default','default-styling','default-colors'])
}}>
<td colspan="{{ $colCount }}" wire:key="{{ $tableName }}-loader-column" {{
$attributes->merge($loaderCell)
->class(['py-4' => $this->isTailwind && ($loaderCell['default'] ?? true)])
->class(['py-4' => $this->isBootstrap && ($loaderCell['default'] ?? true)])
->class([
'py-4' => $this->isTailwind && ($loaderCell['default'] ?? true),
'py-4' => $this->isBootstrap && ($loaderCell['default'] ?? true),
])
->except(['default','default-styling','default-colors', 'colspan','wire:key'])
}}>
@if($this->hasLoadingPlaceholderBlade())
Expand All @@ -25,8 +29,10 @@
<div class="h-min self-center align-middle text-center">
<div class="lds-hourglass"{{
$attributes->merge($loaderIcon)
->class(['lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true)])
->class(['lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true)])
->class([
'lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true),
'lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true),
])
->except(['default','default-styling','default-colors'])
}}></div>
<div>{!! $this->getLoadingPlaceholderContent() !!}</div>
Expand Down
12 changes: 9 additions & 3 deletions resources/views/components/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<div
wire:key="{{ $tableName }}-twrap"
{{ $attributes->merge($customAttributes['wrapper'])
->class(['shadow overflow-y-auto border-b border-gray-200 dark:border-gray-700 sm:rounded-lg' => $customAttributes['wrapper']['default'] ?? true])
->class([
'shadow overflow-y-auto border-b border-gray-200 dark:border-gray-700 sm:rounded-lg' => $customAttributes['wrapper']['default'] ?? true
])
->except(['default','default-styling','default-colors']) }}
>
<table
Expand All @@ -25,7 +27,9 @@
>
<thead wire:key="{{ $tableName }}-thead"
{{ $attributes->merge($customAttributes['thead'])
->class(['bg-gray-50 dark:bg-gray-800' => $customAttributes['thead']['default'] ?? true])
->class([
'bg-gray-50 dark:bg-gray-800' => $customAttributes['thead']['default'] ?? true
])
->except(['default','default-styling','default-colors']) }}
>
<tr>
Expand All @@ -37,7 +41,9 @@
wire:key="{{ $tableName }}-tbody"
id="{{ $tableName }}-tbody"
{{ $attributes->merge($customAttributes['tbody'])
->class(['bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-none' => $customAttributes['tbody']['default'] ?? true])
->class([
'bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-none' => $customAttributes['tbody']['default'] ?? true
])
->except(['default','default-styling','default-colors']) }}
>
{{ $slot }}
Expand Down
Loading
Loading