Skip to content

Commit 2a724ec

Browse files
committed
streamline tree component actions
1 parent 0f23fc5 commit 2a724ec

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Livewire/BaseContentTreeNode.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@
88
use SolutionForest\InspireCms\Helpers\ContentHelper;
99
use SolutionForest\InspireCms\InspireCmsConfig;
1010
use SolutionForest\InspireCms\Models\Contracts\Content;
11+
use SolutionForest\InspireCms\Support\TreeNode\Concerns\InteractsWithModelExplorer;
12+
use SolutionForest\InspireCms\Support\TreeNode\Contracts\HasModelExplorer;
1113
use SolutionForest\InspireCms\Support\TreeNode\ModelExplorer;
12-
use SolutionForest\InspireCms\Support\TreeNode\ModelExplorerComponent;
14+
use SolutionForest\InspireCms\Support\TreeNode\TreeComponent;
1315

1416
#[Lazy]
15-
abstract class BaseContentTreeNode extends ModelExplorerComponent
17+
abstract class BaseContentTreeNode extends TreeComponent implements HasModelExplorer
1618
{
19+
use InteractsWithModelExplorer {
20+
resolveSelectedModelItems as protected traitResolveSelectedModelItems;
21+
getGroupedNodeItems as protected traitGetGroupedNodeItems;
22+
}
23+
1724
public array $cachedModelExplorerRecords = [];
1825

1926
public bool $filterByPermission = true;
@@ -65,7 +72,7 @@ public function modelExplorer(ModelExplorer $modelExplorer): ModelExplorer
6572

6673
public function getGroupedNodeItems()
6774
{
68-
$items = parent::getGroupedNodeItems();
75+
$items = $this->traitGetGroupedNodeItems();
6976

7077
if (! $this->filterByPermission) {
7178
return $items;
@@ -111,7 +118,7 @@ protected function resolveSelectedModelItems(...$keys)
111118
->filter(fn ($key) => (is_string($key) || is_int($key)) && $this->isValidSelectableModelItemKey($key))
112119
->all();
113120

114-
$recordsToCache = count($missingKeys) > 0 ? parent::resolveSelectedModelItems($missingKeys) : collect();
121+
$recordsToCache = count($missingKeys) > 0 ? $this->traitResolveSelectedModelItems($missingKeys) : collect();
115122

116123
if ($recordsToCache != null) {
117124
foreach ($recordsToCache as $record) {

0 commit comments

Comments
 (0)