Skip to content

Commit

Permalink
Merge pull request #68 from sitegeist/tetheredNodes
Browse files Browse the repository at this point in the history
Properly handle tethered nodes
  • Loading branch information
nezaniel authored Nov 17, 2023
2 parents da9ba82 + 48fa93a commit 3e42990
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
1 change: 0 additions & 1 deletion Classes/Command/TaxonomyCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public function taxonomiesCommand(string $vocabulary, string $path = ''): void
if (!$startPoint) {
$this->outputLine('nothing found');
$this->quit(1);
throw new StopCommandException();
}

$subtree = $this->taxonomyService->findSubtree($startPoint);
Expand Down
10 changes: 5 additions & 5 deletions Classes/Service/TaxonomyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\NodeType\NodeTypeNames;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindSubtreeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
Expand Down Expand Up @@ -81,18 +81,18 @@ public function findVocabularyForNode(Node $node): Node
{
$subgraph = $this->crRegistry->subgraphForNode($node);

$ancestors = $subgraph->findAncestorNodes(
$vocabularyNode = $subgraph->findClosestNode(
$node->nodeAggregateId,
FindAncestorNodesFilter::create(
FindClosestNodeFilter::create(
nodeTypes: NodeTypeCriteria::create(
NodeTypeNames::fromArray([ $this->getVocabularyNodeTypeName()]),
NodeTypeNames::createEmpty()
)
)
);

if ($result = $ancestors->first()) {
return $result;
if ($vocabularyNode) {
return $vocabularyNode;
}

throw new \InvalidArgumentException('node seems to be outside of vocabulary');
Expand Down
7 changes: 6 additions & 1 deletion Resources/Private/Fusion/Backend/Form/Taxonomy.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ prototype(Sitegeist.Taxonomy:Form.Taxonomy) < prototype(Neos.Fusion:Component) {
{props.i18nTaxonomy.id('properties.name')}
<span @if={props.defaultTaxonomy}>: {props.defaultTaxonomy.properties.name}</span>
</label>
<Neos.Fusion.Form:Input attributes.class="neos-span6" field.name="name" attributes.required attributes.pattern="[a-z0-9]+" />
<Neos.Fusion.Form:Input
attributes.class="neos-span6"
field.name="name"
attributes.required attributes.pattern="[a-z0-9]+"
attributes.disabled="1" attributes.disabled.@if={props.taxonomyNode.classification.value == 'tethered'}
/>
</div>

<div class="neos-control-group">
Expand Down
8 changes: 7 additions & 1 deletion Resources/Private/Fusion/Backend/Form/Vocabulary.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ prototype(Sitegeist.Taxonomy:Form.Vocabulary) < prototype(Neos.Fusion:Component)
<label class="neos-control-label" for="name">
{props.i18nVocabulary.id('properties.name')}
</label>
<Neos.Fusion.Form:Input attributes.class="neos-span6" field.name="name" attributes.required attributes.pattern="[a-z0-9]+" />
<Neos.Fusion.Form:Input
attributes.class="neos-span6"
field.name="name"
attributes.required attributes.pattern="[a-z0-9]+"
attributes.readonly="1" attributes.readonly.@if={props.vocabularyNode.classification.value == 'tethered'}

/>
</div>

<div class="neos-control-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ prototype(Sitegeist.Taxonomy:Views.Module.Taxonomy.List.Item) < prototype(Neos.F
<i class="fas fa-pencil-alt"></i>
</Neos.Fusion:Link.Action>

<Neos.Fusion:Fragment @if={!props.taxonomySubtree.autoCreated}>
<Neos.Fusion:Fragment @if={props.taxonomySubtree.node.classification.value != 'tethered'}>
&nbsp;
<button class="neos-button neos-button-danger"
title={props.i8n.id('generic.delete')}
Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Fusion/Backend/Views/Vocabulary.List.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ prototype(Sitegeist.Taxonomy:Views.Module.Vocabulary.List) < prototype(Neos.Fusi
<i class="fas fa-pencil-alt"></i>
</Neos.Fusion:Link.Action>

<Neos.Fusion:Fragment @if={!vocabulary.node.autoCreated} >
<Neos.Fusion:Fragment @if={vocabulary.classification.value != 'tethered'} >
&nbsp;
<button class="neos-button neos-button-danger" title={props.i18n.id('generic.delete')} data-toggle="modal" href={'#deleteVocabulary_' + vocabulary.nodeAggregateId.value} data-neos-toggle="tooltip">
<i class="fas fa-trash-alt icon-white"></i>
Expand All @@ -68,7 +68,7 @@ prototype(Sitegeist.Taxonomy:Views.Module.Vocabulary.List) < prototype(Neos.Fusi

</div>

<Neos.Fusion:Fragment @if={!vocabulary.node.autoCreated} >
<Neos.Fusion:Fragment @if={vocabulary.classification.value != 'tethered'} >
<div class="neos-hide" id={'deleteVocabulary_' + vocabulary.nodeAggregateId.value}>
<div class="neos-modal-centered">
<div class="neos-modal-content">
Expand Down

0 comments on commit 3e42990

Please sign in to comment.