Skip to content

Commit 16c919d

Browse files
authored
WIP: Demonstrate Hierarchy Functions (#388)
Provides an example of an hierarchy function as `ListReport` and `ValueHelp` - currently only READ - only on HANA Changes: - `LineItem parent.name` is removed from `app/common.cds`, because it leads to OData requests with `$expand` for an hierarchy function which are not supported yet - `sap.common.CodeList` aspect was removed from `Genres` entity because it provides `ValueHelp` dialog implicitly through annotation [@cds.odata.valuelist](https://pages.github.tools.sap/cap/docs/advanced/fiori#convenience-option-cds-odata-valuelist). It also uses the annotation `@cds.autoexpose`, because of this entity `Genres` should be exposed explicitly in `CatalogService` and `ReviewService` after `sap.common.CodeList` is removed. - renaming in the view `GenreHierarchy` is temporal and will be solved by CAP Java team in the future ``` node as node_id, parent_node as parent_id ``` - 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]>
1 parent d36d232 commit 16c919d

18 files changed

+405
-107
lines changed

app/admin/fiori-service.cds

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,33 @@ annotate AdminService.Books with @(UI : {
5454
]}
5555
});
5656

57+
// Add Value Help for Tree Table
58+
annotate AdminService.Books with {
59+
genre @(Common: {
60+
Label : 'Genre',
61+
ValueList: {
62+
CollectionPath : 'GenreHierarchy',
63+
Parameters : [
64+
{
65+
$Type : 'Common.ValueListParameterDisplayOnly',
66+
ValueListProperty: 'name',
67+
}],
68+
PresentationVariantQualifier: 'VH',
69+
}
70+
});
71+
}
72+
73+
annotate AdminService.GenreHierarchy with @UI: {
74+
PresentationVariant #VH: {
75+
$Type : 'UI.PresentationVariantType',
76+
Visualizations : ['@UI.LineItem'],
77+
RecursiveHierarchyQualifier: 'GenreHierarchy'
78+
},
79+
LineItem : [{
80+
$Type: 'UI.DataField',
81+
Value: name,
82+
}]
83+
};
5784

5885
////////////////////////////////////////////////////////////
5986
//

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: node_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>

app/genres/webapp/manifest.json

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
"_version": "1.8.0",
3+
"sap.app": {
4+
"id": "genres",
5+
"type": "application",
6+
"title": "{{appTitle}}",
7+
"description": "{{appDescription}}",
8+
"applicationVersion": {
9+
"version": "1.0.0"
10+
},
11+
"dataSources": {
12+
"AdminService": {
13+
"uri": "/api/admin/",
14+
"type": "OData",
15+
"settings": {
16+
"odataVersion": "4.0"
17+
}
18+
}
19+
},
20+
"-sourceTemplate": {
21+
"id": "ui5template.basicSAPUI5ApplicationProject",
22+
"-id": "ui5template.smartTemplate",
23+
"-version": "1.40.12"
24+
},
25+
"crossNavigation": {
26+
"inbounds": {
27+
"Genres-show": {
28+
"signature": {
29+
"parameters": {},
30+
"additionalParameters": "allowed"
31+
},
32+
"semanticObject": "GenreHierarchy",
33+
"action": "show"
34+
}
35+
}
36+
}
37+
},
38+
"sap.ui5": {
39+
"dependencies": {
40+
"minUI5Version": "1.122.0",
41+
"libs": {
42+
"sap.fe.templates": {}
43+
}
44+
},
45+
"models": {
46+
"i18n": {
47+
"type": "sap.ui.model.resource.ResourceModel",
48+
"uri": "i18n/i18n.properties"
49+
},
50+
"": {
51+
"dataSource": "AdminService",
52+
"settings": {
53+
"synchronizationMode": "None",
54+
"operationMode": "Server",
55+
"autoExpandSelect" : true,
56+
"earlyRequests": true,
57+
"groupProperties": {
58+
"default": {
59+
"submit": "Auto"
60+
}
61+
}
62+
}
63+
}
64+
},
65+
"routing": {
66+
"routes": [
67+
{
68+
"pattern": ":?query:",
69+
"name": "GenreHierarchyList",
70+
"target": "GenreHierarchyList"
71+
},
72+
{
73+
"pattern": "GenreHierarchy({key}):?query:",
74+
"name": "GenreHierarchyDetails",
75+
"target": "GenreHierarchyDetails"
76+
}
77+
],
78+
"targets": {
79+
"GenreHierarchyList": {
80+
"type": "Component",
81+
"id": "GenreHierarchyList",
82+
"name": "sap.fe.templates.ListReport",
83+
"options": {
84+
"settings" : {
85+
"entitySet" : "GenreHierarchy",
86+
"navigation" : {
87+
"GenreHierarchy" : {
88+
"detail" : {
89+
"route" : "GenreHierarchyDetails"
90+
}
91+
}
92+
},
93+
"controlConfiguration": {
94+
"@com.sap.vocabularies.UI.v1.LineItem": {
95+
"tableSettings": {
96+
"hierarchyQualifier": "GenreHierarchy",
97+
"type": "TreeTable"
98+
}
99+
}
100+
}
101+
}
102+
}
103+
},
104+
"GenreHierarchyDetails": {
105+
"type": "Component",
106+
"id": "GenreHierarchyDetails",
107+
"name": "sap.fe.templates.ObjectPage",
108+
"options": {
109+
"settings" : {
110+
"entitySet": "GenreHierarchy"
111+
}
112+
}
113+
}
114+
}
115+
},
116+
"contentDensities": {
117+
"compact": true,
118+
"cozy": true
119+
}
120+
},
121+
"sap.ui": {
122+
"technology": "UI5",
123+
"fullWidth": false
124+
},
125+
"sap.fiori": {
126+
"registrationIds": [],
127+
"archeType": "transactional"
128+
}
129+
}

0 commit comments

Comments
 (0)