-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix copy paste across dimensions #3873
base: 9.0
Are you sure you want to change the base?
Conversation
After thoroughly thinking this through, I decided that moving nodes across dimensions is effectively a copy followed by a delete, thus it CHANGES IDENTITIES of nodes then. This means it will work in all cases, even if the moved node already existed with the same ID in the target dimension. Lateron, we additionally need to expose CreateNodeVariant (which creates connected variants) in the UI as well. Resolves: #4614
9819aec
to
33df996
Compare
if (!$precedingSibling->dimensionSpacePoint->equals($subject->dimensionSpacePoint)) { | ||
// WORKAROUND for MOVE ACROSS DIMENSIONS: | ||
// - we want it to work like a copy/paste, followed by an original delete. | ||
// - This is to ensure the user can use it as expected from text editors, where context | ||
// is not preserved during cut/paste. | ||
// - LATERON, we need to expose CreateNodeVariant (which creates connected variants) in the UI as well. | ||
$command = CopyNodesRecursively::createFromSubgraphAndStartNode( | ||
$contentRepository->getContentGraph($subject->workspaceName)->getSubgraph( | ||
$subject->dimensionSpacePoint, | ||
VisibilityConstraints::withoutRestrictions() | ||
), | ||
$subject->workspaceName, | ||
$subject, | ||
// NOTE: in order to be able to copy/paste across dimensions, we need to use | ||
// the TARGET NODE's DimensionSpacePoint to create the node in the target dimension. | ||
OriginDimensionSpacePoint::fromDimensionSpacePoint($precedingSibling->dimensionSpacePoint), | ||
$parentNodeOfPreviousSibling->aggregateId, | ||
$succeedingSibling?->aggregateId | ||
); | ||
|
||
$contentRepository->handle($command); | ||
|
||
$command = RemoveNodeAggregate::create( | ||
$subject->workspaceName, | ||
$subject->aggregateId, | ||
$subject->dimensionSpacePoint, | ||
NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS, | ||
); | ||
$contentRepository->handle($command); | ||
} else { | ||
$command = MoveNodeAggregate::create( | ||
$subject->workspaceName, | ||
$subject->dimensionSpacePoint, | ||
$subject->aggregateId, | ||
RelationDistributionStrategy::STRATEGY_GATHER_ALL, | ||
$hasEqualParentNode ? null : $parentNodeOfPreviousSibling->aggregateId, | ||
$precedingSibling->aggregateId, | ||
$succeedingSibling?->aggregateId, | ||
); | ||
$contentRepository->handle($command); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im not sure i understand the full implications of this ... as far as i know is move node super well tested and supports a variety of cases to distribute node aggregates and i dont know if we want to trade that in for the use of this CopyNodesRecursively
plus removing the original node?
isnt this supported already by MoveNodeAggregate
or do we need to extend the core?
Found an alternative fix in neos/neos-development-collection#4614 (comment) |
related neos/neos-development-collection#4614
After thoroughly thinking this through, I decided
that moving nodes across dimensions is effectively a copy followed by
a delete, thus it CHANGES IDENTITIES of nodes then.
This means it will work in all cases, even if the moved node already
existed with the same ID in the target dimension.
Lateron, we additionally need to expose CreateNodeVariant (which creates
connected variants) in the UI as well.
Resolves: #4614