From 20a74a696e7ca9728d334f7c22e826949536af71 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Tue, 10 Dec 2024 20:52:04 +0000 Subject: [PATCH] v3.5.8 Development to Master (#2125) ## [v3.5.8] - 2024-12-10 ### New Features - Set bulk action row button attributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2117 - Add setFilterSlidedownWrapperAttributes and setFilterSlidedownRowAttributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2120 ### Bug Fixes - Respect setDisplayPaginationDetailsDisabled for unpaginated tables by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2119 ### Localisation - Added neccessary files for Farsi translation by @AmirMehrabi in https://github.com/rappasoft/laravel-livewire-tables/pull/2100 ### Testing - Workflow Adjustments by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2108 - Add extra Search Lazy Tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2107 - Restore Missing Lazy Search Tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2106 - Ignore WithEvents Coverage by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2105 - Add missing tests for WithCustomisations by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2104 - Add missing LivewireComponentFilterTest and BooleanFilterTest by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2121 --- .github/workflows/discord-releases.yml | 2 +- .github/workflows/run-phpstan-pull.yml | 6 +- .github/workflows/run-phpstan.yml | 6 +- .github/workflows/run-tests-pcov-pull.yml | 22 +- .github/workflows/run-tests-pull.yml | 8 +- .github/workflows/run-tests.yml | 12 +- CHANGELOG.md | 19 + CONTRIBUTORS.md | 5 +- docs/filters/available-component-methods.md | 273 +++++++++ docs/filters/available-filter-methods.md | 289 ++++++++++ docs/filters/available-methods.md | 520 +----------------- docs/filters/creating-filters.md | 2 +- docs/filters/introduction.md | 2 +- resources/lang/json/fa.json | 72 +++ resources/lang/php/fa/core.php | 41 ++ .../views/components/pagination.blade.php | 129 ++--- .../table/tr/bulk-actions.blade.php | 206 +++---- .../toolbar/items/filter-slidedown.blade.php | 48 +- src/Traits/Helpers/PaginationHelpers.php | 2 + .../BulkActionStylingConfiguration.php | 10 + .../FilterMenuStylingConfiguration.php | 20 + src/Traits/Styling/HasBulkActionsStyling.php | 2 + src/Traits/Styling/HasFilterMenuStyling.php | 4 + .../Helpers/BulkActionStylingHelpers.php | 19 + .../Helpers/FilterMenuStylingHelpers.php | 28 + .../BulkActionsStylingConfigurationTest.php | 1 + .../Styling/FilterSlidedownStylingTest.php | 92 ++++ .../Traits/Visuals/PaginationVisualsTest.php | 6 +- .../Unit/Views/Filters/BooleanFilterTest.php | 17 + .../Filters/LivewireComponentFilterTest.php | 49 ++ 30 files changed, 1129 insertions(+), 783 deletions(-) create mode 100644 docs/filters/available-component-methods.md create mode 100644 docs/filters/available-filter-methods.md create mode 100644 resources/lang/json/fa.json create mode 100644 resources/lang/php/fa/core.php create mode 100644 tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php create mode 100644 tests/Unit/Views/Filters/LivewireComponentFilterTest.php diff --git a/.github/workflows/discord-releases.yml b/.github/workflows/discord-releases.yml index 17e5ac816..236cea737 100644 --- a/.github/workflows/discord-releases.yml +++ b/.github/workflows/discord-releases.yml @@ -4,7 +4,7 @@ on: jobs: github-releases-to-discord: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/run-phpstan-pull.yml b/.github/workflows/run-phpstan-pull.yml index 9a288188b..7426e4a7a 100644 --- a/.github/workflows/run-phpstan-pull.yml +++ b/.github/workflows/run-phpstan-pull.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest] + os: [ubuntu-24.04] php: [8.3] laravel: [11] stability: [prefer-dist] @@ -20,7 +20,7 @@ jobs: name: PHPStan - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, exif, iconv, fileinfo steps: - name: Checkout code @@ -47,7 +47,7 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ env.extensions }} coverage: pcov - tools: phpunit:9.5 + tools: phpunit:11.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/run-phpstan.yml b/.github/workflows/run-phpstan.yml index 87180f167..5132a9479 100644 --- a/.github/workflows/run-phpstan.yml +++ b/.github/workflows/run-phpstan.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest] + os: [ubuntu-24.04] php: [8.3] laravel: [11] stability: [prefer-dist] @@ -23,7 +23,7 @@ jobs: name: PHPStan - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pcntl, pcov, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, exif, iconv, fileinfo steps: - name: Checkout code @@ -50,7 +50,7 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ env.extensions }} coverage: pcov - tools: phpunit:9.5 + tools: phpunit:11.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/run-tests-pcov-pull.yml b/.github/workflows/run-tests-pcov-pull.yml index 4457fb22a..0fa82ceb9 100644 --- a/.github/workflows/run-tests-pcov-pull.yml +++ b/.github/workflows/run-tests-pcov-pull.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [ubuntu-24.04] php: [8.3] laravel: [11] stability: [prefer-dist] @@ -24,7 +24,7 @@ jobs: name: PCOV - ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-withpcov - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pcov,pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pcov,pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo steps: - name: Checkout code @@ -37,7 +37,14 @@ jobs: php-version: ${{ matrix.php }} extensions: ${{ env.extensions }} key: ${{ env.extensionKey }} - + + - name: Cache extensions + uses: actions/cache@v4 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -49,13 +56,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Cache extensions - uses: actions/cache@v4 - with: - path: ${{ steps.extcache.outputs.dir }} - key: ${{ steps.extcache.outputs.key }} - restore-keys: ${{ steps.extcache.outputs.key }} - - name: Setup problem matchers for PHP run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" @@ -91,7 +91,7 @@ jobs: run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: diff --git a/.github/workflows/run-tests-pull.yml b/.github/workflows/run-tests-pull.yml index 0de41ddb2..3d81e3b8c 100644 --- a/.github/workflows/run-tests-pull.yml +++ b/.github/workflows/run-tests-pull.yml @@ -14,14 +14,14 @@ jobs: max-parallel: 3 matrix: os: [ubuntu-latest] - php: [8.1, 8.2, 8.3] + php: [8.1, 8.2, 8.3, 8.4] laravel: [10.*] stability: [prefer-dist] name: PULL PHP-${{ matrix.php }} - Laravel-10 env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo, :psr steps: - name: Checkout code @@ -95,14 +95,14 @@ jobs: max-parallel: 2 matrix: os: [ubuntu-latest] - php: [8.2, 8.3] + php: [8.2, 8.3, 8.4] laravel: [11.*] stability: [prefer-dist] name: PULL PHP-${{ matrix.php }} - Laravel-11 env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-L${{ matrix.laravel }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo, :psr steps: - name: Checkout code diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ff452e572..05ff871b9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -15,15 +15,15 @@ jobs: fail-fast: false max-parallel: 3 matrix: - os: [ubuntu-latest] - php: [8.1, 8.2, 8.3] + os: [ubuntu-24.04] + php: [8.1, 8.2, 8.3, 8.4] laravel: [10.*] stability: [prefer-dist] name: PHP-${{ matrix.php }} - Laravel-10 env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo, :psr steps: - name: Checkout code @@ -96,15 +96,15 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ubuntu-latest] - php: [8.2, 8.3] + os: [ubuntu-24.04] + php: [8.2, 8.3, 8.4] laravel: [11.*] stability: [prefer-dist] name: PHP-${{ matrix.php }} - Laravel-11 env: extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, :psr + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, fileinfo, :psr steps: - name: Checkout code diff --git a/CHANGELOG.md b/CHANGELOG.md index 93bd62c02..3f3165858 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [v3.5.8] - 2024-12-10 +### New Features +- Set bulk action row button attributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2117 +- Add setFilterSlidedownWrapperAttributes and setFilterSlidedownRowAttributes by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2120 + +### Bug Fixes +- Respect setDisplayPaginationDetailsDisabled for unpaginated tables by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2119 + +### Localisation +- Added neccessary files for Farsi translation by @AmirMehrabi in https://github.com/rappasoft/laravel-livewire-tables/pull/2100 + +### Testing +- Workflow Adjustments by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2108 +- Add extra Search Lazy Tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2107 +- Restore Missing Lazy Search Tests by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2106 +- Ignore WithEvents Coverage by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2105 +- Add missing tests for WithCustomisations by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2104 +- Add missing LivewireComponentFilterTest and BooleanFilterTest by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2121 + ## [v3.5.7] - 2024-12-01 ### New Features - IncrementColumn by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2096 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index df270ea9a..f4a2f3e2d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -12,12 +12,13 @@ | Chinese - Taiwan (TW) | None | | Danish (DA) | [jeppeolesen](https://github.com/jeppeolesen) | | Dutch (NL) | [siebsie23](https://github.com/siebsie23), [spekkie2002](https://github.com/spekkie2002), [Jerimu](https://github.com/Jerimu) | -| English (EN) | Core Team | +| English (EN) | Core Maintainers | +| Farsi (FA) | [AmirMehrabi](https://github.com/AmirMehrabi) | | Finnish (FI) | [devmikromike](https://github.com/devmikromike) | | French (FR) | [dgillier](https://github.com/dgillier), [khwadj](https://github.com/khwadj)| | German (DE) | [khwadj](https://github.com/khwadj) | | Indonesian (ID) | None | -| Italian (IT) | Core Team, [khwadj](https://github.com/khwadj) | +| Italian (IT) | Core Maintainers, [khwadj](https://github.com/khwadj) | | Malay (MS) | [wanadri](https://github.com/wanadri) | | Norwegian (NB) | [channor] (https://github.com/channor) | | Polish (PL) | [meavric](https://github.com/meavric) | diff --git a/docs/filters/available-component-methods.md b/docs/filters/available-component-methods.md new file mode 100644 index 000000000..9a463edbf --- /dev/null +++ b/docs/filters/available-component-methods.md @@ -0,0 +1,273 @@ +--- +title: Available Component Methods +weight: 5 +--- + +These are the available filters configuration methods on the component. These are "table-wide" methods. + +--- + +Filters are **enabled by default** but will only show up if you have at least one defined. + +## setFiltersStatus + +Enable/disable filters for the whole component. + +```php +public function configure(): void +{ + $this->setFiltersStatus(true); + $this->setFiltersStatus(false); +} +``` + +## setFiltersEnabled + +Enable filters for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFiltersStatus(true) + $this->setFiltersEnabled(); +} +``` + +## setFiltersDisabled + +Disable filters for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFiltersStatus(false) + $this->setFiltersDisabled(); +} +``` + +--- + +## setFiltersVisibilityStatus + +**Enabled by default**, show/hide the filters dropdown. + +```php +public function configure(): void +{ + $this->setFiltersVisibilityStatus(true); + $this->setFiltersVisibilityStatus(false); +} +``` + +## setFiltersVisibilityEnabled + +Show the filters dropdown for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFiltersVisibilityStatus(true) + $this->setFiltersVisibilityEnabled(); +} +``` + +## setFiltersVisibilityDisabled + +Hide the filters dropdown for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFiltersVisibilityStatus(false) + $this->setFiltersVisibilityDisabled(); +} +``` + +--- + +## setFilterPillsStatus + +**Enabled by default**, show/hide the filter pills. + +```php +public function configure(): void +{ + $this->setFilterPillsStatus(true); + $this->setFilterPillsStatus(false); +} +``` + +## setFilterPillsEnabled + +Show the filter pills for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFilterPillsStatus(true) + $this->setFilterPillsEnabled(); +} +``` + +## setFilterPillsDisabled + +Hide the filter pills for the component. + +```php +public function configure(): void +{ + // Shorthand for $this->setFilterPillsStatus(false) + $this->setFilterPillsDisabled(); +} +``` + +--- + +## setFilterLayout + +Set the filter layout for the component. + +```php +public function configure(): void +{ + $this->setFilterLayout('slide-down'); +} +``` + +## setFilterLayoutPopover + +Set the filter layout to popover. + +```php +public function configure(): void +{ + $this->setFilterLayoutPopover(); +} +``` + +Set the filter layout to slide down. + +## setFilterLayoutSlideDown + +```php +public function configure(): void +{ + $this->setFilterLayoutSlideDown(); +} +``` + +## setFilterSlideDownDefaultStatusEnabled + +Set the filter slide down to visible by default + +```php +public function configure(): void +{ + // Shorthand for $this->setFilterSlideDownDefaultStatus(true) + $this->setFilterSlideDownDefaultStatusEnabled(); +} +``` + +## setFilterSlideDownDefaultStatusDisabled + +Set the filter slide down to collapsed by default + +```php +public function configure(): void +{ + // Shorthand for $this->setFilterSlideDownDefaultStatus(false) + $this->setFilterSlideDownDefaultStatusDisabled(); +} +``` + +## storeFiltersInSessionEnabled + +Optional behaviour - stores filter values in the session (specific to table - based on the table name) + +### Exercise Caution +If re-using the same Livewire Table Component multiple times in your site, with the same table name, this may cause clashes in filter values + +```php +public function configure(): void +{ + $this->storeFiltersInSessionEnabled(); +} +``` +## storeFiltersInSessionDisabled + +Default behaviour - does not store filters in the session + +```php +public function configure(): void +{ + $this->storeFiltersInSessionDisabled(); +} +``` + +## setFilterPopoverAttributes + +Allows for the customisation of the appearance of the Filter Popover Menu. + +Note the addition of a "default-width" boolean, allowing you to customise the width more smoothly without impacting other applied classes. + +You may also replace default colors by setting "default-colors" to false, or default styling by setting "default-styling" to false, and specifying replacement classes in the "class" property. + +You can also replace the default transition behaviours (Tailwind) by specifying replacement attributes in the array. + +```php +public function configure(): void +{ + $this->setFilterPopoverAttributes( + [ + 'class' => 'w-96', + 'default-width' => false, + 'default-colors' => true, + 'default-styling' => true, + 'x-transition:enter' => 'transition ease-out duration-100', + ] + ); +} +``` + +## setFilterSlidedownWrapperAttributes + +Allows for the customisation of the appearance of the Filter Slidedown Wrapper. + +You may also replace default colors by setting "default-colors" to false, or default styling by setting "default-styling" to false, and specifying replacement classes in the "class" property. + +You can also replace the default transition behaviours (Tailwind) by specifying replacement attributes in the array, for example to extend the duration of the transition effect from the default duration-100 to duration-1000: + +```php +public function configure(): void +{ + $this->setFilterSlidedownWrapperAttributes([ + 'x-transition:enter' => 'transition ease-out duration-1000', + 'class' => 'text-black', + 'default-colors' => true, + 'default-styling' => true, + ]); +} +``` + +## setFilterSlidedownRowAttributes + +Allows for the customisation of the appearance of the Filter Slidedown Row. Note that this uses a callback, which receives the "rowIndex" of the Slidedown Row + +You may replace default colors by setting "default-colors" to false, or default styling by setting "default-styling" to false, and specifying replacement classes in the "class" property. + +```php +public function configure(): void +{ + $this->setFilterSlidedownRowAttributes(fn($rowIndex) => $rowIndex % 2 === 0 ? + [ + 'class' => 'bg-red-500', + 'default-colors' => true, + 'default-styling' => true, + ] : [ + 'class' => 'bg-blue-500', + 'default-colors' => true, + 'default-styling' => true, + ] + ); +} +``` diff --git a/docs/filters/available-filter-methods.md b/docs/filters/available-filter-methods.md new file mode 100644 index 000000000..6e17a63b4 --- /dev/null +++ b/docs/filters/available-filter-methods.md @@ -0,0 +1,289 @@ +--- +title: Available Filter Methods +weight: 6 +--- + +The following methods are available on the filter object. These are "filter-specific" methods. + +---- + +## setFilterPillTitle + +By default, the filter pill title is the filter name, but you can make it whatever you want: + +```php +SelectFilter::make('Active') + ->setFilterPillTitle('User Status') +``` + +## setFilterPillValues + +If you have numeric, or generated keys as your filter option values, they probably don't look too nice in the filter pill. You can set the values to be displayed in the filter pill: + +```php +SelectFilter::make('Active') + ->setFilterPillTitle('User Status') + ->setFilterPillValues([ + '1' => 'Active', + '0' => 'Inactive', + ]) + ->options([ + '' => 'All', + '1' => 'Yes', + '0' => 'No', + ]) +``` + +Now instead of `Active: Yes` it will say `User Status: Active` + +## hiddenFromMenus + +Hide the filter from both the filter popover and the filter slide down. + +```php +SelectFilter::make('Active') + ->hiddenFromMenus() +``` + +## hiddenFromPills + +Hide the filter from the filter pills when applied. + +```php +SelectFilter::make('Active') + ->hiddenFromPills() +``` + +## hiddenFromFilterCount + +Hide the filter from the filter count when applied. + +```php +SelectFilter::make('Active') + ->hiddenFromFilterCount() +``` + +## hiddenFromAll + +Hide the filter from the menus, pills, and count. + +```php +SelectFilter::make('Active') + ->hiddenFromAll() +``` + +## notResetByClearButton + +By default the `clear` button will reset all filters to their defaults. You can prevent this on a specific filter by using this method. + +```php +SelectFilter::make('Active') + ->notResetByClearButton() +``` + +## setFilterSlidedownRow + +This method applies only when using the Slide Down approach to filter display. +By default the filters will be displayed in the order that they are listed in the filters() method. This method allows you to specify the row that the filter will be listed. When multiple filters are placed on the same row, and a mobile device is used, then the first filter listed will "win" that row. +You may use either a string or an integer to pass to this method, and it can be used in conjunction with setFilterSlidedownColspan + +```php +SelectFilter::make('Active') + ->setFilterSlidedownRow(1) +``` + +## setFilterSlidedownColspan + +This method applies only when using the Slide Down approach to filter display. +By default each filter will take up one column, with the number of columns determined by the size of the screen, this ranges from 1 on a mobile device, to a maximum of 5 on a large display. This method allows you to specify the number of columns that the filter should span. It will span the number of columns specified, up to the number of columns available (depending on screen size). +You may use either a string or an integer to pass to this method, and it can be used in conjunction with setFilterSlidedownRow + +```php +DateFilter::make('Date') + ->config([ + 'min' => '2020-01-01', + 'max' => '2021-12-31', + ]) + ->setFilterSlidedownColspan('2') +``` + +## setFilterPillBlade + +Set a blade file for use in displaying the filter values in the pills area. You can use this in conjunction with setFilterPillValues() to prettify your applied filter values display. You will receive two properties ($filter) containing the filter instance, and ($value) containing the filter value. + +```php +SelectFilter::make('Active') + ->setFilterPillBlade('path.to.blade') +``` + +Example blade: +```php +@aware(['component']) +@props(['filter']) + + + {{ $filter->getFilterPillTitle() }} - ({{ $filter->getFilterPillValue($value) }}) + + + +``` + +## setCustomFilterLabel + +Set a custom blade file for the filter's label. This will be used in both the Pop-Over and SlideDown filter displays, you should therefore ensure that you cater for the different filter layouts. + +```php +SelectFilter::make('Active') + ->setCustomFilterLabel('path.to.blade') +``` + +You will receive several properties to your blade, explained here: +- $filter (the filter instance) +- $filterLayout ('slide-down' or 'popover') +- $tableName (the table name) +- $isTailwind (bool - is theme Tailwind) +- $isBootstrap (bool - is theme Bootstrap 4 or Bootstrap 5) +- $isBootstrap4 (bool - is theme Bootstrap 4) +- $isBootstrap5 (bool - is theme Bootstrap 5) +- $customLabelAttributes (array -> any customLabel attributes set using setFilterLabelAttributes()) + +Example label blade: +```php +@props(['filter', 'filterLayout' => 'popover', 'tableName' => 'table', 'isTailwind' => false, 'isBootstrap' => false, 'isBootstrap4' => false, 'isBootstrap5' => false, 'customLabelAttributes' => []]) + + + +``` + +## setFilterLabelAttributes + +### Old Method (Still Supported) +Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. + +By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. + +```php +TextFilter::make('Name') + ->setFilterLabelAttributes( + [ + 'class' => 'text-xl', + 'default' => true, + ] + ), +``` + +### New Method (Recommended) +Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. + +By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. + +```php +TextFilter::make('Name') + ->setLabelAttributes( + [ + 'class' => 'text-xl', + 'default' => 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 +- setFilterLabelAttributes + +```php +TextFilter::make('Name') + ->setCustomView('text-custom-view'), +``` + +## Config + +If the filter takes any config options, you can set them with the `config` method: + +```php + DateFilter::make('Date') + ->config([ + 'min' => '2020-01-01', + 'max' => '2021-12-31', + ]) +``` + +## Customising Wireable Behaviour + +For the following Filters, you may customise how the input is wire:model into the Table Component: + +- DateFilter (Defaults to Live) +- DateTimeFilter (Defaults to Live) +- MultiSelectDropdownFilter (Defaults to live.debounce.250ms) +- MultiSelectFilter (Defaults to live.debounce.250ms) +- NumberFilter (Defaults to Blur) +- SelectFilter (Defaults to Live) +- TextFilter (Defaults to Blur) + +You may override this using the following methods, on any of the above Filter types: + +### setWireBlur() +Forces the filter to use a wire:model.blur approach +```php + TextFilter::make('Name') + ->config([ + 'placeholder' => 'Search Name', + 'maxlength' => '25', + ]) + ->setWireBlur() +``` + +### setWireDefer() +Forces the filter to use a wire:model approach +```php + TextFilter::make('Name') + ->config([ + 'placeholder' => 'Search Name', + 'maxlength' => '25', + ]) + ->setWireDefer() +``` + +### setWireLive() +Forces the fitler to use a wire:model.live approach +```php + TextFilter::make('Name') + ->config([ + 'placeholder' => 'Search Name', + 'maxlength' => '25', + ]) + ->setWireLive() +``` + +### setWireDebounce(int $debounceDelay) +Allows you to pass a string to use a wire:model.live.debounce.Xms approach +```php + TextFilter::make('Name') + ->config([ + 'placeholder' => 'Search Name', + 'maxlength' => '25', + ]) + ->setWireDebounce(50) +``` diff --git a/docs/filters/available-methods.md b/docs/filters/available-methods.md index 820916003..2fd27f523 100644 --- a/docs/filters/available-methods.md +++ b/docs/filters/available-methods.md @@ -3,521 +3,7 @@ title: Available Methods weight: 4 --- -## Component Methods +The documentation has now been split into two sections to enhance clarity. -These are the available filters configuration methods on the component. - ---- - -Filters are **enabled by default** but will only show up if you have at least one defined. - -### setFiltersStatus - -Enable/disable filters for the whole component. - -```php -public function configure(): void -{ - $this->setFiltersStatus(true); - $this->setFiltersStatus(false); -} -``` - -### setFiltersEnabled - -Enable filters for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFiltersStatus(true) - $this->setFiltersEnabled(); -} -``` - -### setFiltersDisabled - -Disable filters for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFiltersStatus(false) - $this->setFiltersDisabled(); -} -``` - ---- - -### setFiltersVisibilityStatus - -**Enabled by default**, show/hide the filters dropdown. - -```php -public function configure(): void -{ - $this->setFiltersVisibilityStatus(true); - $this->setFiltersVisibilityStatus(false); -} -``` - -### setFiltersVisibilityEnabled - -Show the filters dropdown for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFiltersVisibilityStatus(true) - $this->setFiltersVisibilityEnabled(); -} -``` - -### setFiltersVisibilityDisabled - -Hide the filters dropdown for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFiltersVisibilityStatus(false) - $this->setFiltersVisibilityDisabled(); -} -``` - ---- - -### setFilterPillsStatus - -**Enabled by default**, show/hide the filter pills. - -```php -public function configure(): void -{ - $this->setFilterPillsStatus(true); - $this->setFilterPillsStatus(false); -} -``` - -### setFilterPillsEnabled - -Show the filter pills for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFilterPillsStatus(true) - $this->setFilterPillsEnabled(); -} -``` - -### setFilterPillsDisabled - -Hide the filter pills for the component. - -```php -public function configure(): void -{ - // Shorthand for $this->setFilterPillsStatus(false) - $this->setFilterPillsDisabled(); -} -``` - ---- - -### setFilterLayout - -Set the filter layout for the component. - -```php -public function configure(): void -{ - $this->setFilterLayout('slide-down'); -} -``` - -### setFilterLayoutPopover - -Set the filter layout to popover. - -```php -public function configure(): void -{ - $this->setFilterLayoutPopover(); -} -``` - -Set the filter layout to slide down. - -### setFilterLayoutSlideDown - -```php -public function configure(): void -{ - $this->setFilterLayoutSlideDown(); -} -``` - -### setFilterSlideDownDefaultStatusEnabled - -Set the filter slide down to visible by default - -```php -public function configure(): void -{ - // Shorthand for $this->setFilterSlideDownDefaultStatus(true) - $this->setFilterSlideDownDefaultStatusEnabled(); -} -``` - -### setFilterSlideDownDefaultStatusDisabled - -Set the filter slide down to collapsed by default - -```php -public function configure(): void -{ - // Shorthand for $this->setFilterSlideDownDefaultStatus(false) - $this->setFilterSlideDownDefaultStatusDisabled(); -} -``` - -### storeFiltersInSessionEnabled - -Optional behaviour - stores filter values in the session (specific to table - based on the table name) - -#### Exercise Caution -If re-using the same Livewire Table Component multiple times in your site, with the same table name, this may cause clashes in filter values - -```php -public function configure(): void -{ - $this->storeFiltersInSessionEnabled(); -} -``` -### storeFiltersInSessionDisabled - -Default behaviour - does not store filters in the session - -```php -public function configure(): void -{ - $this->storeFiltersInSessionDisabled(); -} -``` - -### setFilterPopoverAttributes - -Allows for the customisation of the appearance of the Filter Popover Menu. - -Note the addition of a "default-width" boolean, allowing you to customise the width more smoothly without impacting other applied classes. - -You may also replace default colors by setting "default-colors" to false, or default styling by setting "default-styling" to false, and specifying replacement classes in the "class" property. - -You can also replace the default transition behaviours (Tailwind) by specifying replacement attributes in the array. - -```php -public function configure(): void -{ - $this->setFilterPopoverAttributes( - [ - 'class' => 'w-96', - 'default-width' => false, - 'default-colors' => true, - 'default-styling' => true, - 'x-transition:enter' => 'transition ease-out duration-100', - ] - ); -} -``` - ----- - -## Filter Methods - -The following methods are available on the filter object. - ----- - -### setFilterPillTitle - -By default, the filter pill title is the filter name, but you can make it whatever you want: - -```php -SelectFilter::make('Active') - ->setFilterPillTitle('User Status') -``` - -### setFilterPillValues - -If you have numeric, or generated keys as your filter option values, they probably don't look too nice in the filter pill. You can set the values to be displayed in the filter pill: - -```php -SelectFilter::make('Active') - ->setFilterPillTitle('User Status') - ->setFilterPillValues([ - '1' => 'Active', - '0' => 'Inactive', - ]) - ->options([ - '' => 'All', - '1' => 'Yes', - '0' => 'No', - ]) -``` - -Now instead of `Active: Yes` it will say `User Status: Active` - -### hiddenFromMenus - -Hide the filter from both the filter popover and the filter slide down. - -```php -SelectFilter::make('Active') - ->hiddenFromMenus() -``` - -### hiddenFromPills - -Hide the filter from the filter pills when applied. - -```php -SelectFilter::make('Active') - ->hiddenFromPills() -``` - -### hiddenFromFilterCount - -Hide the filter from the filter count when applied. - -```php -SelectFilter::make('Active') - ->hiddenFromFilterCount() -``` - -### hiddenFromAll - -Hide the filter from the menus, pills, and count. - -```php -SelectFilter::make('Active') - ->hiddenFromAll() -``` - -### notResetByClearButton - -By default the `clear` button will reset all filters to their defaults. You can prevent this on a specific filter by using this method. - -```php -SelectFilter::make('Active') - ->notResetByClearButton() -``` - -### setFilterSlidedownRow - -This method applies only when using the Slide Down approach to filter display. -By default the filters will be displayed in the order that they are listed in the filters() method. This method allows you to specify the row that the filter will be listed. When multiple filters are placed on the same row, and a mobile device is used, then the first filter listed will "win" that row. -You may use either a string or an integer to pass to this method, and it can be used in conjunction with setFilterSlidedownColspan - -```php -SelectFilter::make('Active') - ->setFilterSlidedownRow(1) -``` - -### setFilterSlidedownColspan - -This method applies only when using the Slide Down approach to filter display. -By default each filter will take up one column, with the number of columns determined by the size of the screen, this ranges from 1 on a mobile device, to a maximum of 5 on a large display. This method allows you to specify the number of columns that the filter should span. It will span the number of columns specified, up to the number of columns available (depending on screen size). -You may use either a string or an integer to pass to this method, and it can be used in conjunction with setFilterSlidedownRow - -```php -DateFilter::make('Date') - ->config([ - 'min' => '2020-01-01', - 'max' => '2021-12-31', - ]) - ->setFilterSlidedownColspan('2') -``` - -### setFilterPillBlade - -Set a blade file for use in displaying the filter values in the pills area. You can use this in conjunction with setFilterPillValues() to prettify your applied filter values display. You will receive two properties ($filter) containing the filter instance, and ($value) containing the filter value. - -```php -SelectFilter::make('Active') - ->setFilterPillBlade('path.to.blade') -``` - -Example blade: -```php -@aware(['component']) -@props(['filter']) - - - {{ $filter->getFilterPillTitle() }} - ({{ $filter->getFilterPillValue($value) }}) - - - -``` - -### setCustomFilterLabel - -Set a custom blade file for the filter's label. This will be used in both the Pop-Over and SlideDown filter displays, you should therefore ensure that you cater for the different filter layouts. - -```php -SelectFilter::make('Active') - ->setCustomFilterLabel('path.to.blade') -``` - -You will receive several properties to your blade, explained here: -- $filter (the filter instance) -- $filterLayout ('slide-down' or 'popover') -- $tableName (the table name) -- $isTailwind (bool - is theme Tailwind) -- $isBootstrap (bool - is theme Bootstrap 4 or Bootstrap 5) -- $isBootstrap4 (bool - is theme Bootstrap 4) -- $isBootstrap5 (bool - is theme Bootstrap 5) -- $customLabelAttributes (array -> any customLabel attributes set using setFilterLabelAttributes()) - -Example label blade: -```php -@props(['filter', 'filterLayout' => 'popover', 'tableName' => 'table', 'isTailwind' => false, 'isBootstrap' => false, 'isBootstrap4' => false, 'isBootstrap5' => false, 'customLabelAttributes' => []) - - - -``` - -### setFilterLabelAttributes - -#### Old Method (Still Supported) -Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. - -By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. - -```php -TextFilter::make('Name') - ->setFilterLabelAttributes( - [ - 'class' => 'text-xl', - 'default' => true, - ] - ), -``` - -#### New Method (Recommended) -Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts. - -By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true. - -```php -TextFilter::make('Name') - ->setLabelAttributes( - [ - 'class' => 'text-xl', - 'default' => 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 -- setFilterLabelAttributes - -```php -TextFilter::make('Name') - ->setCustomView('text-custom-view'), -``` - -### Config - -If the filter takes any config options, you can set them with the `config` method: - -```php - DateFilter::make('Date') - ->config([ - 'min' => '2020-01-01', - 'max' => '2021-12-31', - ]) -``` - -### Customising Wireable Behaviour - -For the following Filters, you may customise how the input is wire:model into the Table Component: - -- DateFilter (Defaults to Live) -- DateTimeFilter (Defaults to Live) -- MultiSelectDropdownFilter (Defaults to live.debounce.250ms) -- MultiSelectFilter (Defaults to live.debounce.250ms) -- NumberFilter (Defaults to Blur) -- SelectFilter (Defaults to Live) -- TextFilter (Defaults to Blur) - -You may override this using the following methods, on any of the above Filter types: - -#### setWireBlur() -Forces the filter to use a wire:model.blur approach -```php - TextFilter::make('Name') - ->config([ - 'placeholder' => 'Search Name', - 'maxlength' => '25', - ]) - ->setWireBlur() -``` - -#### setWireDefer() -Forces the filter to use a wire:model approach -```php - TextFilter::make('Name') - ->config([ - 'placeholder' => 'Search Name', - 'maxlength' => '25', - ]) - ->setWireDefer() -``` - -#### setWireLive() -Forces the fitler to use a wire:model.live approach -```php - TextFilter::make('Name') - ->config([ - 'placeholder' => 'Search Name', - 'maxlength' => '25', - ]) - ->setWireLive() -``` - -#### setWireDebounce(int $debounceDelay) -Allows you to pass a string to use a wire:model.live.debounce.Xms approach -```php - TextFilter::make('Name') - ->config([ - 'placeholder' => 'Search Name', - 'maxlength' => '25', - ]) - ->setWireDebounce(50) -``` +Documentation for Available Component Methods is now: [Here](./available-component-methods) +Documentation for Available Filter Methods is now: [Here](./available-filter-methods) diff --git a/docs/filters/creating-filters.md b/docs/filters/creating-filters.md index e940c5952..e13e98563 100644 --- a/docs/filters/creating-filters.md +++ b/docs/filters/creating-filters.md @@ -3,7 +3,7 @@ title: Creating Filters weight: 2 --- -To create filters, you must implement the `filters()` method on your component. +To create filters, you must implement the `filters()` method on your component, which must return an array. ```php public function filters(): array diff --git a/docs/filters/introduction.md b/docs/filters/introduction.md index 11f0d9e76..b0888514b 100644 --- a/docs/filters/introduction.md +++ b/docs/filters/introduction.md @@ -3,7 +3,7 @@ title: Introduction weight: 1 --- -Filters are a good way to narrow down your data. Version 2 has two ways to interact with filters, either by a popover menu or a slide down area. +Filters are a good way to narrow down your data. Version 2 has two ways to interact with filters, either by a popover menu or a slide down area, which are configurable on a per-table basis. ## Popover Menu diff --git a/resources/lang/json/fa.json b/resources/lang/json/fa.json new file mode 100644 index 000000000..7bcf32940 --- /dev/null +++ b/resources/lang/json/fa.json @@ -0,0 +1,72 @@ +{ + "livewire-tables::All": "همه", + "livewire-tables::All Columns": "تمام ستون‌ها", + "livewire-tables::Applied Filters": "فیلترهای اعمال‌شده", + "livewire-tables::Applied Sorting": "مرتب‌سازی اعمال‌شده", + "livewire-tables::Bulk Actions": "اقدامات گروهی", + "livewire-tables::Bulk Actions Confirm": "آیا مطمئن هستید؟", + "livewire-tables::Clear": "پاک کردن", + "livewire-tables::Columns": "ستون‌ها", + "livewire-tables::Debugging Values": "مقادیر اشکال‌زدایی", + "livewire-tables::Deselect All": "لغو انتخاب همه", + "livewire-tables::Done Reordering": "مرتب‌سازی تمام شد", + "livewire-tables::Filters": "فیلترها", + "livewire-tables::loading": "در حال بارگذاری", + "livewire-tables::max": "حداکثر", + "livewire-tables::min": "حداقل", + "livewire-tables::not_applicable": "نامعتبر", + "livewire-tables::No": "خیر", + "livewire-tables::No items found. Try to broaden your search.": "موردی یافت نشد. جستجوی خود را گسترش دهید.", + "livewire-tables::of": "از", + "livewire-tables::Remove filter option": "حذف گزینه فیلتر", + "livewire-tables::Remove sort option": "حذف گزینه مرتب‌سازی", + "livewire-tables::Reorder": "دوباره مرتب کنید", + "livewire-tables::results": "نتایج", + "livewire-tables::row": "ردیف", + "livewire-tables::rows": "ردیف‌ها", + "livewire-tables::rows, do you want to select all": "ردیف‌ها، آیا می‌خواهید همه را انتخاب کنید", + "livewire-tables::Search": "جستجو", + "livewire-tables::Select All": "انتخاب همه", + "livewire-tables::Select All On Page": "انتخاب همه در صفحه", + "livewire-tables::Showing": "در حال نمایش", + "livewire-tables::to": "تا", + "livewire-tables::Yes": "بله", + "livewire-tables::You are currently selecting all": "شما در حال حاضر همه را انتخاب کرده‌اید", + "livewire-tables::You are not connected to the internet.": "شما به اینترنت متصل نیستید.", + "livewire-tables::You have selected": "شما انتخاب کرده‌اید", + "All": "همه", + "All Columns": "تمام ستون‌ها", + "Applied Filters": "فیلترهای اعمال‌شده", + "Applied Sorting": "مرتب‌سازی اعمال‌شده", + "Bulk Actions": "اقدامات گروهی", + "Bulk Actions Confirm": "آیا مطمئن هستید؟", + "Clear": "پاک کردن", + "Columns": "ستون‌ها", + "Debugging Values": "مقادیر اشکال‌زدایی", + "Deselect All": "لغو انتخاب همه", + "Done Reordering": "مرتب‌سازی تمام شد", + "Filters": "فیلترها", + "loading": "در حال بارگذاری", + "max": "حداکثر", + "min": "حداقل", + "not_applicable": "نامعتبر", + "No": "خیر", + "No items found. Try to broaden your search.": "موردی یافت نشد. جستجوی خود را گسترش دهید.", + "of": "از", + "Remove filter option": "حذف گزینه فیلتر", + "Remove sort option": "حذف گزینه مرتب‌سازی", + "Reorder": "دوباره مرتب کنید", + "results": "نتایج", + "row": "ردیف", + "rows": "ردیف‌ها", + "rows, do you want to select all": "ردیف‌ها، آیا می‌خواهید همه را انتخاب کنید", + "Search": "جستجو", + "Select All": "انتخاب همه", + "Select All On Page": "انتخاب همه در صفحه", + "Showing": "در حال نمایش", + "to": "تا", + "Yes": "بله", + "You are currently selecting all": "شما در حال حاضر همه را انتخاب کرده‌اید", + "You are not connected to the internet.": "شما به اینترنت متصل نیستید.", + "You have selected": "شما انتخاب کرده‌اید" +} \ No newline at end of file diff --git a/resources/lang/php/fa/core.php b/resources/lang/php/fa/core.php new file mode 100644 index 000000000..bf880aaeb --- /dev/null +++ b/resources/lang/php/fa/core.php @@ -0,0 +1,41 @@ + 'همه', + 'All Columns' => 'تمام ستون‌ها', + 'Applied Filters' => 'فیلترهای اعمال‌شده', + 'Applied Sorting' => 'مرتب‌سازی اعمال‌شده', + 'Bulk Actions' => 'اقدامات گروهی', + 'Bulk Actions Confirm' => 'آیا مطمئن هستید؟', + 'cancel' => 'لغو', + 'Clear' => 'پاک کردن', + 'Columns' => 'ستون‌ها', + 'Debugging Values' => 'مقادیر اشکال‌زدایی', + 'Deselect All' => 'لغو انتخاب همه', + 'Done Reordering' => 'مرتب‌سازی تمام شد', + 'Filters' => 'فیلترها', + 'loading' => 'در حال بارگذاری', + 'max' => 'حداکثر', + 'min' => 'حداقل', + 'not_applicable' => 'نامعتبر', + 'No' => 'خیر', + 'No items found, try to broaden your search' => 'موردی یافت نشد، جستجوی خود را گسترش دهید', + 'of' => 'از', + 'Remove filter option' => 'حذف گزینه فیلتر', + 'Remove sort option' => 'حذف گزینه مرتب‌سازی', + 'Reorder' => 'دوباره مرتب کنید', + 'results' => 'نتایج', + 'row' => 'ردیف', + 'rows' => 'ردیف‌ها', + 'rows, do you want to select all' => 'ردیف‌ها، آیا می‌خواهید همه را انتخاب کنید', + 'save' => 'ذخیره', + 'Search' => 'جستجو', + 'Select All' => 'انتخاب همه', + 'Select All On Page' => 'انتخاب همه در صفحه', + 'Showing' => 'در حال نمایش', + 'to' => 'تا', + 'Yes' => 'بله', + 'You are currently selecting all' => 'شما در حال حاضر همه را انتخاب کرده‌اید', + 'You are not connected to the internet' => 'شما به اینترنت متصل نیستید', + 'You have selected' => 'شما انتخاب کرده‌اید', +]; diff --git a/resources/views/components/pagination.blade.php b/resources/views/components/pagination.blade.php index 4a9ffca95..feab347e2 100644 --- a/resources/views/components/pagination.blade.php +++ b/resources/views/components/pagination.blade.php @@ -1,19 +1,16 @@ -@aware(['isTailwind','isBootstrap','isBootstrap4','isBootstrap5']) - @includeWhen( $this->hasConfigurableAreaFor('before-pagination'), $this->getConfigurableAreaFor('before-pagination'), $this->getParametersForConfigurableArea('before-pagination') ) -@if ($this->isTailwind) -
getPaginationWrapperAttributesBag() }}> - @if ($this->paginationVisibilityIsEnabled()) +
getPaginationWrapperAttributesBag() }}> + @if ($this->paginationVisibilityIsEnabled()) + @if ($this->isTailwind)
- @if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1) + @if ($this->paginationIsEnabled && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1 && $this->showPaginationDetails)

- @if($this->showPaginationDetails()) {{ __($this->getLocalisationPath.'Showing') }} {{ $this->getRows->firstItem() }} {{ __($this->getLocalisationPath.'to') }} @@ -21,44 +18,43 @@ {{ __($this->getLocalisationPath.'of') }} {{ __($this->getLocalisationPath.'results') }} - @endif

- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple')) + @elseif ($this->paginationIsEnabled && $this->isPaginationMethod('simple') && $this->showPaginationDetails)

- @if($this->showPaginationDetails()) - {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->firstItem() }} - {{ __($this->getLocalisationPath.'to') }} - {{ $this->getRows->lastItem() }} - @endif + {{ __($this->getLocalisationPath.'Showing') }} + {{ $this->getRows->firstItem() }} + {{ __($this->getLocalisationPath.'to') }} + {{ $this->getRows->lastItem() }}

- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor')) + @elseif ($this->paginationIsEnabled && $this->isPaginationMethod('cursor')) @else -

- {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() }} - {{ __($this->getLocalisationPath.'results') }} -

+ @if($this->showPaginationDetails) +

+ {{ __($this->getLocalisationPath.'Showing') }} + {{ $this->getRows->count() }} + {{ __($this->getLocalisationPath.'results') }} +

+ @endif @endif
- @if ($this->paginationIsEnabled()) + @if ($this->paginationIsEnabled) {{ $this->getRows->links('livewire-tables::specific.tailwind.'.(!$this->isPaginationMethod('standard') ? 'simple-' : '').'pagination') }} @endif
- @endif -
-@elseif ($this->isBootstrap4) -
getPaginationWrapperAttributesBag() }}> - @if ($this->paginationVisibilityIsEnabled()) - @if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1) + @else + @if ($this->paginationIsEnabled && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.pagination') }}
-
- @if($this->showPaginationDetails()) +
$this->isBootstrap4, + "text-md-end" => $this->isBootstrap5, + ])> + @if($this->showPaginationDetails) {{ __($this->getLocalisationPath.'Showing') }} {{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }} {{ __($this->getLocalisationPath.'to') }} @@ -69,14 +65,18 @@ @endif
- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple')) + @elseif ($this->paginationIsEnabled && $this->isPaginationMethod('simple'))
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }}
-
- @if($this->showPaginationDetails()) +
$this->isBootstrap4, + "text-md-end" => $this->isBootstrap5, + ])> + @if($this->showPaginationDetails) {{ __($this->getLocalisationPath.'Showing') }} {{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }} {{ __($this->getLocalisationPath.'to') }} @@ -84,7 +84,7 @@ @endif
- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor')) + @elseif ($this->paginationIsEnabled && $this->isPaginationMethod('cursor'))
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }} @@ -93,66 +93,17 @@ @else
- {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() }} - {{ __($this->getLocalisationPath.'results') }} -
-
- @endif - @endif -
-@elseif ($this->isBootstrap5) -
getPaginationWrapperAttributesBag() }} > - @if ($this->paginationVisibilityIsEnabled()) - @if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1) -
-
- {{ $this->getRows->links('livewire-tables::specific.bootstrap-4.pagination') }} -
-
- @if($this->showPaginationDetails()) - {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }} - {{ __($this->getLocalisationPath.'to') }} - {{ $this->getRows->count() ? $this->getRows->lastItem() : 0 }} - {{ __($this->getLocalisationPath.'of') }} - - {{ __($this->getLocalisationPath.'results') }} - @endif -
-
- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple')) -
-
- {{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }} -
-
- @if($this->showPaginationDetails()) - {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }} - {{ __($this->getLocalisationPath.'to') }} - {{ $this->getRows->count() ? $this->getRows->lastItem() : 0 }} + @if($this->showPaginationDetails) + {{ __($this->getLocalisationPath.'Showing') }} + {{ $this->getRows->count() }} + {{ __($this->getLocalisationPath.'results') }} @endif
- @elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor')) -
-
- {{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }} -
-
- @else -
-
- {{ __($this->getLocalisationPath.'Showing') }} - {{ $this->getRows->count() }} - {{ __($this->getLocalisationPath.'results') }} -
-
@endif @endif -
-@endif + @endif +
@includeWhen( $this->hasConfigurableAreaFor('after-pagination'), diff --git a/resources/views/components/table/tr/bulk-actions.blade.php b/resources/views/components/table/tr/bulk-actions.blade.php index 11ecc95a8..e63d18df2 100644 --- a/resources/views/components/table/tr/bulk-actions.blade.php +++ b/resources/views/components/table/tr/bulk-actions.blade.php @@ -1,4 +1,4 @@ -@aware([ 'tableName','isTailwind','isBootstrap']) +@aware([ 'tableName']) @if ($this->bulkActionsAreEnabled() && $this->hasBulkActions()) @php @@ -7,134 +7,94 @@ $simplePagination = $this->isPaginationMethod('simple'); @endphp - @if ($isTailwind) - - - - - - - - @elseif ($isBootstrap) - - - + + + + @endif diff --git a/resources/views/components/tools/toolbar/items/filter-slidedown.blade.php b/resources/views/components/tools/toolbar/items/filter-slidedown.blade.php index be507404b..123e587ec 100644 --- a/resources/views/components/tools/toolbar/items/filter-slidedown.blade.php +++ b/resources/views/components/tools/toolbar/items/filter-slidedown.blade.php @@ -1,28 +1,38 @@ @aware([ 'tableName']) @props([]) -
$this->isBootstrap, - ]) - @if($this->isTailwind) - x-transition:enter="transition ease-out duration-100" - x-transition:enter-start="transform opacity-0" - x-transition:enter-end="transform opacity-100" - x-transition:leave="transition ease-in duration-75" - x-transition:leave-start="transform opacity-100" - x-transition:leave-end="transform opacity-0" - @endif +
merge($this->getFilterSlidedownWrapperAttributes) + ->merge($this->isTailwind ? [ + 'x-transition:enter' => 'transition ease-out duration-100', + 'x-transition:enter-start' => 'transform opacity-0', + 'x-transition:enter-end' => 'transform opacity-100', + 'x-transition:leave' => 'transition ease-in duration-75', + 'x-transition:leave-start' => 'transform opacity-100', + 'x-transition:leave-end' => 'transform opacity-0', + ] : []) + ->class([ + 'container' => $this->isBootstrap && ($this->getFilterSlidedownWrapperAttributes['default'] ?? true), + ]) + ->except(['default','default-colors','default-styling']) + }} + > - @foreach ($this->getFiltersByRow() as $filterRowIndex => $filterRow) -
$this->isBootstrap, - 'grid grid-cols-12 gap-6 px-4 md:p-0 mb-6' => $this->isTailwind, + @foreach ($this->getFiltersByRow() as $filterRowIndex => $filtersInRow) + @php($defaultAttributes = $this->getFilterSlidedownRowAttributes($filterRowIndex)) +
merge($defaultAttributes) + ->merge([ + 'row' => $filterRowIndex, + ]) + ->class([ + 'row col-12' => $this->isBootstrap && ($defaultAttributes['default-styling'] ?? true), + 'grid grid-cols-12 gap-6 px-4 py-2 mb-2' => $this->isTailwind && ($defaultAttributes['default-styling'] ?? true), ]) - row="{{ $filterRowIndex }}" + ->except(['default','default-colors','default-styling']) + }} > - @foreach ($filterRow as $filter) + @foreach ($filtersInRow as $filter)
diff --git a/src/Traits/Helpers/PaginationHelpers.php b/src/Traits/Helpers/PaginationHelpers.php index b97666ca3..07ee59f59 100644 --- a/src/Traits/Helpers/PaginationHelpers.php +++ b/src/Traits/Helpers/PaginationHelpers.php @@ -27,6 +27,7 @@ public function getPaginationTheme(): string return $this->paginationTheme; } + #[Computed] public function paginationIsEnabled(): bool { return $this->getPaginationStatus() === true; @@ -118,6 +119,7 @@ public function getPerPageDisplayedItemCount(): int return $this->paginationCurrentCount; } + #[Computed] public function showPaginationDetails(): bool { return $this->shouldShowPaginationDetails === true; diff --git a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php index 9c61f9eba..6f74ed5a3 100644 --- a/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/BulkActionStylingConfiguration.php @@ -73,4 +73,14 @@ public function setBulkActionsThCheckboxAttributes(array $bulkActionsThCheckboxA return $this; } + + /** + * Used to set attributes for the Bulk Actions Row Buttons + */ + public function setBulkActionsRowButtonAttributes(array $bulkActionsRowButtonAttributes): self + { + $this->setCustomAttributes('bulkActionsRowButtonAttributes', $bulkActionsRowButtonAttributes); + + return $this; + } } diff --git a/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php b/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php index 92d8ba467..4a68532d5 100644 --- a/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/FilterMenuStylingConfiguration.php @@ -16,6 +16,26 @@ public function setFilterPopoverAttributes(array $filterPopoverAttributes): self return $this; } + /** + * Used to set attributes for the Filter Slidedown Wrapper + */ + public function setFilterSlidedownWrapperAttributes(array $filterSlidedownWrapperAttributes): self + { + $this->filterSlidedownWrapperAttributes = array_merge($this->filterSlidedownWrapperAttributes, $filterSlidedownWrapperAttributes); + + return $this; + } + + /** + * Set a list of attributes to override on the th sort button elements + */ + public function setFilterSlidedownRowAttributes(\Closure $callback): self + { + $this->filterSlidedownRowCallback = $callback; + + return $this; + } + public function setFilterLayout(string $type): self { if (! in_array($type, ['popover', 'slide-down'], true)) { diff --git a/src/Traits/Styling/HasBulkActionsStyling.php b/src/Traits/Styling/HasBulkActionsStyling.php index c1f1b1aca..07bf1f133 100644 --- a/src/Traits/Styling/HasBulkActionsStyling.php +++ b/src/Traits/Styling/HasBulkActionsStyling.php @@ -25,4 +25,6 @@ trait HasBulkActionsStyling protected array $bulkActionsMenuAttributes = ['default-colors' => true, 'default-styling' => true]; protected array $bulkActionsMenuItemAttributes = ['default-colors' => true, 'default-styling' => true]; + + protected array $bulkActionsRowButtonAttributes = ['default-colors' => true, 'default-styling' => true]; } diff --git a/src/Traits/Styling/HasFilterMenuStyling.php b/src/Traits/Styling/HasFilterMenuStyling.php index c534027e4..03a6737b4 100644 --- a/src/Traits/Styling/HasFilterMenuStyling.php +++ b/src/Traits/Styling/HasFilterMenuStyling.php @@ -18,4 +18,8 @@ trait HasFilterMenuStyling public bool $filterSlideDownDefaultVisible = false; protected array $filterPopoverAttributes = ['class' => '', 'default-width' => true, 'default-colors' => true, 'default-styling' => true]; + + protected array $filterSlidedownWrapperAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true]; + + protected ?\Closure $filterSlidedownRowCallback; } diff --git a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php index 6c100c345..adc3cea89 100644 --- a/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php +++ b/src/Traits/Styling/Helpers/BulkActionStylingHelpers.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; +use Illuminate\View\ComponentAttributeBag; use Livewire\Attributes\Computed; trait BulkActionStylingHelpers @@ -93,4 +94,22 @@ public function getBulkActionsTdCheckboxAttributes(): array return $this->getCustomAttributes('bulkActionsTdCheckboxAttributes'); } + + /** + * Used to get attributes for the Bulk Actions Row Buttons + * + * @return array + */ + #[Computed] + public function getBulkActionsRowButtonAttributes(): array + { + return $this->getCustomAttributes('bulkActionsRowButtonAttributes', true); + + } + + #[Computed] + public function getBulkActionsRowButtonAttributesBag(): ComponentAttributeBag + { + return $this->getCustomAttributesBagFromArray($this->getBulkActionsRowButtonAttributes()); + } } diff --git a/src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php b/src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php index d5ddf6d6c..9833809d6 100644 --- a/src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php +++ b/src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php @@ -20,6 +20,34 @@ public function getFilterPopoverAttributes(): array } + /** + * Used to get attributes for the Filter Slidedown Wrapper + * + * @return array + */ + #[Computed] + public function getFilterSlidedownWrapperAttributes(): array + { + return $this->filterSlidedownWrapperAttributes; + + } + + /** + * Used to get attributes for the Filter Slidedown Row + * + * @return array + */ + #[Computed] + public function getFilterSlidedownRowAttributes(string $rowIndex): array + { + + if (isset($this->filterSlidedownRowCallback)) { + return array_merge(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => (int) $rowIndex], call_user_func($this->filterSlidedownRowCallback, (int) $rowIndex)); + } + + return ['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => (int) $rowIndex]; + } + public function getFilterSlideDownDefaultStatus(): bool { return $this->filterSlideDownDefaultVisible; diff --git a/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php b/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php index fb321a1c4..019c13d22 100644 --- a/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php +++ b/tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php @@ -32,6 +32,7 @@ public static function providesBulkActionMethodsToTest(): array 'BulkActionsThCheckboxAttributes', 'BulkActionsTdAttributes', 'BulkActionsTdCheckboxAttributes', + 'BulkActionsRowButtonAttributes', ]; } diff --git a/tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php b/tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php new file mode 100644 index 000000000..5ba1ac182 --- /dev/null +++ b/tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php @@ -0,0 +1,92 @@ +assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getFilterSlidedownWrapperAttributes()); + } + + public function test_filter_slidedown_wrapper_attributes_can_be_changed(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getFilterSlidedownWrapperAttributes()); + $this->basicTable->setFilterSlidedownWrapperAttributes([ + 'class' => 'text-blue-500', + 'default-colors' => true, + 'default-styling' => true, + 'x-transition:enter' => 'transition ease-out duration-1000', + ]); + + $this->assertSame(['class' => 'text-blue-500', 'default-colors' => true, 'default-styling' => true, 'x-transition:enter' => 'transition ease-out duration-1000'], $this->basicTable->getFilterSlidedownWrapperAttributes()); + + $this->basicTable->setFilterSlidedownWrapperAttributes([ + 'x-transition:enter-start' => 'transform opacity-0', + ]); + + $this->assertSame(['class' => 'text-blue-500', 'default-colors' => true, 'default-styling' => true, 'x-transition:enter' => 'transition ease-out duration-1000', 'x-transition:enter-start' => 'transform opacity-0'], $this->basicTable->getFilterSlidedownWrapperAttributes()); + + } + + public function test_filter_slidedown_row_attributes_returns_default_if_not_set(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2)); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1')); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2')); + } + + public function test_filter_slidedown_row_attributes_can_be_changed(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + + $this->basicTable->setFilterSlidedownRowAttributes(fn ($rowIndex) => $rowIndex % 2 === 0 ? + [ + 'class' => 'bg-red-500', + 'default-colors' => true, + 'default-styling' => true, + ] : [ + 'class' => 'bg-blue-500', + 'default-colors' => true, + 'default-styling' => true, + ] + ); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0)); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2)); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes(3)); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes('0')); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1')); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2')); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes('3')); + + } + + public function test_filter_slidedown_row_attributes_can_be_changed_and_sets_defaults(): void + { + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0)); + $this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + + $this->basicTable->setFilterSlidedownRowAttributes(fn ($rowIndex) => $rowIndex % 2 === 0 ? + [ + 'class' => 'bg-red-500', + 'default-colors' => false, + ] : [ + 'class' => 'bg-blue-500', + 'default-styling' => false, + ] + ); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0)); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1)); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2)); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes(3)); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes('0')); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1')); + $this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2')); + $this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes('3')); + + } +} diff --git a/tests/Unit/Traits/Visuals/PaginationVisualsTest.php b/tests/Unit/Traits/Visuals/PaginationVisualsTest.php index 8e0134f61..1d4226e78 100644 --- a/tests/Unit/Traits/Visuals/PaginationVisualsTest.php +++ b/tests/Unit/Traits/Visuals/PaginationVisualsTest.php @@ -186,7 +186,7 @@ public function test_detailed_pagination_is_displayed_standard_bs4(): void Livewire::test(PetsTable::class) ->call('setTheme', 'bootstrap-4') ->call('enableDetailedPagination', 'standard') - ->assertSeeHtmlInOrder(['
', + ->assertSeeHtmlInOrder(['
', 'Showing', '1', 'to', @@ -231,7 +231,7 @@ public function test_detailed_pagination_is_displayed_standard_bs5(): void Livewire::test(PetsTable::class) ->call('setTheme', 'bootstrap-5') ->call('enableDetailedPagination', 'standard') - ->assertSeeHtmlInOrder(['
', + ->assertSeeHtmlInOrder(['
', 'Showing', '1', 'to', @@ -244,7 +244,7 @@ public function test_detailed_pagination_is_displayed_simple_bs5(): void Livewire::test(PetsTable::class) ->call('setTheme', 'bootstrap-5') ->call('enableDetailedPagination', 'simple') - ->assertSeeHtmlInOrder(['
', + ->assertSeeHtmlInOrder(['
', 'Showing', '1', 'to', diff --git a/tests/Unit/Views/Filters/BooleanFilterTest.php b/tests/Unit/Views/Filters/BooleanFilterTest.php index 5e834a339..5fb5203e4 100644 --- a/tests/Unit/Views/Filters/BooleanFilterTest.php +++ b/tests/Unit/Views/Filters/BooleanFilterTest.php @@ -27,6 +27,18 @@ public function test_can_set_boolean_filter_to_integer(): void $this->assertTrue(self::$filterInstance->validate(1)); } + public function test_can_set_boolean_filter_to_valid_string(): void + { + $this->assertTrue(self::$filterInstance->validate('1')); + $this->assertFalse(self::$filterInstance->validate('0')); + } + + public function test_cannot_set_boolean_filter_to_valid_string(): void + { + $this->assertFalse(self::$filterInstance->validate('abc')); + $this->assertFalse(self::$filterInstance->validate('def')); + } + public function test_can_get_custom_filter_pills(): void { $filter = self::$filterInstance; @@ -74,6 +86,11 @@ public function test_can_get_if_boolean_filter_not_empty_string(): void $this->assertFalse(self::$filterInstance->isEmpty('0')); } + public function test_can_get_if_boolean_filter_not_empty_invalid_string(): void + { + $this->assertTrue(self::$filterInstance->isEmpty('abc')); + } + public function test_can_validate_null_boolean_filter_value(): void { $filter = self::$filterInstance; diff --git a/tests/Unit/Views/Filters/LivewireComponentFilterTest.php b/tests/Unit/Views/Filters/LivewireComponentFilterTest.php new file mode 100644 index 000000000..447e229b6 --- /dev/null +++ b/tests/Unit/Views/Filters/LivewireComponentFilterTest.php @@ -0,0 +1,49 @@ +assertFalse($filter->hasFilterCallback()); + + $filter = LivewireComponentFilter::make('Active') + ->filter(function (Builder $builder, int $value) { + return $builder->where('name', '=', $value); + }); + + $this->assertTrue($filter->hasFilterCallback()); + $this->assertIsCallable($filter->getFilterCallback()); + } + + public function test_can_set_livewire_component_filter_to_text(): void + { + $filter = LivewireComponentFilter::make('BreedID'); + $this->assertSame('test', $filter->validate('test')); + $this->assertSame('123', $filter->validate(123)); + + } + + public function test_can_get_if_livewire_component_filter_empty(): void + { + $filter = LivewireComponentFilter::make('Active'); + $this->assertTrue($filter->isEmpty(null)); + $this->assertTrue($filter->isEmpty('')); + $this->assertFalse($filter->isEmpty('123')); + $this->assertFalse($filter->isEmpty('test')); + $this->assertFalse($filter->isEmpty(1234)); + + } +}