Skip to content

Commit a625566

Browse files
committed
refactor: enhance navigation tree data handling and configuration
1 parent 0e3d1cd commit a625566

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

resources/views/filament/pages/list-navigation.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</x-slot>
2020
@livewire('inspirecms::navigation-tree', [
2121
'category' => $cat,
22-
'activeLocale' => $activeLocale ?? null,
22+
... $this->getNavigationTreeData($cat),
2323
], key($navTreeKey))
2424
</x-filament::section>
2525
@endforeach

resources/views/livewire/navigation-tree.blade.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
@php
2-
$maxDepth = 10;
32
$actions = $this->getAvailableActions();
43
@endphp
54
<div
65
x-data="TreeView({
76
data: $wire.entangle('nodes'),
87
maxDepth: @js($maxDepth),
9-
maxVisibleDepth: @js($maxDepth),
8+
maxVisibleDepth: @js($maxVisibleDepth),
109
enableKeyboardNav: false,
1110
allowDragDrop: true,
1211
allowCrossCategory: false,

src/Filament/Resources/NavigationResource/Pages/ListNavigationTree.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,13 @@ public function updatingActiveLocale($value)
4242
{
4343
$this->dispatch('refreshAllTree');
4444
}
45+
46+
public function getNavigationTreeData($category): array
47+
{
48+
return [
49+
'activeLocale' => $this->getActiveActionsLocale() ?? null,
50+
'maxDepth' => -1,
51+
'maxVisibleDepth' => 20,
52+
];
53+
}
4554
}

src/Livewire/NavigationTree.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class NavigationTree extends Component implements HasActions, HasForms
2727

2828
public string $category;
2929

30+
public int $maxDepth = -1;
31+
32+
public int $maxVisibleDepth = 20;
33+
3034
#[Reactive]
3135
public ?string $activeLocale = null;
3236

@@ -225,6 +229,9 @@ protected function getResource(): string
225229

226230
public function render()
227231
{
228-
return view('inspirecms::livewire.navigation-tree');
232+
return view('inspirecms::livewire.navigation-tree', [
233+
'maxDepth' => $this->maxDepth,
234+
'maxVisibleDepth' => $this->maxVisibleDepth,
235+
]);
229236
}
230237
}

0 commit comments

Comments
 (0)