Skip to content

Commit bde2090

Browse files
etimragoerlereugene-andreev
authored
Demonstrate Hierarchy Functions (#416)
Provides an example of an hierarchy function as `ListReport` and `ValueHelp` - currently only `READ` - to [enable tree tables](https://ui5.sap.com//#/topic/7cf7a31fd1ee490ab816ecd941bd2f1f) as `ListReport` add to `manifest.json`: ``` "tableSettings": { "type": "TreeTable", "hierarchyQualifier": "NodesHierarchy", ... } ``` - to enable tree table for ValueHelp hierarchical entity should be annotated with `PresentationVariant` and root entity with `PresentationVariantQualifier` --------- Co-authored-by: D070615 <[email protected]> Co-authored-by: Adrian Görler <[email protected]> Co-authored-by: Evgeny Andreev <[email protected]>
1 parent a195f0e commit bde2090

24 files changed

+1103
-141
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ User Interface related Features:
9090
- [Model Localization](https://cap.cloud.sap/docs/guides/i18n) for [English](app/_i18n/i18n.properties) and [German](app/_i18n/i18n_de.properties) language for static texts
9191
- [Custom File Upload extension](app/admin/webapp/extension/Upload.js) which provides a button for uploading `CSV` files
9292
- A simple Swagger UI for the CatalogService API at <http://localhost:8080/swagger/index.html>
93+
- UI5 [Tree Table](app/genres/webapp/manifest.json) with Value Help for [GenreHierarchy](app/admin/fiori-service.cds)
94+
- [Custom event handlers](https://cap.cloud.sap/docs/java/provisioning-api) for Tree Table such as the [Custom business logic for GenreHierarchy](srv/src/main/java/my/bookshop/handlers/HierarchyHandler.java).
95+
Please note, that Tree Tables must be used with HANA. Custom event handler in this case provides a limited support ment for local testing.
9396

9497
CDS Maven Plugin Features:
9598

@@ -138,6 +141,14 @@ are defined for local development:
138141
- User: `user`, password: `user` to browse books
139142
- User: `admin`, password: `admin` to manage books and orders
140143

144+
### Testing in hybrid mode
145+
146+
You can test the `GenreHierarchyTest` on H2 using the profile `default` as well as on HANA using the profile `hybrid`
147+
148+
```
149+
cds bind --exec -- mvn clean install -Dspring.profiles.active=hybrid
150+
```
151+
141152
## Using VS Code
142153

143154
VS Code supports the project out-of-the-box, when using the [Extension Pack for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack).

app/admin/fiori-service.cds

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,44 @@ annotate AdminService.Books with @(UI : {
5959
]}
6060
});
6161

62+
// Add Value Help for Tree Table
63+
annotate AdminService.Books with {
64+
genre @(Common: {
65+
Label : 'Genre',
66+
ValueList: {
67+
CollectionPath : 'GenreHierarchy',
68+
Parameters : [
69+
{
70+
$Type : 'Common.ValueListParameterDisplayOnly',
71+
ValueListProperty: 'name',
72+
},
73+
{
74+
$Type : 'Common.ValueListParameterInOut',
75+
LocalDataProperty: genre_ID,
76+
ValueListProperty: 'ID',
77+
}
78+
],
79+
PresentationVariantQualifier: 'VH',
80+
}
81+
});
82+
}
83+
84+
// Hide ID because of the ValueHelp
85+
annotate AdminService.GenreHierarchy with {
86+
ID @UI.Hidden;
87+
};
88+
89+
annotate AdminService.GenreHierarchy with @UI: {
90+
PresentationVariant #VH: {
91+
$Type : 'UI.PresentationVariantType',
92+
Visualizations : ['@UI.LineItem'],
93+
RecursiveHierarchyQualifier: 'GenreHierarchy'
94+
},
95+
LineItem : [{
96+
$Type: 'UI.DataField',
97+
Value: name,
98+
}]
99+
};
62100

63101
////////////////////////////////////////////////////////////
64102
//

app/appconfig/fioriSandboxConfig.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
"title": "Browse Books",
2121
"description": "Find your favorite book"
2222
}
23+
}, {
24+
"id": "browse-genres",
25+
"tileType": "sap.ushell.ui.tile.StaticTile",
26+
"properties": {
27+
"targetURL": "#Genres-display",
28+
"title": "Browse Genres",
29+
"description": "Find your favorite genre"
30+
}
2331
}
2432
]
2533
},
@@ -112,6 +120,19 @@
112120
"url": "/browse/webapp"
113121
}
114122
},
123+
"browse-genres": {
124+
"semanticObject": "Genres",
125+
"action": "display",
126+
"signature": {
127+
"parameters": {},
128+
"additionalParameters": "allowed"
129+
},
130+
"resolutionResult": {
131+
"applicationType": "SAPUI5",
132+
"additionalInformation": "SAPUI5.Component=genres",
133+
"url": "/genres/webapp"
134+
}
135+
},
115136
"manage-books": {
116137
"semanticObject": "Books",
117138
"action": "manage",

app/common.cds

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,8 @@ annotate my.Genres with
177177
UI : {
178178
SelectionFields : [name],
179179
LineItem : [
180-
{Value : name},
181-
{
182-
Value : parent.name,
183-
Label : 'Main Genre'
180+
{Value : name,
181+
Label : '{i18n>Name}',
184182
},
185183
],
186184
}
@@ -199,12 +197,7 @@ annotate my.Genres with
199197
TypeNamePlural : '{i18n>Genres}',
200198
Title : {Value : name},
201199
Description : {Value : ID}
202-
},
203-
Facets : [{
204-
$Type : 'UI.ReferenceFacet',
205-
Label : '{i18n>SubGenres}',
206-
Target : 'children/@UI.LineItem'
207-
}, ],
200+
}
208201
});
209202

210203

app/genres/fiori-service.cds

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
UI annotations for the Browse GenreHierarchy App
3+
*/
4+
5+
using AdminService from '../../srv/admin-service';
6+
7+
8+
annotate AdminService.GenreHierarchy with @Aggregation.RecursiveHierarchy#GenreHierarchy: {
9+
$Type: 'Aggregation.RecursiveHierarchyType',
10+
NodeProperty: ID, // identifies a node
11+
ParentNavigationProperty: parent // navigates to a node's parent
12+
};
13+
14+
annotate AdminService.GenreHierarchy with @Hierarchy.RecursiveHierarchy#GenreHierarchy: {
15+
$Type: 'Hierarchy.RecursiveHierarchyType',
16+
// ExternalKey : null,
17+
LimitedDescendantCount: LimitedDescendantCount,
18+
DistanceFromRoot: DistanceFromRoot,
19+
DrillState: DrillState,
20+
Matched: Matched,
21+
MatchedDescendantCount: MatchedDescendantCount,
22+
LimitedRank: LimitedRank
23+
};

app/genres/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "genres",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC"
12+
}

app/genres/webapp/Component.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sap.ui.define(["sap/fe/core/AppComponent"], ac => ac.extend("genres.Component", {
2+
metadata:{ manifest:'json' }
3+
}))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
appTitle=Browse Genres
2+
appDescription=Genres as Tree View
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
appTitle=Zeige Genres
2+
appDescription=Genres als Baumansicht

app/genres/webapp/index.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<title>Browse Genres</title>
8+
<style>
9+
html, body, body > div, #container, #container-uiarea {
10+
height: 100%;
11+
}
12+
</style>
13+
<script
14+
id="sap-ui-bootstrap"
15+
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
16+
data-sap-ui-theme="sap_fiori_3"
17+
data-sap-ui-resourceroots='{
18+
"genres": "./"
19+
}'
20+
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
21+
data-sap-ui-compatVersion="edge"
22+
data-sap-ui-async="true"
23+
data-sap-ui-frameOptions="trusted"
24+
></script>
25+
</head>
26+
<body class="sapUiBody sapUiSizeCompact" id="content">
27+
<div
28+
data-sap-ui-component
29+
data-name="genres"
30+
data-id="container"
31+
data-settings='{"id" : "genres"}'
32+
data-handle-validation="true"
33+
></div>
34+
</body>
35+
</html>

0 commit comments

Comments
 (0)