diff --git a/composer.lock b/composer.lock index edd0ed38..04fdaa7a 100644 --- a/composer.lock +++ b/composer.lock @@ -1496,16 +1496,16 @@ }, { "name": "league/flysystem", - "version": "3.17.0", + "version": "3.18.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "bd4c9b26849d82364119c68429541f1631fba94b" + "reference": "015633a05aee22490495159237a5944091d8281e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/bd4c9b26849d82364119c68429541f1631fba94b", - "reference": "bd4c9b26849d82364119c68429541f1631fba94b", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/015633a05aee22490495159237a5944091d8281e", + "reference": "015633a05aee22490495159237a5944091d8281e", "shasum": "" }, "require": { @@ -1534,7 +1534,7 @@ "google/cloud-storage": "^1.23", "microsoft/azure-storage-blob": "^1.1", "phpseclib/phpseclib": "^3.0.14", - "phpstan/phpstan": "^0.12.26", + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5.11|^10.0", "sabre/dav": "^4.3.1" }, @@ -1570,7 +1570,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.17.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.18.0" }, "funding": [ { @@ -1582,20 +1582,20 @@ "type": "github" } ], - "time": "2023-10-05T20:15:05+00:00" + "time": "2023-10-20T17:59:40+00:00" }, { "name": "league/flysystem-local", - "version": "3.16.0", + "version": "3.18.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-local.git", - "reference": "ec7383f25642e6fd4bb0c9554fc2311245391781" + "reference": "e7381ef7643f658b87efb7dbe98fe538fb1bbf32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/ec7383f25642e6fd4bb0c9554fc2311245391781", - "reference": "ec7383f25642e6fd4bb0c9554fc2311245391781", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/e7381ef7643f658b87efb7dbe98fe538fb1bbf32", + "reference": "e7381ef7643f658b87efb7dbe98fe538fb1bbf32", "shasum": "" }, "require": { @@ -1630,7 +1630,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem-local/issues", - "source": "https://github.com/thephpleague/flysystem-local/tree/3.16.0" + "source": "https://github.com/thephpleague/flysystem-local/tree/3.18.0" }, "funding": [ { @@ -1642,7 +1642,7 @@ "type": "github" } ], - "time": "2023-08-30T10:23:59+00:00" + "time": "2023-10-19T20:07:13+00:00" }, { "name": "league/mime-type-detection", @@ -3290,16 +3290,16 @@ }, { "name": "symfony/http-foundation", - "version": "v6.3.5", + "version": "v6.3.6", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "b50f5e281d722cb0f4c296f908bacc3e2b721957" + "reference": "c186627f52febe09c6d5270b04f8462687a250a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/b50f5e281d722cb0f4c296f908bacc3e2b721957", - "reference": "b50f5e281d722cb0f4c296f908bacc3e2b721957", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/c186627f52febe09c6d5270b04f8462687a250a6", + "reference": "c186627f52febe09c6d5270b04f8462687a250a6", "shasum": "" }, "require": { @@ -3309,12 +3309,12 @@ "symfony/polyfill-php83": "^1.27" }, "conflict": { - "symfony/cache": "<6.2" + "symfony/cache": "<6.3" }, "require-dev": { - "doctrine/dbal": "^2.13.1|^3.0", + "doctrine/dbal": "^2.13.1|^3|^4", "predis/predis": "^1.1|^2.0", - "symfony/cache": "^5.4|^6.0", + "symfony/cache": "^6.3", "symfony/dependency-injection": "^5.4|^6.0", "symfony/expression-language": "^5.4|^6.0", "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4", @@ -3347,7 +3347,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.3.5" + "source": "https://github.com/symfony/http-foundation/tree/v6.3.6" }, "funding": [ { @@ -3363,20 +3363,20 @@ "type": "tidelift" } ], - "time": "2023-09-04T21:33:54+00:00" + "time": "2023-10-17T11:32:53+00:00" }, { "name": "symfony/http-kernel", - "version": "v6.3.5", + "version": "v6.3.6", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "9f991a964368bee8d883e8d57ced4fe9fff04dfc" + "reference": "4945f5001b06ff9080cd3d8f1f9f069094c0d156" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/9f991a964368bee8d883e8d57ced4fe9fff04dfc", - "reference": "9f991a964368bee8d883e8d57ced4fe9fff04dfc", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/4945f5001b06ff9080cd3d8f1f9f069094c0d156", + "reference": "4945f5001b06ff9080cd3d8f1f9f069094c0d156", "shasum": "" }, "require": { @@ -3460,7 +3460,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v6.3.5" + "source": "https://github.com/symfony/http-kernel/tree/v6.3.6" }, "funding": [ { @@ -3476,7 +3476,7 @@ "type": "tidelift" } ], - "time": "2023-09-30T06:37:04+00:00" + "time": "2023-10-21T13:12:51+00:00" }, { "name": "symfony/mailer", @@ -4694,16 +4694,16 @@ }, { "name": "symfony/translation", - "version": "v6.3.3", + "version": "v6.3.6", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "3ed078c54bc98bbe4414e1e9b2d5e85ed5a5c8bd" + "reference": "869b26c7a9d4b8a48afdd77ab36031909c87e3a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/3ed078c54bc98bbe4414e1e9b2d5e85ed5a5c8bd", - "reference": "3ed078c54bc98bbe4414e1e9b2d5e85ed5a5c8bd", + "url": "https://api.github.com/repos/symfony/translation/zipball/869b26c7a9d4b8a48afdd77ab36031909c87e3a2", + "reference": "869b26c7a9d4b8a48afdd77ab36031909c87e3a2", "shasum": "" }, "require": { @@ -4769,7 +4769,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v6.3.3" + "source": "https://github.com/symfony/translation/tree/v6.3.6" }, "funding": [ { @@ -4785,7 +4785,7 @@ "type": "tidelift" } ], - "time": "2023-07-31T07:08:24+00:00" + "time": "2023-10-17T11:32:53+00:00" }, { "name": "symfony/translation-contracts", @@ -4941,16 +4941,16 @@ }, { "name": "symfony/var-dumper", - "version": "v6.3.5", + "version": "v6.3.6", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "3d9999376be5fea8de47752837a3e1d1c5f69ef5" + "reference": "999ede244507c32b8e43aebaa10e9fce20de7c97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/3d9999376be5fea8de47752837a3e1d1c5f69ef5", - "reference": "3d9999376be5fea8de47752837a3e1d1c5f69ef5", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/999ede244507c32b8e43aebaa10e9fce20de7c97", + "reference": "999ede244507c32b8e43aebaa10e9fce20de7c97", "shasum": "" }, "require": { @@ -5005,7 +5005,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.3.5" + "source": "https://github.com/symfony/var-dumper/tree/v6.3.6" }, "funding": [ { @@ -5021,7 +5021,7 @@ "type": "tidelift" } ], - "time": "2023-09-12T10:11:35+00:00" + "time": "2023-10-12T18:45:56+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", diff --git a/resources/views/components/frameworks/bootstrap5/header/toggle-columns.blade.php b/resources/views/components/frameworks/bootstrap5/header/toggle-columns.blade.php index 70772c8c..def5d0da 100644 --- a/resources/views/components/frameworks/bootstrap5/header/toggle-columns.blade.php +++ b/resources/views/components/frameworks/bootstrap5/header/toggle-columns.blade.php @@ -10,25 +10,23 @@ class="btn btn-light dropdown-toggle" diff --git a/resources/views/components/frameworks/tailwind/header/toggle-columns.blade.php b/resources/views/components/frameworks/tailwind/header/toggle-columns.blade.php index 79530cae..7a81a2d5 100644 --- a/resources/views/components/frameworks/tailwind/header/toggle-columns.blade.php +++ b/resources/views/components/frameworks/tailwind/header/toggle-columns.blade.php @@ -25,24 +25,21 @@ class="pg-btn-white dark:ring-pg-primary-600 dark:border-pg-primary-600 dark:hov x-transition:leave-end="opacity-0 scale-90" class="mt-2 py-2 w-48 bg-white shadow-xl absolute z-10 dark:bg-pg-primary-700" > - - @foreach ($columns as $column) - @if (!$column->forceHidden) -
visibleColumns as $column) +
- @if (!$column->hidden) - - @else - - @endif -
- {!! $column->title !!} -
+ > + @if (!$column->hidden) + + @else + + @endif +
+ {!! $column->title !!}
- @endif +
@endforeach
diff --git a/resources/views/components/inline-filters.blade.php b/resources/views/components/inline-filters.blade.php index 7475bbec..f6b8d5b8 100644 --- a/resources/views/components/inline-filters.blade.php +++ b/resources/views/components/inline-filters.blade.php @@ -34,7 +34,7 @@ class="{{ $tdClasses }}" > @endif - @foreach ($columns as $column) + @foreach ($this->visibleColumns as $column) $row->{$checkboxAttribute}, ]) -@foreach ($columns as $column) +@foreach ($this->visibleColumns as $column) @php $content = $row->{$column->field} ?? null; $contentClassField = $column->contentClassField != '' ? $row->{$column->contentClassField} : ''; diff --git a/resources/views/components/table-base.blade.php b/resources/views/components/table-base.blade.php index 0d825df6..bd5d4bf5 100644 --- a/resources/views/components/table-base.blade.php +++ b/resources/views/components/table-base.blade.php @@ -17,7 +17,6 @@ class="{{ $theme->theadClass }}" {{ $body }} diff --git a/resources/views/components/table-footer.blade.php b/resources/views/components/table-footer.blade.php index 993cc594..9dd5dd66 100644 --- a/resources/views/components/table-footer.blade.php +++ b/resources/views/components/table-footer.blade.php @@ -12,7 +12,7 @@ class="{{ $theme->table->tdBodyClass }}" @if ($checkbox) @endif - @foreach ($columns as $column) + @foreach ($this->visibleColumns as $column) table->tdBodyClass }}" style="{{ $theme->table->tdBodyStyle }}"> @endif - @foreach ($columns as $column) + @foreach ($this->visibleColumns as $column) @include('livewire-powergrid::components.summarize', [ diff --git a/src/PowerGridComponent.php b/src/PowerGridComponent.php index 5e76c680..d70a0a30 100644 --- a/src/PowerGridComponent.php +++ b/src/PowerGridComponent.php @@ -10,7 +10,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Pagination\{LengthAwarePaginator, Paginator}; use Illuminate\Support\{Collection as BaseCollection, Facades\Cache}; -use Livewire\{Attributes\On, Component, WithPagination}; +use Livewire\{Attributes\Computed, Attributes\On, Component, WithPagination}; use PowerComponents\LivewirePowerGrid\DataSource\{Collection,}; use PowerComponents\LivewirePowerGrid\Themes\ThemeBase; use PowerComponents\LivewirePowerGrid\Traits\{HasFilter, @@ -150,18 +150,17 @@ public function showRadioButton(string $attribute = 'id'): PowerGridComponent private function resolveTotalRow(): void { - collect($this->columns)->each(function (Column $column) { - $hasHeader = $column->sum['header'] || $column->count['header'] || $column->min['header'] || $column->avg['header'] || $column->max['header']; - $hasFooter = $column->sum['footer'] || $column->count['footer'] || $column->min['footer'] || $column->avg['footer'] || $column->max['footer']; + collect($this->columns) + ->each(function ($column) { + $hasHeaderFooter = false; - if ($hasHeader) { - $this->headerTotalColumn = true; - } + foreach (['sum', 'count', 'min', 'avg', 'max'] as $operation) { + $hasHeaderFooter = $hasHeaderFooter || data_get($column, "$operation.header") || data_get($column, "$operation.footer"); + } - if ($hasFooter) { - $this->footerTotalColumn = true; - } - }); + $this->headerTotalColumn = $this->headerTotalColumn || $hasHeaderFooter; + $this->footerTotalColumn = $this->footerTotalColumn || $hasHeaderFooter; + }); } public function fetchDatasource(): void @@ -269,15 +268,13 @@ public function toggleFilters(): void #[On('pg:toggleColumn-{tableName}')] public function toggleColumn(string $field): void { - $this->columns = collect($this->columns) - ->map(function ($column) use ($field) { - if (data_get($column, 'field') === $field) { - data_set($column, 'hidden', !data_get($column, 'hidden')); - } + foreach ($this->visibleColumns() as &$column) { + if (data_get($column, 'field') === $field) { + data_set($column, 'hidden', !data_get($column, 'hidden')); - return (object) $column; - }) - ->toArray(); + break; + } + } $this->persistState('columns'); } @@ -311,7 +308,8 @@ public function refresh(): void $this->dispatch('$refresh', []); } - public function getHasColumnFiltersProperty(): bool + #[Computed] + public function hasColumnFilters(): bool { return collect($this->columns) ->filter(fn ($column) => filled($column->filters))->count() > 0; @@ -365,6 +363,13 @@ private function resolveDetailRow(mixed $results): void }); } + #[Computed] + public function visibleColumns(): BaseCollection + { + return collect($this->columns) + ->where('forceHidden', false); + } + /** * @throws Exception|Throwable */