From 04374b4d6f1562c1face7dbed3ca51c3f710e6cf Mon Sep 17 00:00:00 2001 From: Spitfire Date: Mon, 13 May 2024 14:29:17 -0600 Subject: [PATCH] Bookmarks as H1 and title --- app/Http/Controllers/CrudController.php | 7 +++++++ app/Renderers/DatagridRenderer.php | 10 +++++++++- resources/views/layouts/datagrid/_togglers.blade.php | 10 +++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/CrudController.php b/app/Http/Controllers/CrudController.php index 49ae5c0773..6bfdfff017 100644 --- a/app/Http/Controllers/CrudController.php +++ b/app/Http/Controllers/CrudController.php @@ -251,7 +251,14 @@ public function crudIndex(Request $request) if (empty($data['titleKey'])) { $data['titleKey'] = Module::plural($entityTypeId, __('entities.' . $langKey)); } + // If its a bookmark, override everything else + if ($request->get('bookmark')) { + $bookmark = Bookmark::where('campaign_id', $campaign->id)->where('id', $request->get('bookmark'))->first(); + $this->datagrid->bookmark($bookmark->id); + $data['titleKey'] = $bookmark->name; + } } + if (method_exists($model, 'getParentKeyName')) { $data['nestable'] = $nested; } diff --git a/app/Renderers/DatagridRenderer.php b/app/Renderers/DatagridRenderer.php index 0ed39509cc..f85aadf613 100644 --- a/app/Renderers/DatagridRenderer.php +++ b/app/Renderers/DatagridRenderer.php @@ -25,6 +25,7 @@ class DatagridRenderer protected string $hidden = ' hidden lg:table-cell'; protected array $columns = []; + protected null|int $bookmark = null; protected LengthAwarePaginator|Collection|array $data = []; @@ -59,6 +60,12 @@ public function options(array $options): self return $this; } + public function bookmark(int $bookmark): self + { + $this->bookmark = $bookmark; + return $this; + } + public function models(Collection|LengthAwarePaginator $models): self { $this->models = $models; @@ -246,7 +253,8 @@ private function route(string $field = null, string $label = null) $routeOptions = [ 'campaign' => $this->campaign, 'order' => $field , - 'page' => request()->get('page') + 'page' => request()->get('page'), + 'bookmark' => $this->bookmark ]; if (request()->get('_from', false) == 'quicklink') { $routeOptions['_from'] = 'quicklink'; diff --git a/resources/views/layouts/datagrid/_togglers.blade.php b/resources/views/layouts/datagrid/_togglers.blade.php index d2e844cd89..60d54dcd28 100644 --- a/resources/views/layouts/datagrid/_togglers.blade.php +++ b/resources/views/layouts/datagrid/_togglers.blade.php @@ -7,7 +7,7 @@