Skip to content

Commit 63ff0ae

Browse files
Document Tree Views (#2005)
1 parent 3c1235f commit 63ff0ae

File tree

2 files changed

+102
-6
lines changed

2 files changed

+102
-6
lines changed

advanced/fiori.md

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
shorty: Fiori UIs
32
synopsis: >
43
CAP provides out-of-the-box support for SAP Fiori elements front ends.
54
permalink: advanced/fiori
@@ -9,7 +8,7 @@ impl-variants: true
98
uacp: Used as link target from Help Portal at https://help.sap.com/products/BTP/65de2977205c403bbc107264b8eccf4b/e4a7559baf9f4e4394302442745edcd9.html
109
---
1110

12-
# Serving Fiori UIs
11+
# Serving SAP Fiori UIs
1312

1413
{{ $frontmatter.synopsis }}
1514

@@ -23,13 +22,13 @@ This guide explains how to add one or more SAP Fiori elements apps to a CAP proj
2322

2423
## SAP Fiori Preview
2524

26-
For entities exposed via OData V4 there is a _Fiori preview_ link on the index page. It dynamically serves an SAP Fiori Elements list page that allows you to quickly see the effect of annotation changes without having to create a UI application first.
25+
For entities exposed via OData V4 there is a _Fiori preview_ link on the index page. It dynamically serves an SAP Fiori elements list page that allows you to quickly see the effect of annotation changes without having to create a UI application first.
2726

2827
::: details Be aware that this is **not meant for production**.
2928

3029
<div class="impl node">
3130

32-
The preview not meant as a replacement for a proper SAP Fiori Elements (UI5) application.
31+
The preview is not meant as a replacement for a proper SAP Fiori elements (UI5) application.
3332
It is only active locally where the [development profile](../node.js/cds-env#profiles) is enabled.
3433

3534
To also enable it in cloud deployments, for test or demo purposes maybe, set <Config>cds.fiori.preview:true</Config>.
@@ -38,7 +37,7 @@ To also enable it in cloud deployments, for test or demo purposes maybe, set <Co
3837

3938
<div class="impl java">
4039

41-
The preview not meant as a replacement for a proper SAP Fiori Elements (UI5) application.
40+
The preview is not meant as a replacement for a proper SAP Fiori elements (UI5) application.
4241
It is active by default, but disabled automatically in case the [production profile](../java/developing-applications/configuring#production-profile) is enabled.
4342

4443
To also enable it in cloud deployments, for test or demo purposes maybe, set <Config java>cds.index-page.enabled:true</Config>.
@@ -744,4 +743,101 @@ Cache Control feature is currently supported on the Java runtime only.
744743

745744
<div id="fiori-compat" />
746745

746+
## Hierarchical Tree Views
747+
748+
Recursive hierarchies are parent-child hierarchies, where each entity references its parent and through that defines the hierarchical structure. A common example is a company organization structure or HR reporting, where each employee entity references another employee as a direct report or manager.
749+
750+
Database support for a generic hierarchy implementation by CAP runtimes:
751+
752+
| Runtime\DB | SAP HANA | H2 | PostgreSQL | SQLite |
753+
|-------------|----------|----|------------|--------|
754+
| CAP Java |||| |
755+
| CAP Node.js || |||
756+
757+
758+
### Example
759+
Let's assume we have the following domain model and its projection in a service:
760+
761+
::: code-group
762+
```cds [schema.cds]
763+
namespace my.bookshop;
764+
765+
entity Genres { //...
766+
parent : Association to Genres;
767+
}
768+
```
769+
:::
770+
771+
::: code-group
772+
```cds [AdminService.cds]
773+
service AdminService {
774+
entity Genres as projection on my.bookshop.Genres;
775+
}
776+
```
777+
:::
778+
779+
780+
Annotate/extend the entity in the service as follows:
781+
782+
```cds
783+
// declare a hierarchy with the qualifier "GenresHierarchy"
784+
annotate AdminService.Genres with @Aggregation.RecursiveHierarchy #GenresHierarchy : {
785+
NodeProperty : ID, // identifies a node, usually the key
786+
ParentNavigationProperty : parent // navigates to a node's parent
787+
};
788+
789+
extend AdminService.Genres with @(
790+
// The computed properties expected by Fiori to be present in hierarchy entities
791+
Hierarchy.RecursiveHierarchy #GenresHierarchy : {
792+
LimitedDescendantCount : LimitedDescendantCount,
793+
DistanceFromRoot : DistanceFromRoot,
794+
DrillState : DrillState,
795+
LimitedRank : LimitedRank
796+
},
797+
// Disallow filtering on these properties from Fiori UIs
798+
Capabilities.FilterRestrictions.NonFilterableProperties: [
799+
'LimitedDescendantCount', 'DistanceFromRoot', 'DrillState', 'LimitedRank'
800+
],
801+
// Disallow sorting on these properties from Fiori UIs
802+
Capabilities.SortRestrictions.NonSortableProperties : [
803+
'LimitedDescendantCount', 'DistanceFromRoot', 'DrillState', 'LimitedRank'
804+
],
805+
) columns { // Ensure we can query these columns from the database
806+
null as LimitedDescendantCount : Int16,
807+
null as DistanceFromRoot : Int16,
808+
null as DrillState : String,
809+
null as LimitedRank : Int16
810+
};
811+
```
812+
813+
> Note: When naming the hierarchy qualifier, use the following pattern: <br>
814+
> `<entity name in service>Hierarchy`
815+
816+
Configure the TreeTable in UI5's _manifest.json_ file:
817+
818+
```jsonc
819+
"sap.ui5": { ...
820+
"routing": { ...
821+
"targets": { ...
822+
"GenresList": { ...
823+
"options": {
824+
"settings": { ...
825+
"controlConfiguration": {
826+
"@com.sap.vocabularies.UI.v1.LineItem": {
827+
"tableSettings": {
828+
"hierarchyQualifier": "GenresHierarchy", // [!code focus]
829+
"type": "TreeTable" // [!code focus]
830+
}
831+
}
832+
}
833+
}
834+
}
835+
},
836+
},
837+
},
838+
```
839+
840+
> Note: use the `hierarchyQualifier` declared earlier
841+
747842
<div id="reserved-words" />
843+

menu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
### [AsyncAPI](advanced/publishing-apis/asyncapi)
5656

5757
## [Serving UIs](advanced/fiori)
58-
### [Fiori UIs](advanced/fiori)
58+
### [SAP Fiori UIs](advanced/fiori)
5959

6060
## [Databases](guides/databases)
6161

0 commit comments

Comments
 (0)