@@ -16,8 +16,6 @@ public function mountWithReordering(): void
16
16
if (! $ this ->reorderEnabled && $ this ->hasReorderingSession ()) {
17
17
$ this ->forgetReorderingSession ();
18
18
}
19
-
20
- $ this ->setReorderingProperties ();
21
19
}
22
20
23
21
public function enableReordering (): void
@@ -51,6 +49,9 @@ private function setReorderingProperties(): void
51
49
{
52
50
if ($ this ->hasReorderingSession ()) {
53
51
$ this ->reordering = true ;
52
+
53
+ $ this ->setReorderingBackup ();
54
+
54
55
$ this ->bulkActionsEnabled = false ;
55
56
$ this ->selectPage = false ;
56
57
$ this ->selectAll = false ;
@@ -68,6 +69,7 @@ private function setReorderingProperties(): void
68
69
$ this ->resetPage ();
69
70
} else {
70
71
$ this ->reordering = false ;
72
+
71
73
$ this ->reset ([
72
74
'bulkActionsEnabled ' ,
73
75
'selectPage ' ,
@@ -84,11 +86,66 @@ private function setReorderingProperties(): void
84
86
'perPageAll ' ,
85
87
'perPage ' ,
86
88
]);
89
+
90
+ $ this ->getReorderingBackup ();
87
91
}
88
92
}
89
93
90
94
private function getReorderingSessionKey (): string
91
95
{
92
96
return $ this ->tableName .'-reordering ' ;
93
97
}
98
+
99
+ private function getReorderingBackupSessionKey (): string
100
+ {
101
+ return $ this ->tableName .'-reordering-backup ' ;
102
+ }
103
+
104
+ private function setReorderingBackup (): void
105
+ {
106
+ if (session ()->has ($ this ->getReorderingBackupSessionKey ())) {
107
+ session ()->forget ($ this ->getReorderingBackupSessionKey ());
108
+ }
109
+
110
+ session ([$ this ->getReorderingBackupSessionKey () => [
111
+ 'bulkActionsEnabled ' => $ this ->bulkActionsEnabled ,
112
+ 'selectPage ' => $ this ->selectPage ,
113
+ 'selectAll ' => $ this ->selectAll ,
114
+ 'selected ' => $ this ->selected ,
115
+ 'showSorting ' => $ this ->showSorting ,
116
+ 'sortingEnabled ' => $ this ->sortingEnabled ,
117
+ 'filtersEnabled ' => $ this ->filtersEnabled ,
118
+ 'sorts ' => $ this ->sorts ,
119
+ 'filters ' => $ this ->filters ,
120
+ 'showPagination ' => $ this ->showPagination ,
121
+ 'showPerPage ' => $ this ->showPerPage ,
122
+ 'showSearch ' => $ this ->showSearch ,
123
+ 'perPageAll ' => $ this ->perPageAll ,
124
+ 'perPage ' => $ this ->perPage ,
125
+ 'page ' => $ this ->page ,
126
+ ]]);
127
+ }
128
+
129
+ private function getReorderingBackup (): void
130
+ {
131
+ if (session ()->has ($ this ->getReorderingBackupSessionKey ())) {
132
+ $ save = session ()->get ($ this ->getReorderingBackupSessionKey ());
133
+ $ this ->bulkActionsEnabled = $ save ['bulkActionsEnabled ' ] ?? false ;
134
+ $ this ->selectPage = $ save ['selectPage ' ] ?? false ;
135
+ $ this ->selectAll = $ save ['selectAll ' ] ?? false ;
136
+ $ this ->selected = $ save ['selected ' ] ?? [];
137
+ $ this ->showSorting = $ save ['showSorting ' ] ?? false ;
138
+ $ this ->sortingEnabled = $ save ['sortingEnabled ' ] ?? false ;
139
+ $ this ->filtersEnabled = $ save ['filtersEnabled ' ] ?? false ;
140
+ $ this ->sorts = $ save ['sorts ' ] ?? [];
141
+ $ this ->filters = $ save ['filters ' ] ?? [];
142
+ $ this ->showPagination = $ save ['showPagination ' ] ?? false ;
143
+ $ this ->showPerPage = $ save ['showPerPage ' ] ?? false ;
144
+ $ this ->showSearch = $ save ['showSearch ' ] ?? false ;
145
+ $ this ->perPageAll = $ save ['perPageAll ' ] ?? true ;
146
+ $ this ->perPage = $ save ['perPage ' ] ?? -1 ;
147
+ $ this ->page = $ save ['page ' ] ?? 1 ;
148
+ session ()->forget ($ this ->getReorderingBackupSessionKey ());
149
+ }
150
+ }
94
151
}
0 commit comments