From 117649313d55120c5f0d5a0ff59ff1212392437e Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 14:22:24 +0100 Subject: [PATCH 1/9] :sparkles: allow for scroll to selector --- resources/views/report.blade.php | 2 +- resources/views/table.blade.php | 2 +- src/Support/Concerns/WithPagination.php | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/views/report.blade.php b/resources/views/report.blade.php index 34ce276..8f9d4f2 100644 --- a/resources/views/report.blade.php +++ b/resources/views/report.blade.php @@ -166,7 +166,7 @@ class="sr-only ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">isPaginated() && $this->rows->hasPages())
-
{{ $this->rows->links(data: ['scrollTo' => $this->shouldScroll()]) }}
+
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
@endif @endif diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index 30d3cb7..d70d7df 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -110,7 +110,7 @@
@if($this->isPaginated() && $this->rows->hasPages())
-
{{ $this->rows->links(data: ['scrollTo' => $this->shouldScroll()]) }}
+
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
@endif
diff --git a/src/Support/Concerns/WithPagination.php b/src/Support/Concerns/WithPagination.php index a7b7144..dde3962 100644 --- a/src/Support/Concerns/WithPagination.php +++ b/src/Support/Concerns/WithPagination.php @@ -12,7 +12,7 @@ trait WithPagination private bool $paginate = true; - private bool $scrollToTop = false; + private bool|string $scrollTo = false; //false disables scroll on pagination public function usePagination($usePagination = true): static { @@ -21,16 +21,16 @@ public function usePagination($usePagination = true): static return $this; } - public function scrollToTop($scrollToTop = true): static + public function scrollTo($scrollTo = true): static { - $this->scrollToTop = $scrollToTop; + $this->scrollTo = $scrollTo; return $this; } - public function shouldScroll(): bool + public function scroll(): bool|string { - return $this->scrollToTop; + return $this->scrollTo; } public function pageName($pageName = null): static From 99bed9000073ac754b79eec1a57637ce5f828db1 Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 14:41:54 +0100 Subject: [PATCH 2/9] wip --- src/Support/Concerns/WithPagination.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Support/Concerns/WithPagination.php b/src/Support/Concerns/WithPagination.php index dde3962..825dc9b 100644 --- a/src/Support/Concerns/WithPagination.php +++ b/src/Support/Concerns/WithPagination.php @@ -21,9 +21,13 @@ public function usePagination($usePagination = true): static return $this; } - public function scrollTo($scrollTo = true): static + public function shouldScrollTo($scrollTo): static { - $this->scrollTo = $scrollTo; + $this->scrollTo = match ($scrollTo) { + 'top' => true, + 'none' => false, + default => $scrollTo, + }; return $this; } From 07acc52e11aab9169a787df1370a56746e2ae1ef Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 14:49:22 +0100 Subject: [PATCH 3/9] wip --- resources/views/report.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/report.blade.php b/resources/views/report.blade.php index 8f9d4f2..485730c 100644 --- a/resources/views/report.blade.php +++ b/resources/views/report.blade.php @@ -166,6 +166,7 @@ class="sr-only ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">isPaginated() && $this->rows->hasPages())
+ @ray($this->scroll())
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
@endif From 13d28c9ba5731501d3f1e37560ca6664ff4532b4 Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 14:49:55 +0100 Subject: [PATCH 4/9] wip --- resources/views/report.blade.php | 1 - resources/views/table.blade.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/report.blade.php b/resources/views/report.blade.php index 485730c..8f9d4f2 100644 --- a/resources/views/report.blade.php +++ b/resources/views/report.blade.php @@ -166,7 +166,6 @@ class="sr-only ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">isPaginated() && $this->rows->hasPages())
- @ray($this->scroll())
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
@endif diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index d70d7df..3b7ffbb 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -110,6 +110,7 @@
@if($this->isPaginated() && $this->rows->hasPages())
+ @ray($this->scroll())
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
@endif From 4ec162b8488ec0d2cabfe8c9d8d82fb7e68e4254 Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 14:53:36 +0100 Subject: [PATCH 5/9] wip --- resources/views/table.blade.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index 3b7ffbb..a92a8d4 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -110,8 +110,7 @@
@if($this->isPaginated() && $this->rows->hasPages())
- @ray($this->scroll()) -
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
+
{{ $this->rows->links(data: ['scrollTo' => (bool) $this->scroll()]) }}
@endif
From ea0797ceb1513d50dd737040fec72adbd0fb6d78 Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 14:56:03 +0100 Subject: [PATCH 6/9] wip --- resources/views/table.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index a92a8d4..d2f406b 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -110,7 +110,7 @@
@if($this->isPaginated() && $this->rows->hasPages())
-
{{ $this->rows->links(data: ['scrollTo' => (bool) $this->scroll()]) }}
+
{{ $this->rows->links(data: ['scrollTo' => true]) }}
@endif
From 7771bb0780363f6c621fd8603367ae1b031531e6 Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 14:57:43 +0100 Subject: [PATCH 7/9] wip --- resources/views/table.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index d2f406b..44d67da 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -110,7 +110,7 @@
@if($this->isPaginated() && $this->rows->hasPages())
-
{{ $this->rows->links(data: ['scrollTo' => true]) }}
+
{{ $this->rows->links() }}
@endif
From e4779014678050f766cc6ffe8ff9076a0b86ead9 Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 15:00:42 +0100 Subject: [PATCH 8/9] wip --- resources/views/table.blade.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index 44d67da..aebac42 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -110,7 +110,11 @@
@if($this->isPaginated() && $this->rows->hasPages())
+ @if($this->scroll() === true)
{{ $this->rows->links() }}
+ @else +
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
+ @endif
@endif
From 66d386600d836aebfadebf8cb4a5a9fed60c1b92 Mon Sep 17 00:00:00 2001 From: Simon Barrett Date: Fri, 30 Aug 2024 15:19:26 +0100 Subject: [PATCH 9/9] wip --- resources/views/report.blade.php | 8 ++++++-- resources/views/table.blade.php | 4 ++-- src/QueryBuilder.php | 3 +++ src/Support/Concerns/WithIdentifier.php | 24 ++++++++++++++++++++++++ src/TableBuilder.php | 2 ++ 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/Support/Concerns/WithIdentifier.php diff --git a/resources/views/report.blade.php b/resources/views/report.blade.php index 8f9d4f2..7d74a5b 100644 --- a/resources/views/report.blade.php +++ b/resources/views/report.blade.php @@ -45,7 +45,7 @@ @if($this->rows->count()) -
+
@@ -166,7 +166,11 @@ class="sr-only ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">isPaginated() && $this->rows->hasPages())
-
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
+ @if($this->scroll() === true) +
{{ $this->rows->links() }}
+ @else +
{{ $this->rows->links(data: ['scrollTo' => $this->scroll()]) }}
+ @endif
@endif @endif diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index aebac42..f1e9147 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -21,10 +21,10 @@ @endif -
+
@if($this->rows->count())
-
+
diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 6afae74..847467d 100755 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -9,6 +9,7 @@ use ACTTraining\QueryBuilder\Support\Concerns\WithCaching; use ACTTraining\QueryBuilder\Support\Concerns\WithColumns; use ACTTraining\QueryBuilder\Support\Concerns\WithFilters; +use ACTTraining\QueryBuilder\Support\Concerns\WithIdentifier; use ACTTraining\QueryBuilder\Support\Concerns\WithIndicator; use ACTTraining\QueryBuilder\Support\Concerns\WithPagination; use ACTTraining\QueryBuilder\Support\Concerns\WithQueryBuilder; @@ -28,10 +29,12 @@ abstract class QueryBuilder extends Component { + use WithActions; use WithCaching; use WithColumns; use WithFilters; + use WithIdentifier; use WithIndicator; use WithPagination; use WithQueryBuilder; diff --git a/src/Support/Concerns/WithIdentifier.php b/src/Support/Concerns/WithIdentifier.php new file mode 100644 index 0000000..0c44baa --- /dev/null +++ b/src/Support/Concerns/WithIdentifier.php @@ -0,0 +1,24 @@ +identifier; + } + + public function setIdentifier(string $identifier = 'table-builder'): static + { + $this->identifier = $identifier; + + return $this; + } + +} diff --git a/src/TableBuilder.php b/src/TableBuilder.php index 7ef2e04..307679a 100755 --- a/src/TableBuilder.php +++ b/src/TableBuilder.php @@ -6,6 +6,7 @@ use ACTTraining\QueryBuilder\Support\Concerns\WithColumns; use ACTTraining\QueryBuilder\Support\Concerns\WithFilters; +use ACTTraining\QueryBuilder\Support\Concerns\WithIdentifier; use ACTTraining\QueryBuilder\Support\Concerns\WithIndicator; use ACTTraining\QueryBuilder\Support\Concerns\WithMessage; use ACTTraining\QueryBuilder\Support\Concerns\WithPagination; @@ -27,6 +28,7 @@ abstract class TableBuilder extends Component { use WithColumns; use WithFilters; + use WithIdentifier; use WithIndicator; use WithMessage; use WithPagination;