Skip to content

Commit 1ce8ee1

Browse files
committed
add content entity
1 parent 1605d14 commit 1ce8ee1

File tree

5 files changed

+136
-22
lines changed

5 files changed

+136
-22
lines changed

app/admin/fiori-service.cds

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ annotate AdminService.Books with @(UI : {
3535
$Type : 'UI.ReferenceFacet',
3636
Label : '{i18n>Admin}',
3737
Target : '@UI.FieldGroup#Admin'
38+
},
39+
{
40+
$Type : 'UI.ReferenceFacet',
41+
Label : '{i18n>Contents}',
42+
Target : 'contents/@UI.PresentationVariant'
3843
}
3944
],
4045
FieldGroup #General : {Data : [
@@ -59,7 +64,11 @@ annotate AdminService.Books with @(UI : {
5964
]}
6065
});
6166

62-
// Add Value Help for Tree Table
67+
68+
////////////////////////////////////////////////////////////////////////////
69+
//
70+
// Value Help for Tree Table
71+
//
6372
annotate AdminService.Books with {
6473
genre @(Common: {
6574
Label : 'Genre',
@@ -98,6 +107,44 @@ annotate AdminService.GenreHierarchy with @UI: {
98107
}]
99108
};
100109

110+
annotate AdminService.ContentsHierarchy with @UI: {
111+
PresentationVariant : {
112+
$Type : 'UI.PresentationVariantType',
113+
RequestAtLeast: [name],
114+
Visualizations: ['@UI.LineItem', ],
115+
},
116+
LineItem : [{
117+
$Type: 'UI.DataField',
118+
Value: name,
119+
},
120+
{
121+
$Type: 'UI.DataField',
122+
Value: page,
123+
}],
124+
HeaderInfo : {
125+
$Type : 'UI.HeaderInfoType',
126+
TypeName : 'Organization Level',
127+
TypeNamePlural: 'Organization Levels',
128+
Title : {
129+
$Type: 'UI.DataField',
130+
Value: name,
131+
}
132+
},
133+
FieldGroup : {
134+
$Type: 'UI.FieldGroupType',
135+
Data : [{
136+
$Type: 'UI.DataField',
137+
Value: page,
138+
Label : 'Page Number'
139+
}],
140+
},
141+
Facets : [{
142+
$Type : 'UI.ReferenceFacet',
143+
Target: '@UI.FieldGroup',
144+
Label : 'Informations',
145+
}],
146+
};
147+
101148
////////////////////////////////////////////////////////////
102149
//
103150
// Draft for Localized Data
@@ -137,6 +184,26 @@ annotate AdminService.Books.texts {
137184
}
138185
}
139186

187+
////////////////////////////////////////////////////////////
188+
//
189+
// Annotations for hierarchy ContentsHierarchy
190+
//
191+
annotate AdminService.ContentsHierarchy with @Aggregation.RecursiveHierarchy#ContentsHierarchy: {
192+
$Type: 'Aggregation.RecursiveHierarchyType',
193+
NodeProperty: ID, // identifies a node
194+
ParentNavigationProperty: parent // navigates to a node's parent
195+
};
196+
197+
annotate AdminService.ContentsHierarchy with @Hierarchy.RecursiveHierarchy#ContentsHierarchy: {
198+
$Type: 'Hierarchy.RecursiveHierarchyType',
199+
LimitedDescendantCount: LimitedDescendantCount,
200+
DistanceFromRoot: DistanceFromRoot,
201+
DrillState: DrillState,
202+
Matched: Matched,
203+
MatchedDescendantCount: MatchedDescendantCount,
204+
LimitedRank: LimitedRank
205+
};
206+
140207
annotate AdminService.Books actions {
141208
@(
142209
Common.SideEffects : {

app/admin/webapp/manifest.json

Lines changed: 28 additions & 20 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": {
@@ -85,12 +85,12 @@
8585
"id": "BooksList",
8686
"name": "sap.fe.templates.ListReport",
8787
"options": {
88-
"settings" : {
89-
"entitySet" : "Books",
90-
"navigation" : {
91-
"Books" : {
92-
"detail" : {
93-
"route" : "BooksDetails"
88+
"settings": {
89+
"entitySet": "Books",
90+
"navigation": {
91+
"Books": {
92+
"detail": {
93+
"route": "BooksDetails"
9494
}
9595
}
9696
},
@@ -112,25 +112,33 @@
112112
"id": "BooksDetailsList",
113113
"name": "sap.fe.templates.ObjectPage",
114114
"options": {
115-
"settings" : {
116-
"entitySet" : "Books",
117-
"navigation" : {
118-
"Authors" : {
119-
"detail" : {
120-
"route" : "AuthorsDetails"
115+
"settings": {
116+
"entitySet": "Books",
117+
"navigation": {
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-
"entitySet" : "Authors"
140+
"settings": {
141+
"entitySet": "ContentsHierarchy"
134142
}
135143
}
136144
}

db/books.cds

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ entity Books : cuid, managed {
2222
reviews : Association to many Reviews
2323
on reviews.book = $self;
2424
isReviewable : TechnicalBooleanFlag not null default true;
25+
contents : Composition of many Contents on contents.book = $self;
2526
}
2627

2728
entity Authors : cuid, managed {
@@ -51,4 +52,17 @@ annotate Authors with
5152
entity Genres : sap.common.CodeList {
5253
key ID : UUID;
5354
parent : Association to Genres;
55+
children : Composition of many Genres on children.parent = $self;
5456
}
57+
58+
/**
59+
* Hierarchically organized entity for Contents
60+
*/
61+
entity Contents {
62+
key ID : UUID;
63+
name : String;
64+
page : Integer;
65+
parent : Association to Contents @odata.draft.enclosed;
66+
book : Association to Books @odata.draft.enclosed;
67+
}
68+

db/data/my.bookshop-Contents.csv

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ID;parent_ID;name;page;book_ID
2+
f846b0b9-01d4-4f6d-82a4-d79204f62514;;Foreword;3;9b084139-0b1e-43b6-b12a-7b3669d75f02
3+
f846b0b9-01d4-4f6d-82a4-d79204f62515;;Chapter 1;4;9b084139-0b1e-43b6-b12a-7b3669d75f02
4+
f846b0b9-01d4-4f6d-82a4-d79204f62516;f846b0b9-01d4-4f6d-82a4-d79204f62515;Section 1.1;5;9b084139-0b1e-43b6-b12a-7b3669d75f02
5+
f846b0b9-01d4-4f6d-82a4-d79204f62517;f846b0b9-01d4-4f6d-82a4-d79204f62515;Section 1.2;28;9b084139-0b1e-43b6-b12a-7b3669d75f02
6+
f846b0b9-01d4-4f6d-82a4-d79204f62518;f846b0b9-01d4-4f6d-82a4-d79204f62517;Subsection 1.2.1;30;9b084139-0b1e-43b6-b12a-7b3669d75f02
7+
f846b0b9-01d4-4f6d-82a4-d79204f62519;f846b0b9-01d4-4f6d-82a4-d79204f62517;Subsection 1.2.2;33;9b084139-0b1e-43b6-b12a-7b3669d75f02
8+
f846b0b9-01d4-4f6d-82a4-d79204f62520;f846b0b9-01d4-4f6d-82a4-d79204f62515;Section 1.3;36;9b084139-0b1e-43b6-b12a-7b3669d75f02
9+
f846b0b9-01d4-4f6d-82a4-d79204f62521;;Chapter 2;54;9b084139-0b1e-43b6-b12a-7b3669d75f02
10+
f846b0b9-01d4-4f6d-82a4-d79204f62522;f846b0b9-01d4-4f6d-82a4-d79204f62521;Section 2.1;56;9b084139-0b1e-43b6-b12a-7b3669d75f02
11+
f846b0b9-01d4-4f6d-82a4-d79204f62523;f846b0b9-01d4-4f6d-82a4-d79204f62521;Section 2.2;58;9b084139-0b1e-43b6-b12a-7b3669d75f02
12+
f846b0b9-01d4-4f6d-82a4-d79204f62524;;Conclusion;63;9b084139-0b1e-43b6-b12a-7b3669d75f02
13+
f846b0b9-01d4-4f6d-82a4-d79204f62525;;Endnotes;65;9b084139-0b1e-43b6-b12a-7b3669d75f02
14+
f846b0b9-01d4-4f6d-82a4-d79204f62526;;Copyright notice;2;51061ce3-ddde-4d70-a2dc-6314afbcc73e
15+
f846b0b9-01d4-4f6d-82a4-d79204f62527;;Chapter 1;3;51061ce3-ddde-4d70-a2dc-6314afbcc73e
16+
f846b0b9-01d4-4f6d-82a4-d79204f62528;f846b0b9-01d4-4f6d-82a4-d79204f62527;Section 1.1;5;51061ce3-ddde-4d70-a2dc-6314afbcc73e
17+
f846b0b9-01d4-4f6d-82a4-d79204f62529;f846b0b9-01d4-4f6d-82a4-d79204f62527;Section 1.2;13;51061ce3-ddde-4d70-a2dc-6314afbcc73e
18+
f846b0b9-01d4-4f6d-82a4-d79204f62530;;Chapter 2;20;51061ce3-ddde-4d70-a2dc-6314afbcc73e
19+
f846b0b9-01d4-4f6d-82a4-d79204f62531;f846b0b9-01d4-4f6d-82a4-d79204f62530;Section 2.1;21;51061ce3-ddde-4d70-a2dc-6314afbcc73e
20+
f846b0b9-01d4-4f6d-82a4-d79204f62532;f846b0b9-01d4-4f6d-82a4-d79204f62530;Section 2.2;25;51061ce3-ddde-4d70-a2dc-6314afbcc73e
21+
f846b0b9-01d4-4f6d-82a4-d79204f62533;f846b0b9-01d4-4f6d-82a4-d79204f62530;Section 2.3;27;51061ce3-ddde-4d70-a2dc-6314afbcc73e
22+
f846b0b9-01d4-4f6d-82a4-d79204f62534;;Chapter 3;30;51061ce3-ddde-4d70-a2dc-6314afbcc73e
23+
f846b0b9-01d4-4f6d-82a4-d79204f62535;;Endnotes;41;51061ce3-ddde-4d70-a2dc-6314afbcc73e

srv/admin-service.cds

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ service AdminService @(requires: 'admin') {
2121
entity Authors as projection on my.Authors;
2222
entity Orders as select from my.Orders;
2323
extend my.Genres with Hierarchy;
24-
entity GenreHierarchy as projection on my.Genres;
24+
entity GenreHierarchy as projection on my.Genres excluding {children};
25+
extend my.Contents with Hierarchy;
26+
entity ContentsHierarchy as projection on my.Contents;
2527

2628
@cds.persistence.skip
2729
entity Upload @odata.singleton {

0 commit comments

Comments
 (0)