From f15a8c02475a1c1b624c3ff8b386e655903f3922 Mon Sep 17 00:00:00 2001 From: Sebastian Helzle Date: Fri, 22 Mar 2024 08:39:06 +0100 Subject: [PATCH] BUGFIX: Sort properties in raw content mode Previously there was no obvious sorting. With this change the sorting option which is also used for the inspector is used to sort the items and therefore giving an option to the integrator on their arrangement. This changes introduces the sortByPosition method into the Neos.Array Eel helper to make the PositionalArraySorter available in Fusion. --- Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php | 9 +++++++++ .../References/EelHelpersReference.rst | 15 ++++++++++----- .../Fusion/RawContent/NodeProperties.fusion | 7 ++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php b/Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php index 65097ab559a..ade31b9fa0f 100644 --- a/Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php @@ -15,6 +15,7 @@ use Neos\Eel\ProtectedContextAwareInterface; use Neos\Flow\Annotations as Flow; use Neos\Utility\ObjectAccess; +use Neos\Utility\PositionalArraySorter; /** * Some Functional Programming Array helpers for Eel contexts @@ -90,6 +91,14 @@ public function groupBy($set, $groupingKey) return $result; } + /** + * Sorts the input array by the $positionProperty of each element. + */ + public function sortByPropertyPath(array $set, $positionPropertyPath = 'position'): array + { + return (new PositionalArraySorter($set, $positionPropertyPath))->toArray(); + } + /** * All methods are considered safe * diff --git a/Neos.Neos/Documentation/References/EelHelpersReference.rst b/Neos.Neos/Documentation/References/EelHelpersReference.rst index 3261a73218d..5005ce26cb8 100644 --- a/Neos.Neos/Documentation/References/EelHelpersReference.rst +++ b/Neos.Neos/Documentation/References/EelHelpersReference.rst @@ -1214,6 +1214,16 @@ The input is assumed to be an array or Collection of objects. Groups this input **Return** (array) +Neos.Array.sortByPropertyPath(set, positionPropertyPath) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The input is assumed to be an array. Sorts this input by the $positionPropertyPath property of each element. + +* ``set`` (array) +* ``positionPropertyPath`` (string) + +**Return** (array) + @@ -2467,8 +2477,3 @@ Get the variable type * ``variable`` (mixed) **Return** (string) - - - - - diff --git a/Neos.Neos/Resources/Private/Fusion/RawContent/NodeProperties.fusion b/Neos.Neos/Resources/Private/Fusion/RawContent/NodeProperties.fusion index 484a54d8702..1f22a265684 100644 --- a/Neos.Neos/Resources/Private/Fusion/RawContent/NodeProperties.fusion +++ b/Neos.Neos/Resources/Private/Fusion/RawContent/NodeProperties.fusion @@ -1,7 +1,12 @@ prototype(Neos.Neos:RawContent.NodeProperties) < prototype(Neos.Fusion:Component) { + @private { + items = ${node.nodeType.properties} + items.@process.sort = ${Neos.Array.sortByPropertyPath(value, 'ui.inspector.position')} + } + renderer = afx`
- +