Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{yml,yaml,json,xlf}]
[*.{feature,yml,yaml,json,xlf}]
indent_size = 2

[*.md]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function performSearch(
$matchingNodes = $nodeService->search(
rootNode: $rootNode,
searchTerm: $query->searchTerm,
nodeTypeFilter: $narrowNodeTypeFilter,
nodeTypeFilter: $narrowNodeTypeFilter->isEmpty() ? $baseNodeTypeFilter : $narrowNodeTypeFilter,
);

$treeBuilder = $nodeService->createTreeBuilderForRootNode(
Expand Down
12 changes: 8 additions & 4 deletions Classes/LinkEditor/Infrastructure/ESCR/NodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,20 @@ public function findParentNode(Node $node): ?Node
return $this->subgraph->findParentNode($node->aggregateId);
}

public function findPrecedingSiblingNodes(Node $node): Nodes
public function findPrecedingSiblingNodes(Node $node, NodeTypeFilter $nodeTypeFilter): Nodes
{
$filter = FindPrecedingSiblingNodesFilter::create();
$filter = FindPrecedingSiblingNodesFilter::create(
nodeTypes: $nodeTypeFilter->nodeTypeCriteria,
);

return $this->subgraph->findPrecedingSiblingNodes($node->aggregateId, $filter);
}

public function findSucceedingSiblingNodes(Node $node): Nodes
public function findSucceedingSiblingNodes(Node $node, NodeTypeFilter $nodeTypeFilter): Nodes
{
$filter = FindSucceedingSiblingNodesFilter::create();
$filter = FindSucceedingSiblingNodesFilter::create(
nodeTypes: $nodeTypeFilter->nodeTypeCriteria,
);

return $this->subgraph->findSucceedingSiblingNodes($node->aggregateId, $filter);
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/LinkEditor/Infrastructure/ESCR/NodeTypeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public function getAllowedNodeTypeNames(): NodeTypeNames
return $this->allowedNodeTypeNames;
}

public function toFilterString(): string
public function isEmpty(): bool
{
throw new \Exception(__METHOD__ . ' is not implemented yet!');
return $this->nodeTypeCriteria->explicitlyAllowedNodeTypeNames->isEmpty() && $this->nodeTypeCriteria->explicitlyDisallowedNodeTypeNames->isEmpty();
}

public function isSatisfiedByNode(Node $node): bool
Expand Down
32 changes: 13 additions & 19 deletions Classes/LinkEditor/Infrastructure/ESCR/TreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,24 @@ public function addNodeWithSiblingsAndAncestors(Node $node): self
/** @var Node $parentNode */
$parentTreeNodeBuilder = $addNodeWithSiblingsAndParentRecursively($parentNode);

foreach ($this->nodeService->findPrecedingSiblingNodes($node) as $siblingNode) {
/** @var Node $siblingNode */
if ($this->nodeSearchSpecification->baseNodeTypeFilter->isSatisfiedByNode($siblingNode)) {
$siblingTreeNodeBuilder = $this->addNode($siblingNode);
$siblingTreeNodeBuilder->setHasUnloadedChildren(
$this->nodeService->getNumberOfChildNodes($siblingNode, $this->nodeSearchSpecification->baseNodeTypeFilter->nodeTypeCriteria) > 0,
);

$parentTreeNodeBuilder->addChild($siblingTreeNodeBuilder);
}
foreach ($this->nodeService->findPrecedingSiblingNodes($node, $this->nodeSearchSpecification->baseNodeTypeFilter) as $siblingNode) {
$siblingTreeNodeBuilder = $this->addNode($siblingNode);
$siblingTreeNodeBuilder->setHasUnloadedChildren(
$this->nodeService->getNumberOfChildNodes($siblingNode, $this->nodeSearchSpecification->baseNodeTypeFilter->nodeTypeCriteria) > 0,
);

$parentTreeNodeBuilder->addChild($siblingTreeNodeBuilder);
}

$parentTreeNodeBuilder->addChild($treeNodeBuilder);

foreach ($this->nodeService->findSucceedingSiblingNodes($node) as $siblingNode) {
/** @var Node $siblingNode */
if ($this->nodeSearchSpecification->baseNodeTypeFilter->isSatisfiedByNode($siblingNode)) {
$siblingTreeNodeBuilder = $this->addNode($siblingNode);
$siblingTreeNodeBuilder->setHasUnloadedChildren(
$this->nodeService->getNumberOfChildNodes($siblingNode, $this->nodeSearchSpecification->baseNodeTypeFilter->nodeTypeCriteria) > 0,
);
foreach ($this->nodeService->findSucceedingSiblingNodes($node, $this->nodeSearchSpecification->baseNodeTypeFilter) as $siblingNode) {
$siblingTreeNodeBuilder = $this->addNode($siblingNode);
$siblingTreeNodeBuilder->setHasUnloadedChildren(
$this->nodeService->getNumberOfChildNodes($siblingNode, $this->nodeSearchSpecification->baseNodeTypeFilter->nodeTypeCriteria) > 0,
);

$parentTreeNodeBuilder->addChild($siblingTreeNodeBuilder);
}
$parentTreeNodeBuilder->addChild($siblingTreeNodeBuilder);
}

$parentTreeNodeBuilder->setHasUnloadedChildren(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Feature: GetChildrenForTreeNode
'Neos.Neos:Content':
abstract: true

'Neos.Neos:ContentCollection':
abstract: true

'Neos.Neos:Document':
abstract: true
properties:
Expand All @@ -30,6 +33,9 @@ Feature: GetChildrenForTreeNode
ui:
icon: "my-icon"
label: "My Document Type"
childNodes:
main:
type: "Neos.Neos:ContentCollection"

'Vendor.Site:OtherDocument':
label: "My Other Node"
Expand All @@ -38,6 +44,9 @@ Feature: GetChildrenForTreeNode
ui:
icon: "my-other-icon"
label: "My Other Document Type"
childNodes:
main:
type: "Neos.Neos:ContentCollection"

'Vendor.Site:Content':
superTypes:
Expand Down Expand Up @@ -176,7 +185,7 @@ Feature: GetChildrenForTreeNode
| workspaceName | "live" |
| dimensionValues | {"language": ["en"]} |
| treeNodeId | "feature-a-multi-dsp" |
| nodeTypeFilter | "" |
| nodeTypeFilter | "Neos.Neos:Document" |
| linkableNodeTypes | [] |
Then I expect the following query response:
"""json
Expand Down Expand Up @@ -284,7 +293,7 @@ Feature: GetChildrenForTreeNode
| workspaceName | "live" |
| dimensionValues | {"language": ["de"]} |
| treeNodeId | "features" |
| nodeTypeFilter | "" |
| nodeTypeFilter | "Neos.Neos:Document" |
| linkableNodeTypes | [] |
Then I expect the following query response:
"""json
Expand Down
26 changes: 20 additions & 6 deletions Tests/Behavior/Features/LinkEditor/06-GetTreeQuery.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Feature: GetTreeQuery
'Neos.Neos:Content':
abstract: true

'Neos.Neos:ContentCollection':
abstract: true

'Neos.Neos:Document':
abstract: true
properties:
Expand All @@ -34,6 +37,9 @@ Feature: GetTreeQuery
ui:
icon: "my-icon"
label: "My Document Type"
childNodes:
main:
type: "Neos.Neos:ContentCollection"

'Vendor.Site:OtherDocument':
label: "My Other Node"
Expand All @@ -42,13 +48,19 @@ Feature: GetTreeQuery
ui:
icon: "my-other-icon"
label: "My Other Document Type"
childNodes:
main:
type: "Neos.Neos:ContentCollection"

'Vendor.Site:Content':
superTypes:
'Neos.Neos:Content': true
ui:
icon: "my-content"
label: "My Content"
properties:
text:
type: string

'Vendor.Site:SpecialLinkable':
abstract: true
Expand Down Expand Up @@ -85,6 +97,7 @@ Feature: GetTreeQuery
| features | homepage | Vendor.Site:Document | {"title": "features"} | {"language": "en"} | features |
| features-content | features | Vendor.Site:Content | {} | {"language": "en"} | |
| feature-a-default | features | Vendor.Site:Document | {"title": "a"} | {"language": "en"} | a |
| feature-a-content | feature-a-default | Vendor.Site:Content | {} | {"language": "en"} | |
| feature-a1-default | feature-a-default | Vendor.Site:Document | {"title": "a1"} | {"language": "en"} | leaf |
| feature-a2-default | feature-a-default | Vendor.Site:Document | {"title": "a2"} | {"language": "en"} | |
| feature-b-disabled | features | Vendor.Site:Document | {"title": "b"} | {"language": "en"} | |
Expand All @@ -102,6 +115,7 @@ Feature: GetTreeQuery
| search-a2-other-type | search-a-default | Vendor.Site:OtherDocument | {"title": "a2"} | {"language": "en"} | |
| search-a3-other-text | search-a-default | Vendor.Site:OtherDocument | {"title": "a3 special text"} | {"language": "en"} | |
| search-b-with-text | search | Vendor.Site:Document | {"title": "b special text"} | {"language": "en"} | |
| search-b-content | search-b-with-text | Vendor.Site:Content | {"text": "b' special text"} | {"language": "en"} | |
| search-c-other-type | search | Vendor.Site:OtherDocument | {"title": "c"} | {"language": "en"} | |

And the command CreateNodeVariant is executed with payload:
Expand Down Expand Up @@ -309,7 +323,7 @@ Feature: GetTreeQuery
| dimensionValues | {"language": ["en"]} |
| startingPoint | "/<Neos.Neos:Sites>/site-a/features/a/leaf" |
| loadingDepth | 8 |
| baseNodeTypeFilter | "" |
| baseNodeTypeFilter | "Neos.Neos:Document" |
| linkableNodeTypes | [] |
| narrowNodeTypeFilter | "" |
| searchTerm | "" |
Expand Down Expand Up @@ -884,7 +898,7 @@ Feature: GetTreeQuery
| dimensionValues | {"language": ["en"]} |
| startingPoint | "/<Neos.Neos:Sites>/site-a/features/a/leaf" |
| loadingDepth | 8 |
| baseNodeTypeFilter | "" |
| baseNodeTypeFilter | "Neos.Neos:Document" |
| linkableNodeTypes | [] |
| narrowNodeTypeFilter | "" |
| searchTerm | "" |
Expand Down Expand Up @@ -1034,7 +1048,7 @@ Feature: GetTreeQuery
}
"""

Examples:
| selectedNodeId |
| "feature-a1-default" |
| "feature-a2-default" |
Examples:
| selectedNodeId |
| "feature-a1-default" |
| "feature-a2-default" |
Loading