Skip to content

Commit

Permalink
BUGFIX: Sort properties in raw content mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sebobo committed Apr 11, 2024
1 parent 12c5ac3 commit f15a8c0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
9 changes: 9 additions & 0 deletions Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down
15 changes: 10 additions & 5 deletions Neos.Neos/Documentation/References/EelHelpersReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)




Expand Down Expand Up @@ -2467,8 +2477,3 @@ Get the variable type
* ``variable`` (mixed)

**Return** (string)





Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
prototype(Neos.Neos:RawContent.NodeProperties) < prototype(Neos.Fusion:Component) {
@private {
items = ${node.nodeType.properties}
[email protected] = ${Neos.Array.sortByPropertyPath(value, 'ui.inspector.position')}
}

renderer = afx`
<dl class="neos-raw-content-properties" @if={!String.isBlank(this.content)}>
<Neos.Fusion:Loop items={node.nodeType.properties} itemKey="propertyName" itemName="propertyConfiguration">
<Neos.Fusion:Loop items={private.items} itemKey="propertyName" itemName="propertyConfiguration">
<Neos.Neos:RawContent.NodeProperty propertyName={propertyName} propertyConfiguration={propertyConfiguration}/>
</Neos.Fusion:Loop>
</dl>
Expand Down

0 comments on commit f15a8c0

Please sign in to comment.