[MAGNOLIA-7080] Decorators: Provide possibility to define the order/location of a new configuration item Created: 03/Jul/17  Updated: 05/Mar/21

Status: Accepted
Project: Magnolia
Component/s: configuration
Affects Version/s: 5.5.4
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Christian Ringele Assignee: Unassigned
Resolution: Unresolved Votes: 7
Labels: configuration, decoration, decorator
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Result_Pages_App.png     Zip Archive decorations.zip    
Issue Links:
Relates
relates to MAGNOLIA-7343 Respect order of keys coming from dec... Closed
causality
duplicate
duplicates MGNLUI-6028 View's columns can't be ordered: Espe... Closed
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:
Epic Link: LD Backlog

 Description   

Use case:
A new data column should be added to the pages app's workbench.
One can not define where the new data column would appear, its always the last one of the collection.

Generally:
It is important that when decorating configurations one can define where a new configuration item is added into a map/collection. Especially when its a configuration which is visible to the author -> people are very sensitive on visible items, so where it is located can matter a lot to the customer/author.
Otherwise one ends up fast overriding the whole configuration.

In extends it was solved to adding an empty sibling node before the configuration itself.
This doesn't work for decorators.

On inputs of @Sasha explicit tags might be the best solution:
Something like:

columns:
  sample: !orderAfter='page'

Also we should think of wiping out/removing a node from the target configuration (comparable to the 'override=true' of extends)

Reproduce:
Use this configuration decorating the pages app (I also attach the 'decorations' folder that can be placed into any LM)

subApps:
  browser:
    workbench:
      contentViews:
        tree:
          columns:
            page:
              label: test before
            sample:
              class: info.magnolia.ui.workbench.column.definition.PropertyColumnDefinition
              propertyName: abstract
              label: test
            title:
              label: test after

See the result in the print screen.



 Comments   
Comment by Roman Kovařík [ 25/Aug/17 ]

Another usecase: https://jira.magnolia-cms.com/browse/MGNLDEMO-222?focusedCommentId=147086&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-147086

Comment by Christopher Zimmermann [ 17/Jul/18 ]

This is a really common use case.

Without support for ordering of decoration, in many cases decoration cannot be used.

Comment by Christopher Zimmermann [ 17/Jul/18 ]

Another usecase: reordering fields in a dialog. (for content types)

https://jira.magnolia-cms.com/browse/MGNLUI-4498

Comment by Richard Gange [ 17/Jul/18 ]

Also we should think of wiping out/removing a node from the target configuration (comparable to the 'override=true' of extends)

A lot of times this is handled by using the enabled property. For example, in JCR config we have this one /modules/pages/apps/pages/subApps/browser/workbench/contentViews/tree/columns/path@enabled. If we use something like "override" then that could be a problem when using extends. I would say it's best to leave the override together with extends otherwise we might end up seeing some unforeseen problems for older installations when they upgrade. Instead let's look to provide the enabled property on things we'd like to "turn off" with decorations.

On inputs of @Sasha explicit tags might be the best solution:
Something like:

columns:
  sample: !orderAfter='page'

We would also need orderBefore. But maybe a better solution is just to re-declare the nodes in the decoration in the order you would like to see them. So just use the node names. Kind of like the applauncher layout config.

 

Comment by Christopher Zimmermann [ 23/Jul/18 ]

See this fix for 5.7.1 https://jira.magnolia-cms.com/browse/MAGNOLIA-7343

This fixes the problem described by Christian in ticket description. It is what rgange suggests in the previous comment.

It does not address all use-cases, but it is handy and may work for your case. Applying it to the example here, this works now - note the use of the "!override" directive:

columns: !override
  page:
  sample:
    class: info.magnolia.ui.workbench.column.definition.PropertyColumnDefinition
    propertyName: abstract
    label: test
  title:

 

Comment by Christopher Zimmermann [ 23/Jul/18 ]

OK - based on the comments, I propose the following 3 new directives:
!orderFirst
!orderBefore='page'
!orderAfter='moddate'

Ordering last is the default condition.

Generated at Mon Feb 12 04:20:32 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.