From 18fe30803674c387be9392ce79b552b0f11fd6e2 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Sat, 1 Feb 2025 12:02:31 +0000 Subject: [PATCH] Avoid double evaluation on Blade components --- .../resources/views/action-modal.blade.php | 57 +++++-- .../tables/resources/views/index.blade.php | 158 +++++++++++++----- .../views/components/widgets.blade.php | 2 + 3 files changed, 156 insertions(+), 61 deletions(-) diff --git a/packages/actions/resources/views/action-modal.blade.php b/packages/actions/resources/views/action-modal.blade.php index 1ab1729c749..a3705df41ea 100644 --- a/packages/actions/resources/views/action-modal.blade.php +++ b/packages/actions/resources/views/action-modal.blade.php @@ -1,23 +1,44 @@
+ @php + $actionModalAlignment = $action->getModalAlignment(); + $actionIsModalAutofocused = $action->isModalAutofocused(); + $actionHasModalCloseButton = $action->hasModalCloseButton(); + $actionIsModalClosedByClickingAway = $action->isModalClosedByClickingAway(); + $actionIsModalClosedByEscaping = $action->isModalClosedByEscaping(); + $actionModalDescription = $action->getModalDescription(); + $actionExtraModalWindowAttributeBag = $action->getExtraModalWindowAttributeBag(); + $actionModalFooterActions = $action->getVisibleModalFooterActions(); + $actionModalFooterActionsAlignment = $action->getModalFooterActionsAlignment(); + $actionModalHeading = $action->getModalHeading(); + $actionModalIcon = $action->getModalIcon(); + $actionModalIconColor = $action->getModalIconColor(); + $actionModalId = "fi-{$this->getId()}-action-{$action->getNestingIndex()}"; + $actionIsModalSlideOver = $action->isModalSlideOver(); + $actionIsModalFooterSticky = $action->isModalFooterSticky(); + $actionIsModalHeaderSticky = $action->isModalHeaderSticky(); + $actionModalWidth = $action->getModalWidth(); + $actionModalWireKey = "{$this->getId()}.actions.{$action->getName()}.modal"; + @endphp + {{ $action->getModalContent() }} diff --git a/packages/tables/resources/views/index.blade.php b/packages/tables/resources/views/index.blade.php index e0ceeceae4b..9966c379f99 100644 --- a/packages/tables/resources/views/index.blade.php +++ b/packages/tables/resources/views/index.blade.php @@ -29,6 +29,9 @@ $contentGrid = $getContentGrid(); $contentFooter = $getContentFooter(); $filterIndicators = $getFilterIndicators(); + $filtersApplyAction = $getFiltersApplyAction(); + $filtersForm = $getFiltersForm(); + $filtersFormWidth = $getFiltersFormWidth(); $hasColumnGroups = $hasColumnGroups(); $hasColumnsLayout = $hasColumnsLayout(); $hasSummary = $hasSummary(); @@ -173,8 +176,8 @@ class="fi-ta-header-heading" ]) > @endif @@ -386,23 +393,40 @@ class="fi-ta-grouping-settings" @if ($hasFiltersDialog || $hasColumnToggleDropdown) @if ($hasFiltersDialog) @if (($filtersLayout === FiltersLayout::Modal) || $filtersTriggerAction->isModalSlideOver()) + @php + $filtersTriggerActionModalAlignment = $filtersTriggerAction->getModalAlignment(); + $filtersTriggerActionIsModalAutofocused = $filtersTriggerAction->isModalAutofocused(); + $filtersTriggerActionHasModalCloseButton = $filtersTriggerAction->hasModalCloseButton(); + $filtersTriggerActionIsModalClosedByClickingAway = $filtersTriggerAction->isModalClosedByClickingAway(); + $filtersTriggerActionIsModalClosedByEscaping = $filtersTriggerAction->isModalClosedByEscaping(); + $filtersTriggerActionModalDescription = $filtersTriggerAction->getModalDescription(); + $filtersTriggerActionVisibleModalFooterActions = $filtersTriggerAction->getVisibleModalFooterActions(); + $filtersTriggerActionModalFooterActionsAlignment = $filtersTriggerAction->getModalFooterActionsAlignment(); + $filtersTriggerActionModalHeading = $filtersTriggerAction->getCustomModalHeading() ?? __('filament-tables::table.filters.heading'); + $filtersTriggerActionModalIcon = $filtersTriggerAction->getModalIcon(); + $filtersTriggerActionModalIconColor = $filtersTriggerAction->getModalIconColor(); + $filtersTriggerActionIsModalSlideOver = $filtersTriggerAction->isModalSlideOver(); + $filtersTriggerActionIsModalFooterSticky = $filtersTriggerAction->isModalFooterSticky(); + $filtersTriggerActionIsModalHeaderSticky = $filtersTriggerAction->isModalHeaderSticky(); + @endphp + @@ -411,17 +435,21 @@ class="fi-ta-filters-modal" {{ $filtersTriggerAction->getModalContent() }} - {{ $getFiltersForm() }} + {{ $filtersForm }} {{ $filtersTriggerAction->getModalContentFooter() }} @else + @php + $filtersFormMaxHeight = $getFiltersFormMaxHeight(); + @endphp + @@ -429,8 +457,8 @@ class="fi-ta-filters-dropdown" @@ -440,12 +468,17 @@ class="fi-ta-filters-dropdown" {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_TOGGLE_COLUMN_TRIGGER_BEFORE, scopes: static::class) }} @if ($hasColumnToggleDropdown) + @php + $columnToggleFormMaxHeight = $getColumnToggleFormMaxHeight(); + $columnToggleFormWidth = $getColumnToggleFormWidth(); + @endphp + @@ -552,14 +585,22 @@ class="fi-ta-selection-indicator"
@foreach ($filterIndicators as $indicator) - + @php + $indicatorColor = $indicator->getColor(); + @endphp + + {{ $indicator->getLabel() }} @if ($indicator->isRemovable()) + @php + $indicatorRemoveLivewireClickHandler = $indicator->getRemoveLivewireClickHandler(); + @endphp + @@ -776,6 +817,10 @@ function (array $carry, $action) use ($record): array { ]) > + @php + $groupScopedAllTableSummaryQuery = $group->scopeQuery($this->getAllTableSummaryQuery(), $previousRecord); + @endphp + @@ -1018,12 +1063,16 @@ class="fi-ta-record-collapse-btn fi-icon-btn" @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle) && ((! $records instanceof \Illuminate\Contracts\Pagination\Paginator) || (! $records->hasMorePages()))) + @php + $groupScopedAllTableSummaryQuery = $group->scopeQuery($this->getAllTableSummaryQuery(), $previousRecord); + @endphp + @@ -1327,18 +1376,22 @@ class="fi-ta-actions-header-cell fi-ta-empty-header-cell" @endif @foreach ($columns as $column) + @php + $columnName = $column->getName(); + @endphp + @@ -1398,14 +1451,19 @@ function (array $carry, $action) use ($record): array { @if ($recordGroupTitle !== $previousRecordGroupTitle) @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle)) + @php + $groupColumn = $group->getColumn(); + $groupScopedAllTableSummaryQuery = $group->scopeQuery($this->getAllTableSummaryQuery(), $previousRecord); + @endphp + hasMorePages()))) + @php + $groupColumn = $group->getColumn(); + $groupScopedAllTableSummaryQuery = $group->scopeQuery($this->getAllTableSummaryQuery(), $previousRecord); + @endphp + getColumn(); + @endphp + total())) + @php + $hasExtremePaginationLinks = $hasExtremePaginationLinks(); + $paginationPageOptions = $getPaginationPageOptions(); + @endphp + @endif @if ($hasFiltersBelowContent) diff --git a/packages/widgets/resources/views/components/widgets.blade.php b/packages/widgets/resources/views/components/widgets.blade.php index 09c0c40c141..31b5bc31e91 100644 --- a/packages/widgets/resources/views/components/widgets.blade.php +++ b/packages/widgets/resources/views/components/widgets.blade.php @@ -1,3 +1,5 @@ +{{-- @deprecated Use a schema to render widgets. --}} + @props([ 'columns' => [ 'lg' => 2,
$isIndividuallySearchable = $column->isIndividuallySearchable(), - 'fi-ta-individual-search-cell-' . str($column->getName())->camel()->kebab() => $isIndividuallySearchable, + 'fi-ta-individual-search-cell-' . str($columnName)->camel()->kebab() => $isIndividuallySearchable, ]) > @if ($isIndividuallySearchable) @endif