From 146386c00bdc648673330c0f422d242da77661c4 Mon Sep 17 00:00:00 2001 From: Lars Lauger Date: Mon, 22 May 2023 16:40:18 +0200 Subject: [PATCH] FEATURE: Add select for nodetype field --- .../Controller/NodeTypeFinderController.php | 1 + Classes/Service/NodeTypeFinderService.php | 16 +++++++ .../Fusion/Backend/NodeTypeFinder.fusion | 44 +++++++++++-------- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Classes/Controller/NodeTypeFinderController.php b/Classes/Controller/NodeTypeFinderController.php index 3f2a260..dd574a4 100644 --- a/Classes/Controller/NodeTypeFinderController.php +++ b/Classes/Controller/NodeTypeFinderController.php @@ -43,6 +43,7 @@ protected function initializeView(ViewInterface $view) public function indexAction(?string $searchTerm = null): void { $this->view->assign('searchTerm', $searchTerm); + $this->view->assign('nodeTypes', $this->nodeTypeFinderService->getRelevantNodeTypes()); if (!empty($searchTerm)) { $this->view->assign('occurrences', iterator_to_array($this->search($searchTerm))); diff --git a/Classes/Service/NodeTypeFinderService.php b/Classes/Service/NodeTypeFinderService.php index 523470a..69f8815 100644 --- a/Classes/Service/NodeTypeFinderService.php +++ b/Classes/Service/NodeTypeFinderService.php @@ -3,7 +3,9 @@ namespace Netlogix\NodeTypeFinder\Service; +use Neos\ContentRepository\Domain\Model\NodeType; use Neos\ContentRepository\Domain\Service\ContentDimensionCombinator; +use Neos\ContentRepository\Domain\Service\NodeTypeManager; use Neos\Flow\Annotations as Flow; use Neos\ContentRepository\Domain\Model\NodeInterface; use Neos\Eel\FlowQuery\FlowQuery; @@ -41,6 +43,12 @@ class NodeTypeFinderService */ protected $userService; + /** + * @var NodeTypeManager + * @Flow\Inject + */ + protected $nodeTypeManager; + /** * @param string $nodeTypeName * @param ControllerContext $controllerContext @@ -77,6 +85,14 @@ public function findNodeTypeOccurrences(string $nodeTypeName, ControllerContext return array_values($occurrences); } + public function getRelevantNodeTypes(): array + { + $nodeTypes = $this->nodeTypeManager->getNodeTypes(false); + $nodeTypes = array_filter($nodeTypes, fn (NodeType $nodeType) => $nodeType->isOfType('Neos.Neos:Document') || $nodeType->isOfType('Neos.Neos:Content')); + + return array_map(fn (NodeType $nodeType) => ['name' => $nodeType->getName(), 'label' => $nodeType->getLabel()], $nodeTypes); + } + private function findNodeTypeOccurrencesInAllDimensions(string $nodeTypeName): iterable { $dimensionCombinations = $this->contentDimensionCombinator->getAllAllowedCombinations(); diff --git a/Resources/Private/Fusion/Backend/NodeTypeFinder.fusion b/Resources/Private/Fusion/Backend/NodeTypeFinder.fusion index 828a95e..37e65a3 100644 --- a/Resources/Private/Fusion/Backend/NodeTypeFinder.fusion +++ b/Resources/Private/Fusion/Backend/NodeTypeFinder.fusion @@ -8,7 +8,13 @@ prototype(Netlogix.NodeTypeFinder:BackendModule) < prototype(Neos.Fusion:Compone
- + + + + {nodeType.label ? nodeType.label + ' (' + nodeType.name + ')' : nodeType.name} + + + Search @@ -37,24 +43,24 @@ prototype(Netlogix.NodeTypeFinder:BackendModule) < prototype(Neos.Fusion:Compone } prototype(Netlogix.NodeTypeFinder:BackendModule.Occurrence) < prototype(Neos.Fusion:Component) { - occurrence = ${occurrence} - hiddenProps = Neos.Fusion:DataStructure { - style = Neos.Fusion:Join { - 0 = 'color: #777' - @glue = ';' - } + occurrence = ${occurrence} + hiddenProps = Neos.Fusion:DataStructure { + style = Neos.Fusion:Join { + 0 = 'color: #777' + @glue = ';' + } - @if.hidden = ${occurrence.visible == false} - } + @if.hidden = ${occurrence.visible == false} + } - renderer = afx` - - - - {props.occurrence.label} - - - {props.occurrence.url} - - ` + renderer = afx` + + + + {props.occurrence.label} + + + {props.occurrence.url} + + ` }