[MGNLUI-7003] Datasource ordering not working without allowedNodeTypes being defined Created: 05/Jan/22  Updated: 08/Sep/22  Resolved: 08/Sep/22

Status: Closed
Project: Magnolia UI
Component/s: dialogs, forms
Affects Version/s: 6.2.15, 6.2.20
Fix Version/s: 6.3.0, 6.2.24

Type: Bug Priority: Neutral
Reporter: Roberto Gaona Assignee: Antonín Juran
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
Problem/Incident
causality
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLUI-7467 Implementation Sub-task Closed Antonín Juran  
MGNLUI-7482 Code review Sub-task Completed Roman Kovařík  
MGNLUI-7483 Pre-integration QA Sub-task Completed Jaromir Sarf  
MGNLUI-7484 Final QA Sub-task Completed Adam Siska  
MGNLUI-7501 Write unit tests Sub-task Completed Antonín Juran  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Date of First Response:
Epic Link: Nucleus Regular Maintenance
Sprint: Nucleus 18
Story Points: 3
Team: Nucleus

 Description   

Steps to reproduce

  1. Add the following definition to any linkField (can be tested on demo page):
      datasource:
          $type: jcrDatasource
          workspace: category
          rootPath: /destinations
          includeProperties: true
          describeByProperty: displayName 
          sortBy:
            displayName: descending 
  1. Open such element dialog and check the generated list.

Expected results

List appears ordered as stated on the definition.

Actual results

List won't appear ordered unless allowedNodeTypes is defined.

Workaround

Adding the allowedNodeTypes parameter allows the list to be properly ordered:

      datasource:
          $type: jcrDatasource
          workspace: category
          rootPath: /destinations
          includeProperties: true
          allowedNodeTypes:
            - mgnl:folder
            - mgnl:category
          describeByProperty: displayName 
          sortBy:
            displayName: descending 

Development notes



 Comments   
Comment by Roman Kovařík [ 23/Aug/22 ]

Discovery:

  • Without specifying the node types, the combo/link fields use HierarchicalDataProvider to show only the root nodes
  • Sorting is currently supported only with JcrDataProvider
  • To support sorting in HierarchicalJcrDataProvider:
    • In info.magnolia.ui.field.JcrSelectFieldSupport#getDataProvider
      • Call com.vaadin.data.provider.BackEndDataProvider#setSortOrders(java.util.List<com.vaadin.data.provider.QuerySortOrder>)
    • In info.magnolia.ui.contentapp.HierarchicalJcrDataProvider#fetchChildrenFromBackEnd
      • sort the stream for each QuerySortOrder
      • use Comparator#comparing(node ->PropertyUtil.getString((Node) item, sortOrder.getSorted(), "")
      • add a logic for jcrPath property as well
Generated at Mon Feb 12 09:42:10 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.