From bfb6b9c2bf712a7cc2d31b40b60bd626f713879c Mon Sep 17 00:00:00 2001
From: Luan Freitas <33601626+luanfreitasdev@users.noreply.github.com>
Date: Wed, 13 Mar 2024 19:05:03 -0300
Subject: [PATCH] [Fix] selecting a filter from select filter empties all
filter select inputs (#1460)
* Reorder resolveFilters - Add computedDatasource
* Reorder resolveFilters - Add computedDatasource
* Make laravel stable
---
.github/workflows/sqlite.yml | 7 +++-
composer.json | 2 +-
.../bootstrap5/filters/select.blade.php | 10 ++++-
.../tailwind/filters/select.blade.php | 10 ++++-
.../views/components/inputs/select.blade.php | 17 +++++++--
src/Components/Filters/FilterSelect.php | 9 +++++
src/Concerns/Filter.php | 5 ++-
src/DataSource/Builder.php | 7 +---
src/PowerGridComponent.php | 4 +-
src/ProcessDataSource.php | 4 +-
tests/Feature/Filters/FilterSelectTest.php | 38 ++++++++++++++++++-
11 files changed, 93 insertions(+), 20 deletions(-)
diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml
index 4feaf1ad..05165e31 100644
--- a/.github/workflows/sqlite.yml
+++ b/.github/workflows/sqlite.yml
@@ -24,6 +24,11 @@ jobs:
exclude:
- php: 8.1
laravel: 11.*
+ include:
+ - laravel: 10.*
+ testbench: 8.*
+ - laravel: 11.*
+ testbench: 9.*
dependency-version: [ prefer-stable ]
name: PHP:${{ matrix.php }} / L:${{ matrix.laravel }}
@@ -54,7 +59,7 @@ jobs:
- name: Install Composer dependencies
run: |
- composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
+ composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer install
- name: Install openspout/openspout
diff --git a/composer.json b/composer.json
index 3d71b810..f360d818 100644
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,7 @@
"description": "PowerGrid generates Advanced Datatables using Laravel Livewire.",
"homepage": "https://github.com/power-components/livewire-powergrid",
"license": "MIT",
- "minimum-stability": "dev",
+ "minimum-stability": "stable",
"prefer-stable": true,
"authors": [
{
diff --git a/resources/views/components/frameworks/bootstrap5/filters/select.blade.php b/resources/views/components/frameworks/bootstrap5/filters/select.blade.php
index 0784f8be..9b212db7 100644
--- a/resources/views/components/frameworks/bootstrap5/filters/select.blade.php
+++ b/resources/views/components/frameworks/bootstrap5/filters/select.blade.php
@@ -35,7 +35,15 @@ class="{{ $filterClasses }}"
{{ $defaultAttributes['selectAttributes'] }}
>
- @foreach (data_get($filter, 'dataSource') as $key => $item)
+
+ @php
+ $computedDatasource = data_get($filter, 'computedDatasource');
+ $dataSource = filled($computedDatasource)
+ ? $this->{$computedDatasource}
+ : data_get($filter, 'dataSource');
+ @endphp
+
+ @foreach ($dataSource as $key => $item)
- @foreach (data_get($filter, 'dataSource') as $key => $item)
+
+ @php
+ $computedDatasource = data_get($filter, 'computedDatasource');
+ $dataSource = filled($computedDatasource)
+ ? $this->{$computedDatasource}
+ : data_get($filter, 'dataSource');
+ @endphp
+
+ @foreach ($dataSource as $key => $item)