Skip to content

Commit

Permalink
Merge pull request #2174 from rappasoft/development
Browse files Browse the repository at this point in the history
Development to Master for 3.6.0
  • Loading branch information
lrljoe authored Jan 16, 2025
2 parents 692d780 + 6598b25 commit 28cc21a
Show file tree
Hide file tree
Showing 214 changed files with 4,702 additions and 3,739 deletions.
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

0 comments on commit 28cc21a

Please sign in to comment.