Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions fiori/app/common.cds
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,36 @@ annotate my.Books with {

////////////////////////////////////////////////////////////////////////////
//
// Computed Fields for Tree Tables
// Computed Fields for Tree Tables
//
// DISCLAIMER: The below are an alpha version implementation and will change in final release !!!
//
aspect Hierarchy {
LimitedDescendantCount : Integer64 = null;
DistanceFromRoot : Integer64 = null;
LimitedDescendantCount : Int16 = null;
LimitedRank : Int16 = null;
DistanceFromRoot : Int16 = null;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I also tried changing Int64 types to Int16 as discussed → seems to work end-to-end for Fiori clients.

DrillState : String = null;
Matched : Boolean = null;
MatchedDescendantCount : Integer64 = null;
LimitedRank : Integer64 = null;
// Matched : Boolean = null;
// MatchedDescendantCount : Int16 = null;
}

// REVISIT: Do we really need to do that? -> answer shall be: no.
annotate Hierarchy with @Capabilities.FilterRestrictions.NonFilterableProperties: [
'LimitedDescendantCount',
'DistanceFromRoot',
'DrillState',
'Matched',
'MatchedDescendantCount',
// 'Matched',
// 'MatchedDescendantCount',
'LimitedRank'
];

// REVISIT: Do we really need to do that? -> answer shall be: no.
annotate Hierarchy with @Capabilities.SortRestrictions.NonSortableProperties: [
'LimitedDescendantCount',
'DistanceFromRoot',
'DrillState',
'Matched',
'MatchedDescendantCount',
// 'Matched',
// 'MatchedDescendantCount',
'LimitedRank'
];

Expand All @@ -110,21 +112,25 @@ extend my.Genres with Hierarchy;
//
// DISCLAIMER: The below are an alpha version implementation and will change in final release !!!
//
annotate my.Genres with @Aggregation.RecursiveHierarchy #GenreHierarchy: {
$Type : 'Aggregation.RecursiveHierarchyType',
NodeProperty : ID, // identifies a node
ParentNavigationProperty: parent // navigates to a node's parent
};

annotate my.Genres with @Hierarchy.RecursiveHierarchy #GenreHierarchy: {
$Type : 'Hierarchy.RecursiveHierarchyType',
LimitedDescendantCount: LimitedDescendantCount,
DistanceFromRoot : DistanceFromRoot,
DrillState : DrillState,
Matched : Matched,
MatchedDescendantCount: MatchedDescendantCount,
LimitedRank : LimitedRank
};
// Envisioned target annotation for the below:
annotate my.Genres with @Fiori.TreeView #GenreHierarchy .via: parent;

// annotate my.Genres with @Aggregation.RecursiveHierarchy #GenreHierarchy: {
// $Type : 'Aggregation.RecursiveHierarchyType',
// NodeProperty : ID, // identifies a node
// ParentNavigationProperty: parent // navigates to a node's parent
// };

// annotate my.Genres with @Hierarchy.RecursiveHierarchy #GenreHierarchy: {
// $Type : 'Hierarchy.RecursiveHierarchyType',
// LimitedDescendantCount: LimitedDescendantCount,
// DistanceFromRoot : DistanceFromRoot,
// DrillState : DrillState,
// // Matched : Matched,
// // MatchedDescendantCount: MatchedDescendantCount,
// LimitedRank : LimitedRank
// };

annotate my.Genres with @(
readonly,
Expand Down
3 changes: 2 additions & 1 deletion fiori/app/genres/fiori-service.cds
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
All annotations needed for UI5 Tree Table View are located in '../common'
All annotations needed for UI5 Tree Table View are located in '../common'
REVISIT: Why?
*/
16 changes: 16 additions & 0 deletions fiori/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// PoC for simplified Fiori Tree Views
const cds = require('@sap/cds/lib')

cds.on('compile.to.edmx', csn => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also for @Aggregation.RecursiveHierarchy?

Copy link
Copy Markdown
Contributor Author

@danjoa danjoa May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if we replace that by a simplified shortcut, e.g. like that:

annotate AdminService.Genres with @Fiori.TreeView #GenreHierarchy .via: parent;
annotate AdminService.Genres with @Fiori.TreeView #GenreHierarchy { via: parent };

If there's only one Association to self:

annotate AdminService.Genres with @Fiori.TreeView #GenreHierarchy;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoPilot just did that for me in d46956d

const { 'AdminService.Genres': Genres } = csn.definitions

Genres['@Hierarchy.RecursiveHierarchy#GenreHierarchy.$Type'] = 'Hierarchy.RecursiveHierarchyType'
Genres['@Hierarchy.RecursiveHierarchy#GenreHierarchy.LimitedDescendantCount'] = {'=':'LimitedDescendantCount'}
Genres['@Hierarchy.RecursiveHierarchy#GenreHierarchy.DistanceFromRoot'] = {'=':'DistanceFromRoot'}
Genres['@Hierarchy.RecursiveHierarchy#GenreHierarchy.DrillState'] = {'=':'DrillState'}
Genres['@Hierarchy.RecursiveHierarchy#GenreHierarchy.LimitedRank'] = {'=':'LimitedRank'}

Genres['@Aggregation.RecursiveHierarchy#GenreHierarchy.$Type'] = 'Aggregation.RecursiveHierarchyType'
Genres['@Aggregation.RecursiveHierarchy#GenreHierarchy.NodeProperty'] = {'=':'ID'}
Genres['@Aggregation.RecursiveHierarchy#GenreHierarchy.ParentNavigationProperty'] = {'=':'parent'}
})