@@ -120,112 +120,6 @@ protected function getNodeItemActions(): array
120120 ];
121121 }
122122
123- // public function getNodeItemActionsByNodes(array $nodes): array
124- // {
125- // if (!$this->showNodeActions) {
126- // return [];
127- // }
128-
129- // // Step 1: Generate cache key from node IDs
130- // $cacheKey = $this->generateNodesCacheKey($nodes);
131-
132- // // Step 2: Check if actions are already cached
133- // if (isset($this->nodeActionsCache[$cacheKey])) {
134- // return $this->nodeActionsCache[$cacheKey];
135- // }
136-
137- // // Step 3: Get base actions template
138- // $baseActions = $this->getNodeItemActions();
139- // if (empty($baseActions)) {
140- // return [];
141- // }
142-
143- // // Step 4: Fetch records and apply to actions
144- // $formattedActions = $this->formatActionsWithRecords($baseActions, $nodes);
145-
146- // // Step 5: Cache the formatted actions
147- // $this->nodeActionsCache[$cacheKey] = $formattedActions;
148-
149- // return $formattedActions;
150- // }
151-
152- // protected function generateNodesCacheKey(array $nodes): string
153- // {
154- // $nodeIds = array_column($nodes, 'id');
155- // sort($nodeIds); // Ensure consistent ordering
156- // return md5(implode('|', $nodeIds));
157- // }
158-
159- // /**
160- // * @param array<Action|ActionGroup> $baseActions
161- // * @param array $nodes
162- // * @return array<array>
163- // */
164- // protected function formatActionsWithRecords(array $baseActions, array $nodes): array
165- // {
166- // $formattedActions = [];
167-
168- // $this->nodeRecordsCache = array_merge(
169- // $this->nodeRecordsCache,
170- // $this->getElquentQuery()
171- // ->findMany(
172- // collect($nodes)
173- // ->pluck('id')
174- // ->filter()
175- // ->filter(fn ($id) => !isset($this->nodeRecordsCache[$id]))
176- // ->values()
177- // ->all()
178- // )
179- // ->keyBy(fn ($record) => $record->getKey())
180- // ->all()
181- // );
182-
183- // foreach ($baseActions as $index => $action) {
184- // $formattedActions[$index] = [];
185-
186- // foreach ($nodes as $node) {
187- // $nodeId = $node['id'];
188-
189- // // Get or fetch record for this node
190- // $record = $this->nodeRecordsCache[$nodeId] ?? null;
191-
192- // $formattedActions[$index] = $action->applyTreeNodeRecord($record, $node);
193- // }
194- // }
195-
196- // return $formattedActions;
197- // }
198-
199- // /**
200- // * Clear all caches - useful when data changes
201- // */
202- // public function clearActionCaches(): void
203- // {
204- // $this->nodeActionsCache = [];
205- // $this->nodeRecordsCache = [];
206- // }
207-
208- // /**
209- // * Clear cache for specific nodes
210- // */
211- // public function clearNodeActionCache(array $nodeIds): void
212- // {
213- // // Clear record cache for specific nodes
214- // foreach ($nodeIds as $nodeId) {
215- // unset($this->nodeRecordsCache[$nodeId]);
216- // }
217-
218- // // Clear action caches that might contain these nodes
219- // // This is a simple approach - could be optimized further
220- // $this->nodeActionsCache = [];
221- // }
222-
223- // public function refreshTree(): void
224- // {
225- // $this->clearActionCaches(); // Clear action caches when refreshing
226- // parent::refreshTree();
227- // }
228-
229123 protected function getElquentQuery (): Builder
230124 {
231125 return parent ::getElquentQuery ()
0 commit comments