Skip to content

Commit

Permalink
Merge pull request #4957 from neos/bugfix/sort-raw-content-properties
Browse files Browse the repository at this point in the history
BUGFIX: Sort properties in raw content mode
  • Loading branch information
Sebobo authored Apr 11, 2024
2 parents 1867f49 + f15a8c0 commit a0d616d
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 a0d616d

Please sign in to comment.