From 9f438f744f82a99327362dac5c49ecd0415c925a Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Fri, 9 Feb 2024 18:26:04 +0300 Subject: [PATCH] fix UI and the usage of plugin config in FE --- resources/views/filament/pages/builder.blade.php | 2 +- resources/views/filament/pages/dynamic-dashboard.blade.php | 2 +- .../views/themes/zeus/dynamic-dashboard/layouts.blade.php | 2 +- .../zeus/dynamic-dashboard/widgets/FaqWidget.blade.php | 4 ++-- .../zeus/dynamic-dashboard/widgets/FormsWidget.blade.php | 2 +- .../zeus/dynamic-dashboard/widgets/HeadingWidget.blade.php | 5 +---- .../zeus/dynamic-dashboard/widgets/ImageWidget.blade.php | 2 +- .../zeus/dynamic-dashboard/widgets/PostsWidget.blade.php | 2 +- src/Livewire/Layouts.php | 5 ++--- src/Widgets/Classes/FaqWidget.php | 2 +- src/Widgets/Classes/LibraryWidget.php | 2 +- src/Widgets/Classes/MenuWidget.php | 2 +- src/Widgets/Classes/PostsWidget.php | 6 +++--- 13 files changed, 17 insertions(+), 21 deletions(-) diff --git a/resources/views/filament/pages/builder.blade.php b/resources/views/filament/pages/builder.blade.php index f168c52..3c1eb64 100644 --- a/resources/views/filament/pages/builder.blade.php +++ b/resources/views/filament/pages/builder.blade.php @@ -4,7 +4,7 @@ {{ $this->mainWidgetForm }}
- @foreach (\LaraZeus\DynamicDashboard\DynamicDashboardPlugin::get()->getModel('Columns')::all() as $layout) + @foreach (config('zeus-dynamic-dashboard.models.Columns')::all() as $layout)

{{ $layout->name }}

{{ $this->{'widgetsFrom'.$layout->key} }} diff --git a/resources/views/filament/pages/dynamic-dashboard.blade.php b/resources/views/filament/pages/dynamic-dashboard.blade.php index af9fde8..d6483a9 100644 --- a/resources/views/filament/pages/dynamic-dashboard.blade.php +++ b/resources/views/filament/pages/dynamic-dashboard.blade.php @@ -1,7 +1,7 @@ @if($dashLayout->widgets !== null)
- @foreach (\LaraZeus\DynamicDashboard\DynamicDashboardPlugin::get()->getModel('Columns')::all() as $column) + @foreach (config('zeus-dynamic-dashboard.models.Columns')::all() as $column) @if(isset($dashLayout->widgets[$column->key])) @php $widgetsItems = collect($dashLayout->widgets[$column->key])->sortBy('data.sort')->toArray(); diff --git a/resources/views/themes/zeus/dynamic-dashboard/layouts.blade.php b/resources/views/themes/zeus/dynamic-dashboard/layouts.blade.php index 367d87a..8973fb4 100644 --- a/resources/views/themes/zeus/dynamic-dashboard/layouts.blade.php +++ b/resources/views/themes/zeus/dynamic-dashboard/layouts.blade.php @@ -1,7 +1,7 @@
@if($dashLayout->widgets !== null)
- @foreach (\LaraZeus\DynamicDashboard\DynamicDashboardPlugin::get()->getModel('Columns')::all() as $column) + @foreach (config('zeus-dynamic-dashboard.models.Columns')::all() as $column) @if(isset($dashLayout->widgets[$column->key])) @php $widgetsItems = collect($dashLayout->widgets[$column->key])->sortBy('data.sort')->toArray(); diff --git a/resources/views/themes/zeus/dynamic-dashboard/widgets/FaqWidget.blade.php b/resources/views/themes/zeus/dynamic-dashboard/widgets/FaqWidget.blade.php index 7801307..6fbc053 100644 --- a/resources/views/themes/zeus/dynamic-dashboard/widgets/FaqWidget.blade.php +++ b/resources/views/themes/zeus/dynamic-dashboard/widgets/FaqWidget.blade.php @@ -1,7 +1,7 @@ -
+
@if($data['faqs'] !== null) @foreach($data['faqs'] as $faq) - +

{{ $faq->question }}

diff --git a/resources/views/themes/zeus/dynamic-dashboard/widgets/FormsWidget.blade.php b/resources/views/themes/zeus/dynamic-dashboard/widgets/FormsWidget.blade.php index d59fbaa..a44ed50 100644 --- a/resources/views/themes/zeus/dynamic-dashboard/widgets/FormsWidget.blade.php +++ b/resources/views/themes/zeus/dynamic-dashboard/widgets/FormsWidget.blade.php @@ -1,7 +1,7 @@
@if($data['form_slug'] !== null) @php - $checkForm = \LaraZeus\Bolt\BoltPlugin::getModel('Form')::whereSlug($data['form_slug'])->first(); + $checkForm = config('zeus-bolt.models.Form')::whereSlug($data['form_slug'])->first(); @endphp @if($checkForm !== null) diff --git a/resources/views/themes/zeus/dynamic-dashboard/widgets/HeadingWidget.blade.php b/resources/views/themes/zeus/dynamic-dashboard/widgets/HeadingWidget.blade.php index f29ce89..0ad9f2f 100644 --- a/resources/views/themes/zeus/dynamic-dashboard/widgets/HeadingWidget.blade.php +++ b/resources/views/themes/zeus/dynamic-dashboard/widgets/HeadingWidget.blade.php @@ -1,6 +1,3 @@ -
- -
+
{!! str($data['content'])->markdown() !!}
-
diff --git a/resources/views/themes/zeus/dynamic-dashboard/widgets/ImageWidget.blade.php b/resources/views/themes/zeus/dynamic-dashboard/widgets/ImageWidget.blade.php index b59d3ae..0a69428 100644 --- a/resources/views/themes/zeus/dynamic-dashboard/widgets/ImageWidget.blade.php +++ b/resources/views/themes/zeus/dynamic-dashboard/widgets/ImageWidget.blade.php @@ -1,4 +1,4 @@ -
+
@if(isset($data['url'])) {{ $data['alt'] }} @endif diff --git a/resources/views/themes/zeus/dynamic-dashboard/widgets/PostsWidget.blade.php b/resources/views/themes/zeus/dynamic-dashboard/widgets/PostsWidget.blade.php index 354ac7d..24880f6 100644 --- a/resources/views/themes/zeus/dynamic-dashboard/widgets/PostsWidget.blade.php +++ b/resources/views/themes/zeus/dynamic-dashboard/widgets/PostsWidget.blade.php @@ -1,4 +1,4 @@ -
+
@foreach($data['posts'] as $post) @if($post->image() !== null && $data['show_thumbnail']) diff --git a/src/Livewire/Layouts.php b/src/Livewire/Layouts.php index bee7848..932c4fa 100644 --- a/src/Livewire/Layouts.php +++ b/src/Livewire/Layouts.php @@ -3,7 +3,6 @@ namespace LaraZeus\DynamicDashboard\Livewire; use Illuminate\View\View; -use LaraZeus\DynamicDashboard\DynamicDashboardPlugin; use LaraZeus\DynamicDashboard\Models\Layout; use Livewire\Component; @@ -13,8 +12,8 @@ class Layouts extends Component public function mount(?string $slug = null): void { - $l = $slug ?? DynamicDashboardPlugin::get()->getDefaultLayout(); - $this->dashLayout = DynamicDashboardPlugin::get()->getModel('Layout')::where('layout_slug', $l)->firstOrFail(); + $l = $slug ?? config('zeus-dynamic-dashboard.defaultLayout'); + $this->dashLayout = config('zeus-dynamic-dashboard.models.Layout')::where('layout_slug', $l)->firstOrFail(); } public function render(): View diff --git a/src/Widgets/Classes/FaqWidget.php b/src/Widgets/Classes/FaqWidget.php index 7d08745..b0c621c 100644 --- a/src/Widgets/Classes/FaqWidget.php +++ b/src/Widgets/Classes/FaqWidget.php @@ -46,7 +46,7 @@ public function viewData(array $data): array { return [ // @phpstan-ignore-next-line - 'faqs' => ($data['faq_cat'] !== null) ? \LaraZeus\Sky\SkyPlugin::get()->getModel('Faq')::withAnyTags([$data['faq_cat']], 'faq')->get() : null, + 'faqs' => ($data['faq_cat'] !== null) ? config('zeus-sky.models.Faq')::withAnyTags([$data['faq_cat']], 'faq')->get() : null, ]; } } diff --git a/src/Widgets/Classes/LibraryWidget.php b/src/Widgets/Classes/LibraryWidget.php index 63699f7..92f988d 100644 --- a/src/Widgets/Classes/LibraryWidget.php +++ b/src/Widgets/Classes/LibraryWidget.php @@ -46,7 +46,7 @@ public function viewData(array $data): array { return [ // @phpstan-ignore-next-line - 'library' => ($data['library_slug'] !== null) ? \LaraZeus\Sky\SkyPlugin::get()->getModel('Library')::withAnyTags([$data['library_slug']], 'library')->get() : null, + 'library' => ($data['library_slug'] !== null) ? config('zeus-sky.models.Library')::withAnyTags([$data['library_slug']], 'library')->get() : null, ]; } } diff --git a/src/Widgets/Classes/MenuWidget.php b/src/Widgets/Classes/MenuWidget.php index 72bfb81..20611ee 100644 --- a/src/Widgets/Classes/MenuWidget.php +++ b/src/Widgets/Classes/MenuWidget.php @@ -49,7 +49,7 @@ public function viewData(array $data): array { return [ // @phpstan-ignore-next-line - 'menu' => ($data['menu_slug'] !== null) ? \LaraZeus\Sky\SkyPlugin::get()->getModel('Navigation')::fromHandle($data['menu_slug']) : null, + 'menu' => ($data['menu_slug'] !== null) ? config('zeus-sky.models.Navigation')::fromHandle($data['menu_slug']) : null, ]; } } diff --git a/src/Widgets/Classes/PostsWidget.php b/src/Widgets/Classes/PostsWidget.php index 75984d2..59809e6 100644 --- a/src/Widgets/Classes/PostsWidget.php +++ b/src/Widgets/Classes/PostsWidget.php @@ -50,7 +50,7 @@ public function form(): Builder\Block Select::make('category') // @phpstan-ignore-next-line - ->options(\LaraZeus\Sky\SkyPlugin::get()->getModel('Tag')::query() + ->options(config('zeus-sky.models.Tag')::query() ->withType('category') ->pluck('name', 'id')), @@ -65,11 +65,11 @@ public function form(): Builder\Block public function viewData(array $data): array { // @phpstan-ignore-next-line - $posts = \LaraZeus\Sky\SkyPlugin::get()->getModel('Post')::query(); + $posts = config('zeus-sky.models.Post')::query(); if ($data['category'] !== null) { // @phpstan-ignore-next-line - $category = \LaraZeus\Sky\SkyPlugin::get()->getModel('Tag')::where('type', 'category')->find($data['category']); + $category = config('zeus-sky.models.Tag')::where('type', 'category')->find($data['category']); if ($category !== null) { $posts = $category->postsPublished(); }