From e5512a448e4ff67e090a8cc2838acc713a35baf5 Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Mon, 6 Jan 2025 09:50:49 +0100 Subject: [PATCH 01/16] Fix order by subqueries --- packages/support/src/Services/RelationshipJoiner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/support/src/Services/RelationshipJoiner.php b/packages/support/src/Services/RelationshipJoiner.php index 6f6fade8b0..5828c0bbee 100644 --- a/packages/support/src/Services/RelationshipJoiner.php +++ b/packages/support/src/Services/RelationshipJoiner.php @@ -95,7 +95,7 @@ class RelationshipJoiner continue; } - if (str($order['column'])->startsWith("{$relationshipQuery->getModel()->getTable()}.")) { + if (is_string($order['column']) && str($order['column'])->startsWith("{$relationshipQuery->getModel()->getTable()}.")) { continue; } From f15369ea3f0dc03764e88d34aed1769efb01d25c Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Mon, 6 Jan 2025 10:15:26 +0100 Subject: [PATCH 02/16] Improve RelationshipJoiner orderBy support --- .../src/Services/RelationshipJoiner.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/support/src/Services/RelationshipJoiner.php b/packages/support/src/Services/RelationshipJoiner.php index 5828c0bbee..cef705f15f 100644 --- a/packages/support/src/Services/RelationshipJoiner.php +++ b/packages/support/src/Services/RelationshipJoiner.php @@ -5,6 +5,7 @@ namespace Filament\Support\Services; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\Relation; +use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Arr; use Illuminate\Support\Str; @@ -91,15 +92,26 @@ class RelationshipJoiner /** @phpstan-ignore-next-line */ foreach (($relationshipQuery->getQuery()->orders ?? []) as $order) { - if (! array_key_exists('column', $order)) { + // Regular orders: { column: string, direction: 'asc' | 'desc' } + // Raw orders: { type: 'Raw', sql: string } + // Sub-query orders look like: { column: Illuminate\Database\Query\Expression, direction: 'asc' | 'desc' } + if (! array_key_exists('column', $order) && ! array_key_exists('sql', $order)) { continue; } - if (is_string($order['column']) && str($order['column'])->startsWith("{$relationshipQuery->getModel()->getTable()}.")) { + $columnValue = $order['column'] ?? new Expression($order['sql']); + + if ($columnValue instanceof Expression && str($columnValue->getValue($relationship->getGrammar()))->contains('?')) { + // Heuristic to determine if the expression contains (a) binding(s), if so, as of + // yet we cannot reliably determine (which) bindings are used in the expression. continue; } - $relationshipQuery->addSelect($order['column']); + if (str($columnValue instanceof Expression ? $columnValue->getValue($relationship->getGrammar()) : $columnValue)->startsWith("{$relationshipQuery->getModel()->getTable()}.")) { + continue; + } + + $relationshipQuery->addSelect($columnValue); } } From f63d15544ff0f8deb4cf805f6a78dceef4df7e50 Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Mon, 6 Jan 2025 10:55:43 +0100 Subject: [PATCH 03/16] Update RelationshipJoiner.php --- packages/support/src/Services/RelationshipJoiner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/support/src/Services/RelationshipJoiner.php b/packages/support/src/Services/RelationshipJoiner.php index cef705f15f..1b38318e49 100644 --- a/packages/support/src/Services/RelationshipJoiner.php +++ b/packages/support/src/Services/RelationshipJoiner.php @@ -93,8 +93,8 @@ class RelationshipJoiner /** @phpstan-ignore-next-line */ foreach (($relationshipQuery->getQuery()->orders ?? []) as $order) { // Regular orders: { column: string, direction: 'asc' | 'desc' } - // Raw orders: { type: 'Raw', sql: string } // Sub-query orders look like: { column: Illuminate\Database\Query\Expression, direction: 'asc' | 'desc' } + // Raw orders: { type: 'Raw', sql: string } if (! array_key_exists('column', $order) && ! array_key_exists('sql', $order)) { continue; } From 5b9b970440c8ab124e8709ebae26cf95f9ded725 Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Mon, 6 Jan 2025 10:55:59 +0100 Subject: [PATCH 04/16] Update RelationshipJoiner.php --- packages/support/src/Services/RelationshipJoiner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/support/src/Services/RelationshipJoiner.php b/packages/support/src/Services/RelationshipJoiner.php index 1b38318e49..57ea8157a9 100644 --- a/packages/support/src/Services/RelationshipJoiner.php +++ b/packages/support/src/Services/RelationshipJoiner.php @@ -93,7 +93,7 @@ class RelationshipJoiner /** @phpstan-ignore-next-line */ foreach (($relationshipQuery->getQuery()->orders ?? []) as $order) { // Regular orders: { column: string, direction: 'asc' | 'desc' } - // Sub-query orders look like: { column: Illuminate\Database\Query\Expression, direction: 'asc' | 'desc' } + // Sub-query orders: { column: Illuminate\Database\Query\Expression, direction: 'asc' | 'desc' } // Raw orders: { type: 'Raw', sql: string } if (! array_key_exists('column', $order) && ! array_key_exists('sql', $order)) { continue; From 693a0e3c09511aafe16ef006312167691da01ab8 Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Mon, 6 Jan 2025 11:02:48 +0100 Subject: [PATCH 05/16] Style --- packages/support/src/Services/RelationshipJoiner.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/support/src/Services/RelationshipJoiner.php b/packages/support/src/Services/RelationshipJoiner.php index 57ea8157a9..441d53562b 100644 --- a/packages/support/src/Services/RelationshipJoiner.php +++ b/packages/support/src/Services/RelationshipJoiner.php @@ -101,13 +101,19 @@ class RelationshipJoiner $columnValue = $order['column'] ?? new Expression($order['sql']); - if ($columnValue instanceof Expression && str($columnValue->getValue($relationship->getGrammar()))->contains('?')) { + if ( + $columnValue instanceof Expression + && str($columnValue->getValue($relationship->getGrammar()))->contains('?') + ) { // Heuristic to determine if the expression contains (a) binding(s), if so, as of // yet we cannot reliably determine (which) bindings are used in the expression. continue; } - if (str($columnValue instanceof Expression ? $columnValue->getValue($relationship->getGrammar()) : $columnValue)->startsWith("{$relationshipQuery->getModel()->getTable()}.")) { + if ( + str($columnValue instanceof Expression ? $columnValue->getValue($relationship->getGrammar()) : $columnValue) + ->startsWith("{$relationshipQuery->getModel()->getTable()}.") + ) { continue; } From bf1704ed32f449533e82b58dc24321baa27edbb7 Mon Sep 17 00:00:00 2001 From: Tina Hammar Date: Tue, 14 Jan 2025 12:52:05 +0100 Subject: [PATCH 06/16] prevent click through on table editable columns --- .../views/columns/checkbox-column.blade.php | 39 +++++----- .../views/columns/select-column.blade.php | 48 ++++++------- .../views/columns/text-input-column.blade.php | 54 +++++++------- .../views/columns/toggle-column.blade.php | 71 ++++++++++--------- 4 files changed, 107 insertions(+), 105 deletions(-) diff --git a/packages/tables/resources/views/columns/checkbox-column.blade.php b/packages/tables/resources/views/columns/checkbox-column.blade.php index 3e9fd5cbc1..3f58d5e53d 100644 --- a/packages/tables/resources/views/columns/checkbox-column.blade.php +++ b/packages/tables/resources/views/columns/checkbox-column.blade.php @@ -4,7 +4,7 @@ @endphp
merge($getExtraAttributes(), escape: false) - ->class([ - 'fi-ta-checkbox flex items-center', - 'px-3 py-4' => ! $isInline(), - ]) - }} + {{ + $attributes + ->merge($getExtraAttributes(), escape: false) + ->class([ + 'fi-ta-checkbox flex items-center', + 'px-3 py-4' => ! $isInline(), + ]) + }} > - + { Livewire.hook('commit', ({ component, commit, succeed, fail, respond }) => { succeed(({ snapshot, effect }) => { @@ -46,25 +46,25 @@ }) } " - {{ - $attributes - ->merge($getExtraAttributes(), escape: false) - ->class([ - 'fi-ta-select w-full min-w-48', - 'px-3 py-4' => ! $isInline(), - ]) - }} + {{ + $attributes + ->merge($getExtraAttributes(), escape: false) + ->class([ + 'fi-ta-select w-full min-w-48', + 'px-3 py-4' => ! $isInline(), + ]) + }} > @if ($canSelectPlaceholder) @@ -103,8 +103,8 @@ @foreach ($getOptions() as $value => $label) diff --git a/packages/tables/resources/views/columns/text-input-column.blade.php b/packages/tables/resources/views/columns/text-input-column.blade.php index 50e2928b19..58af241d72 100644 --- a/packages/tables/resources/views/columns/text-input-column.blade.php +++ b/packages/tables/resources/views/columns/text-input-column.blade.php @@ -19,7 +19,7 @@ @endphp
{ Livewire.hook('commit', ({ component, commit, succeed, fail, respond }) => { succeed(({ snapshot, effect }) => { @@ -61,25 +61,25 @@ }) } " - {{ - $attributes - ->merge($getExtraAttributes(), escape: false) - ->class([ - 'fi-ta-text-input w-full min-w-48', - 'px-3 py-4' => ! $isInline(), - ]) - }} + {{ + $attributes + ->merge($getExtraAttributes(), escape: false) + ->class([ + 'fi-ta-text-input w-full min-w-48', + 'px-3 py-4' => ! $isInline(), + ]) + }} > {{-- format-ignore-start --}} getId() }}.table.record.{{ $recordKey }}.column.{{ $getName() }}.toggle-column.{{ $state ? 'true' : 'false' }}" + wire:key="{{ $this->getId() }}.table.record.{{ $recordKey }}.column.{{ $getName() }}.toggle-column.{{ $state ? 'true' : 'false' }}" >
merge($getExtraAttributes(), escape: false) - ->class([ - 'fi-ta-toggle', - 'px-3 py-4' => ! $isInline(), - ]) - }} + wire:ignore + {{ + $attributes + ->merge($getExtraAttributes(), escape: false) + ->class([ + 'fi-ta-toggle', + 'px-3 py-4' => ! $isInline(), + ]) + }} > @php $offColor = $getOffColor() ?? 'gray'; @@ -28,12 +28,13 @@ @endphp
$isDisabled, - ]) + @class([ + 'relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent outline-none transition-colors duration-200 ease-in-out', + 'pointer-events-none opacity-70' => $isDisabled, + ]) >