Skip to content
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

BUGFIX: Sort properties in raw content mode #4957

Merged
merged 1 commit into from Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions Neos.Neos/Classes/Fusion/Helper/ArrayHelper.php
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
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)





@@ -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`
<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