File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545
4646 @if ($this -> rows -> count () )
4747
48- <div class =" relative overflow-x-auto" >
48+ <div id = " {{ $this -> identifier () } } " class =" relative overflow-x-auto" >
4949 <table class =" w-full text-sm text-left text-gray-500" >
5050 <thead class =" text-xs text-gray-700 uppercase bg-gray-50" >
5151 <tr class =" border-y border-gray-200" >
@@ -166,7 +166,11 @@ class="sr-only ml-2 text-sm font-medium text-gray-900 dark:text-gray-300"></labe
166166
167167 @if ($this -> isPaginated () && $this -> rows -> hasPages () )
168168 <div class =" border-b border-gray-200 shadow-sm" >
169- <div class =" py-2 px-6" >{{ $this -> rows -> links (data : [' scrollTo' => $this -> shouldScroll ()]) } } </div >
169+ @if ($this -> scroll () === true )
170+ <div class =" py-2 px-6" >{{ $this -> rows -> links () } } </div >
171+ @else
172+ <div class =" py-2 px-6" >{{ $this -> rows -> links (data : [' scrollTo' => $this -> scroll ()]) } } </div >
173+ @endif
170174 </div >
171175 @endif
172176 @endif
Original file line number Diff line number Diff line change 2121 @endif
2222 </div >
2323
24- <div >
24+ <div id = " {{ $this -> identifier () } } " >
2525 @if ($this -> rows -> count () )
2626 <div class =" relative overflow-x-auto overflow-y-auto" >
27- <table class =" w-full text-sm text-left text-gray-500" wire:key =" table-1 " >
27+ <table class =" w-full text-sm text-left text-gray-500" wire:key =" {{ $this -> identifier () } } " >
2828 <thead class =" text-xs text-gray-700 uppercase bg-gray-50" >
2929 <tr class =" border-y border-gray-200" >
3030
110110 <div >
111111 @if ($this -> isPaginated () && $this -> rows -> hasPages () )
112112 <div class =" border-b border-gray-200 shadow-sm" >
113- <div class =" py-2 px-6" >{{ $this -> rows -> links (data : [' scrollTo' => $this -> shouldScroll ()]) } } </div >
113+ @if ($this -> scroll () === true )
114+ <div class =" py-2 px-6" >{{ $this -> rows -> links () } } </div >
115+ @else
116+ <div class =" py-2 px-6" >{{ $this -> rows -> links (data : [' scrollTo' => $this -> scroll ()]) } } </div >
117+ @endif
114118 </div >
115119 @endif
116120 </div >
Original file line number Diff line number Diff line change 99use ACTTraining \QueryBuilder \Support \Concerns \WithCaching ;
1010use ACTTraining \QueryBuilder \Support \Concerns \WithColumns ;
1111use ACTTraining \QueryBuilder \Support \Concerns \WithFilters ;
12+ use ACTTraining \QueryBuilder \Support \Concerns \WithIdentifier ;
1213use ACTTraining \QueryBuilder \Support \Concerns \WithIndicator ;
1314use ACTTraining \QueryBuilder \Support \Concerns \WithPagination ;
1415use ACTTraining \QueryBuilder \Support \Concerns \WithQueryBuilder ;
2829
2930abstract class QueryBuilder extends Component
3031{
32+
3133 use WithActions;
3234 use WithCaching;
3335 use WithColumns;
3436 use WithFilters;
37+ use WithIdentifier;
3538 use WithIndicator;
3639 use WithPagination;
3740 use WithQueryBuilder;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ACTTraining \QueryBuilder \Support \Concerns ;
4+
5+ use ACTTraining \QueryBuilder \Support \Actions \BaseAction ;
6+ use Illuminate \Support \Enumerable ;
7+
8+ trait WithIdentifier
9+ {
10+ protected string $ identifier = 'table-builder ' ;
11+
12+ public function identifier (): string
13+ {
14+ return $ this ->identifier ;
15+ }
16+
17+ public function setIdentifier (string $ identifier = 'table-builder ' ): static
18+ {
19+ $ this ->identifier = $ identifier ;
20+
21+ return $ this ;
22+ }
23+
24+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ trait WithPagination
1212
1313 private bool $ paginate = true ;
1414
15- private bool $ scrollToTop = false ;
15+ private bool | string $ scrollTo = false ; //false disables scroll on pagination
1616
1717 public function usePagination ($ usePagination = true ): static
1818 {
@@ -21,16 +21,20 @@ public function usePagination($usePagination = true): static
2121 return $ this ;
2222 }
2323
24- public function scrollToTop ( $ scrollToTop = true ): static
24+ public function shouldScrollTo ( $ scrollTo ): static
2525 {
26- $ this ->scrollToTop = $ scrollToTop ;
26+ $ this ->scrollTo = match ($ scrollTo ) {
27+ 'top ' => true ,
28+ 'none ' => false ,
29+ default => $ scrollTo ,
30+ };
2731
2832 return $ this ;
2933 }
3034
31- public function shouldScroll (): bool
35+ public function scroll (): bool | string
3236 {
33- return $ this ->scrollToTop ;
37+ return $ this ->scrollTo ;
3438 }
3539
3640 public function pageName ($ pageName = null ): static
Original file line number Diff line number Diff line change 66
77use ACTTraining \QueryBuilder \Support \Concerns \WithColumns ;
88use ACTTraining \QueryBuilder \Support \Concerns \WithFilters ;
9+ use ACTTraining \QueryBuilder \Support \Concerns \WithIdentifier ;
910use ACTTraining \QueryBuilder \Support \Concerns \WithIndicator ;
1011use ACTTraining \QueryBuilder \Support \Concerns \WithMessage ;
1112use ACTTraining \QueryBuilder \Support \Concerns \WithPagination ;
@@ -27,6 +28,7 @@ abstract class TableBuilder extends Component
2728{
2829 use WithColumns;
2930 use WithFilters;
31+ use WithIdentifier;
3032 use WithIndicator;
3133 use WithMessage;
3234 use WithPagination;
You can’t perform that action at this time.
0 commit comments