From 1386c2ec236549865d21995e291f6d5a8536ac1f Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 6 Mar 2026 10:35:40 +0000 Subject: [PATCH] Add card-only mode to skip table view and hide toggle Closes #105 Co-Authored-By: Claude Opus 4.6 --- resources/views/query-table.blade.php | 2 +- resources/views/table.blade.php | 2 +- src/Support/Concerns/WithCardView.php | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/resources/views/query-table.blade.php b/resources/views/query-table.blade.php index ce48788..3c521c1 100644 --- a/resources/views/query-table.blade.php +++ b/resources/views/query-table.blade.php @@ -25,7 +25,7 @@
- @if($this->isCardViewEnabled()) + @if($this->isCardViewEnabled() && ! $this->isCardOnly()) @include('query-builder::components.view-toggle') @endif diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index ae29214..e733284 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -8,7 +8,7 @@ @if($this->isSearchVisible() && $this->searchableColumnsSet() && ! $this->areActionsVisible()) @if($this->isFiltered() || $this->isSearchActive() || $this->rows->count() > 0)
- @if($this->isCardViewEnabled()) + @if($this->isCardViewEnabled() && ! $this->isCardOnly()) @include('query-builder::components.view-toggle') @endif diff --git a/src/Support/Concerns/WithCardView.php b/src/Support/Concerns/WithCardView.php index bc79ea8..da57002 100644 --- a/src/Support/Concerns/WithCardView.php +++ b/src/Support/Concerns/WithCardView.php @@ -13,6 +13,18 @@ public function cardLayout(): ?CardLayout return null; } + public function isCardOnly(): bool + { + return false; + } + + public function mountWithCardView(): void + { + if ($this->isCardOnly() && $this->isCardViewEnabled()) { + $this->viewMode = 'cards'; + } + } + public function toggleViewMode(): void { $this->viewMode = $this->viewMode === 'table' ? 'cards' : 'table';