Skip to content

Commit 5947b74

Browse files
etimragoerlerbeckermarceugene-andreev
authored
Modification of Hierarchies (#428)
Co-authored-by: D070615 <[email protected]> Co-authored-by: Adrian Görler <[email protected]> Co-authored-by: Marc Becker <[email protected]> Co-authored-by: Evgeny Andreev <[email protected]>
1 parent fcffdec commit 5947b74

32 files changed

+624
-120
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ 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)
93+
- UI5 [Tree Table](app/genres/webapp/manifest.json) with CRUD requests and Value Help for [GenreHierarchy](app/admin/fiori-service.cds). Only on HANA. To check tree table `Contents` embedded into `Books`, please remove `@UI.Hidden` annotation from [Fiori Service](app/admin/fiori-service.cds)
9494
- [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).
9595
Please note, that Tree Tables must be used with HANA. Custom event handler in this case provides a limited support ment for local testing.
96+
- [Custom actions](https://cap.cloud.sap/docs/cds/cdl#actions) such as `moveSibling` in the [Admin Service](srv/admin-service.cds). This action demonstrates experimental UI feature [ChangeNextSiblingAction](https://github.com/SAP/odata-vocabularies/blob/main/vocabularies/Hierarchy.md#template_changenextsiblingaction-experimental). The Action implementation is in the [Hierarchy Sibling Action Handler](srv/src/main/java/my/bookshop/handlers/HierarchySiblingActionHandler.java)
9697

9798
CDS Maven Plugin Features:
9899

app/_i18n/i18n.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Created = Created
55
Modified = Modified
66
ModifiedBy = Modified By
77
General = General
8+
Contents = Contents
89
Details = Details
910
Admin = Administrative
1011
Translations = Translations
@@ -63,7 +64,11 @@ Text = Text
6364
Image = Image
6465
Genres = Genres
6566
Genre = Genre
66-
67+
PageNumber = Page Number
68+
Informations = Informations
69+
Page = Page
70+
ContentsLevel = Contents Level
71+
ContentsLevels = Contents Levels
6772
AddReview = Add Review
6873
6974
Notes = Notes

app/_i18n/i18n_de.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Created = Angelegt
55
Modified = Bearbeitet
66
ModifiedBy = Bearbeitet von
77
General = Generelles
8+
Contents = Buchinhalt
89
Details = Details
910
Admin = Administratives
1011
Translations = Übersetzungen
@@ -63,6 +64,11 @@ Text = Text
6364
Image = Bild
6465
Genres = Genre
6566
Genre = Genre
67+
PageNumber = Seitenzahl
68+
Informations = Informationen
69+
Page = Seite
70+
ContentsLevel = Inhaltsebene
71+
ContentsLevels = Inhaltsebenen
6672

6773
AddReview = Rezension hinzufügen
6874

app/admin/fiori-service.cds

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ annotate AdminService.Books with @(UI : {
3636
$Type : 'UI.ReferenceFacet',
3737
Label : '{i18n>Admin}',
3838
Target : '@UI.FieldGroup#Admin'
39+
},
40+
{
41+
// TODO: should work dynamically
42+
@UI.Hidden,
43+
$Type : 'UI.ReferenceFacet',
44+
Label : '{i18n>Contents}',
45+
Target : 'contents/@UI.PresentationVariant'
3946
}
4047
],
4148
FieldGroup #General : {Data : [
@@ -60,10 +67,14 @@ annotate AdminService.Books with @(UI : {
6067
]}
6168
});
6269

63-
// Add Value Help for Tree Table
70+
71+
////////////////////////////////////////////////////////////////////////////
72+
//
73+
// Value Help for Tree Table
74+
//
6475
annotate AdminService.Books with {
6576
genre @(Common: {
66-
Label : 'Genre',
77+
Label : '{i18n>Genre}',
6778
ValueList: {
6879
CollectionPath : 'GenreHierarchy',
6980
Parameters : [
@@ -87,6 +98,12 @@ annotate AdminService.GenreHierarchy with {
8798
ID @UI.Hidden;
8899
};
89100

101+
@Hierarchy.RecursiveHierarchyActions #GenreHierarchy: {
102+
$Type : 'Hierarchy.RecursiveHierarchyActionsType',
103+
// any name can be the action name with namespace/no bound action name
104+
ChangeNextSiblingAction: 'AdminService.moveSibling',
105+
}
106+
90107
annotate AdminService.GenreHierarchy with @UI: {
91108
PresentationVariant #VH: {
92109
$Type : 'UI.PresentationVariantType',
@@ -96,7 +113,48 @@ annotate AdminService.GenreHierarchy with @UI: {
96113
LineItem : [{
97114
$Type: 'UI.DataField',
98115
Value: name,
99-
}]
116+
Label : '{i18n>Genre}'
117+
}],
118+
};
119+
120+
annotate AdminService.ContentsHierarchy with @UI: {
121+
PresentationVariant : {
122+
$Type : 'UI.PresentationVariantType',
123+
RequestAtLeast: [name],
124+
Visualizations: ['@UI.LineItem'],
125+
},
126+
LineItem : [{
127+
$Type: 'UI.DataField',
128+
Value: name,
129+
Label : '{i18n>Name}'
130+
},
131+
{
132+
$Type: 'UI.DataField',
133+
Value: page,
134+
Label : '{i18n>Page}'
135+
}],
136+
HeaderInfo : {
137+
$Type : 'UI.HeaderInfoType',
138+
TypeName : '{i18n>ContentsLevel}',
139+
TypeNamePlural: '{i18n>ContentsLevels}',
140+
Title : {
141+
$Type: 'UI.DataField',
142+
Value: name,
143+
}
144+
},
145+
FieldGroup : {
146+
$Type: 'UI.FieldGroupType',
147+
Data : [{
148+
$Type: 'UI.DataField',
149+
Value: page,
150+
Label : '{i18n>PageNumber}'
151+
}],
152+
},
153+
Facets : [{
154+
$Type : 'UI.ReferenceFacet',
155+
Target: '@UI.FieldGroup',
156+
Label : '{i18n>Informations}',
157+
}],
100158
};
101159

102160
////////////////////////////////////////////////////////////
@@ -138,6 +196,26 @@ annotate AdminService.Books.texts {
138196
}
139197
}
140198

199+
////////////////////////////////////////////////////////////
200+
//
201+
// Annotations for hierarchy ContentsHierarchy
202+
//
203+
annotate AdminService.ContentsHierarchy with @Aggregation.RecursiveHierarchy#ContentsHierarchy: {
204+
$Type: 'Aggregation.RecursiveHierarchyType',
205+
NodeProperty: ID, // identifies a node
206+
ParentNavigationProperty: parent // navigates to a node's parent
207+
};
208+
209+
annotate AdminService.ContentsHierarchy with @Hierarchy.RecursiveHierarchy#ContentsHierarchy: {
210+
$Type: 'Hierarchy.RecursiveHierarchyType',
211+
LimitedDescendantCount: LimitedDescendantCount,
212+
DistanceFromRoot: DistanceFromRoot,
213+
DrillState: DrillState,
214+
Matched: Matched,
215+
MatchedDescendantCount: MatchedDescendantCount,
216+
LimitedRank: LimitedRank
217+
};
218+
141219
annotate AdminService.Books actions {
142220
@(
143221
Common.SideEffects : {

app/admin/webapp/manifest.json

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"settings": {
5252
"synchronizationMode": "None",
5353
"operationMode": "Server",
54-
"autoExpandSelect" : true,
54+
"autoExpandSelect": true,
5555
"earlyRequests": true,
5656
"groupProperties": {
5757
"default": {
@@ -74,9 +74,9 @@
7474
"target": "BooksDetails"
7575
},
7676
{
77-
"pattern": "Books({key}/author({key2}):?query:",
78-
"name": "AuthorsDetails",
79-
"target": "AuthorsDetails"
77+
"pattern": "Books({key})/contents({key2}):?query:",
78+
"name": "ContentsDetails",
79+
"target": "ContentsDetails"
8080
}
8181
],
8282
"targets": {
@@ -115,22 +115,30 @@
115115
"settings" : {
116116
"contextPath" : "/Books",
117117
"navigation" : {
118-
"Authors" : {
119-
"detail" : {
120-
"route" : "AuthorsDetails"
118+
"contents": {
119+
"detail": {
120+
"route": "ContentsDetails"
121+
}
122+
}
123+
},
124+
"controlConfiguration": {
125+
"contents/@com.sap.vocabularies.UI.v1.LineItem": {
126+
"tableSettings": {
127+
"hierarchyQualifier": "ContentsHierarchy",
128+
"type": "TreeTable"
121129
}
122130
}
123131
}
124132
}
125133
}
126134
},
127-
"AuthorsDetails": {
135+
"ContentsDetails": {
128136
"type": "Component",
129-
"id": "AuthorsDetailsList",
137+
"id": "ContentsDetails",
130138
"name": "sap.fe.templates.ObjectPage",
131139
"options": {
132-
"settings" : {
133-
"contextPath" : "/Authors"
140+
"settings": {
141+
"contextPath": "/Books/contents"
134142
}
135143
}
136144
}

app/appconfig/fioriSandboxConfig.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"title": "Browse Books",
2121
"description": "Find your favorite book"
2222
}
23-
}, {
23+
},
24+
{
2425
"id": "browse-genres",
2526
"tileType": "sap.ushell.ui.tile.StaticTile",
2627
"properties": {
@@ -64,6 +65,15 @@
6465
"title": "Manage Reviews",
6566
"description": "Add/edit/delete reviews"
6667
}
68+
},
69+
{
70+
"id": "manage-genres",
71+
"tileType": "sap.ushell.ui.tile.StaticTile",
72+
"properties": {
73+
"targetURL": "#Genres-manage",
74+
"title": "Manage Genres",
75+
"description": "Add/edit/delete genres"
76+
}
6777
}
6878
]
6979
},
@@ -129,8 +139,8 @@
129139
},
130140
"resolutionResult": {
131141
"applicationType": "SAPUI5",
132-
"additionalInformation": "SAPUI5.Component=genres",
133-
"url": "/genres/webapp"
142+
"additionalInformation": "SAPUI5.Component=browse-genres",
143+
"url": "/browse-genres/webapp"
134144
}
135145
},
136146
"manage-books": {
@@ -146,6 +156,19 @@
146156
"url": "/admin/webapp"
147157
}
148158
},
159+
"manage-genres": {
160+
"semanticObject": "Genres",
161+
"action": "manage",
162+
"signature": {
163+
"parameters": {},
164+
"additionalParameters": "allowed"
165+
},
166+
"resolutionResult": {
167+
"applicationType": "SAPUI5",
168+
"additionalInformation": "SAPUI5.Component=genres",
169+
"url": "/genres/webapp"
170+
}
171+
},
149172
"manage-orders": {
150173
"semanticObject": "Orders",
151174
"action": "manage",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
UI annotations for the Browse GenreHierarchy App
3+
*/
4+
5+
using CatalogService from '../../srv/cat-service';
6+
7+
8+
annotate CatalogService.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 CatalogService.GenreHierarchy with @Hierarchy.RecursiveHierarchy#GenreHierarchy: {
15+
$Type: 'Hierarchy.RecursiveHierarchyType',
16+
LimitedDescendantCount: LimitedDescendantCount,
17+
DistanceFromRoot: DistanceFromRoot,
18+
DrillState: DrillState,
19+
Matched: Matched,
20+
MatchedDescendantCount: MatchedDescendantCount,
21+
LimitedRank: LimitedRank
22+
};

app/browse-genres/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "browse-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+
}
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("browse-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

0 commit comments

Comments
 (0)