From 237fca4de2673542faad7fb8da7454b8d80bf137 Mon Sep 17 00:00:00 2001 From: 89 Date: Sun, 28 Jul 2024 15:05:36 +0300 Subject: [PATCH] adds partial table widget customisation --- .../views/advanced-table-widget.blade.php | 52 +++++++++++++++++-- src/AdvancedTableWidget.php | 2 + src/Concerns/HasSectionContent.php | 35 +++++++++++++ 3 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 src/Concerns/HasSectionContent.php diff --git a/resources/views/advanced-table-widget.blade.php b/resources/views/advanced-table-widget.blade.php index 723fe24..80084c2 100644 --- a/resources/views/advanced-table-widget.blade.php +++ b/resources/views/advanced-table-widget.blade.php @@ -1,7 +1,53 @@ +@php + use Filament\Support\Facades\FilamentView; + + $heading = $this->getHeading(); + $description = $this->getDescription(); + $label = $this->getLabel(); + $filters = $this->getFilters(); + + $icon = $this->getIcon(); + $iconColor = $this->getIconColor(); + $iconBackgroundColor = filled($this->getIconBackgroundColor()) + ? match ($this->getIconBackgroundColor()) { + 'primary' => 'bg-primary-200 dark:bg-primary-950', + 'secondary' => 'bg-secondary-200 dark:bg-secondary-950', + 'success' => 'bg-success-200 dark:bg-success-950', + 'danger' => 'bg-danger-200 dark:bg-danger-950', + 'warning' => 'bg-warning-200 dark:bg-warning-950', + 'info' => 'bg-info-200 dark:bg-info-950', + default => 'bg-gray-200 dark:bg-gray-950', + } + : ''; + + $badge = $this->getBadge(); + $badgeColor = $this->getBadgeColor(); + $badgeIcon = $this->getBadgeIcon(); + $badgeIconPosition = $this->getBadgeIconPosition(); + $badgeSize = $this->getBadgeSize(); +@endphp - {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Widgets\View\WidgetsRenderHook::TABLE_WIDGET_START, scopes: static::class) }} - {{ $this->table }} + + @if ($filters) + + + + @foreach ($filters as $value => $label) + + @endforeach + + + + @endif + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Widgets\View\WidgetsRenderHook::TABLE_WIDGET_START, scopes: static::class) }} + + {{ $this->table }} - {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Widgets\View\WidgetsRenderHook::TABLE_WIDGET_END, scopes: static::class) }} + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Widgets\View\WidgetsRenderHook::TABLE_WIDGET_END, scopes: static::class) }} + diff --git a/src/AdvancedTableWidget.php b/src/AdvancedTableWidget.php index 41c768b..c368cf9 100644 --- a/src/AdvancedTableWidget.php +++ b/src/AdvancedTableWidget.php @@ -14,6 +14,8 @@ class AdvancedTableWidget extends AdvancedWidget implements Actions\Contracts\HasActions, Forms\Contracts\HasForms, Infolists\Contracts\HasInfolists, Tables\Contracts\HasTable { + use Concerns\CanBeCustomised, + Concerns\HasSectionContent; use Actions\Concerns\InteractsWithActions; use Forms\Concerns\InteractsWithForms; use Infolists\Concerns\InteractsWithInfolists; diff --git a/src/Concerns/HasSectionContent.php b/src/Concerns/HasSectionContent.php new file mode 100644 index 0000000..997dac6 --- /dev/null +++ b/src/Concerns/HasSectionContent.php @@ -0,0 +1,35 @@ +