Skip to content

Commit edcbe96

Browse files
authored
Add change tracking (#327)
Adds change tracking for orders in the admin view. Bumps Fiori version.
1 parent f05bc92 commit edcbe96

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

app/fiori.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
};
1515
</script>
1616

17-
<script id="sap-ushell-bootstrap" src="https://sapui5.hana.ondemand.com/1.112.3/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
18-
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/1.112.3/resources/sap-ui-core.js"
17+
<script id="sap-ushell-bootstrap" src="https://sapui5.hana.ondemand.com/1.123.2/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
18+
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/1.123.2/resources/sap-ui-core.js"
1919
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
2020
data-sap-ui-compatVersion="edge"
2121
data-sap-ui-theme="sap_horizon"

app/orders/fiori-service.cds

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ annotate AdminService.Orders with {
6868
// UI
6969
//
7070
annotate AdminService.Orders with @(
71+
title : '{i18n>Order}',
7172
UI : {
7273
////////////////////////////////////////////////////////////////////////////
7374
//
@@ -147,6 +148,13 @@ annotate AdminService.Orders with @(
147148
Label : '{i18n>OrderItems}',
148149
Target : 'Items/@UI.LineItem'
149150
},
151+
{
152+
$Type : 'UI.ReferenceFacet',
153+
ID : 'ChangeHistoryFacet',
154+
Label : '{i18n>ChangeHistory}',
155+
Target : 'changes/@UI.PresentationVariant',
156+
![@UI.PartOfPreview]: false
157+
}
150158
],
151159
FieldGroup #Details : {Data : [
152160
{
@@ -216,6 +224,7 @@ annotate AdminService.Orders with @(
216224
//The enity types name is AdminService.my_bookshop_OrderItems
217225
//The annotations below are not generated in edmx WHY?
218226
annotate AdminService.OrderItems with @(
227+
title : '{i18n>OrderItem}',
219228
UI : {
220229
HeaderInfo : {
221230
TypeName : '{i18n>OrderItem}',
@@ -236,26 +245,21 @@ annotate AdminService.OrderItems with @(
236245
},
237246
{
238247
Value : quantity,
239-
Label : '{i18n>Quantity}'
240248
},
241249
{
242250
Value : amount,
243-
Label : '{i18n>Amount}'
244251
}
245252
],
246253
Identification : [ //Is the main field group
247254
//{Value: ID, Label:'{i18n>ID}'}, //A guid shouldn't be on the UI
248255
{
249256
Value : book_ID,
250-
Label : '{i18n>Book}'
251257
},
252258
{
253259
Value : quantity,
254-
Label : '{i18n>Quantity}'
255260
},
256261
{
257262
Value : amount,
258-
Label : '{i18n>Amount}'
259263
}
260264
],
261265
Facets : [{
@@ -276,8 +280,14 @@ annotate AdminService.OrderItems with @(
276280
}
277281
}
278282
) {
283+
@title: '{i18n>Amount}'
279284
amount
280285
@Common.FieldControl : #ReadOnly;
286+
287+
@title: '{i18n>Quantity}'
288+
quantity;
289+
@title: '{i18n>Book}'
290+
book;
281291
//ERROR ALERT: The following line refering to the parents currency code will lead to a server error
282292
//@Measures.ISOCurrency:parent.currency.code; //Bind the currency field to the quantity field of the parent
283293
};

mtx/sidecar/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"profile": "mtx-sidecar",
1919
"[development]": {
2020
"requires": { "auth": "dummy" }
21+
},
22+
"cdsc": {
23+
"moduleLookupDirectories": [ "node_modules/", "target/cds/" ]
2124
}
2225
},
2326
"scripts": {

srv/admin-service.cds

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using {sap.common.Languages as CommonLanguages} from '@sap/cds/common';
22
using {my.bookshop as my} from '../db/index';
3+
using {sap.changelog as changelog} from 'com.sap.cds/change-tracking';
4+
5+
extend my.Orders with changelog.changeTracked;
36

47
@path : 'admin'
58
service AdminService @(requires : 'admin') {
@@ -40,3 +43,23 @@ annotate AdminService.Books with @odata.draft.enabled;
4043
extend service AdminService with {
4144
entity Languages as projection on CommonLanguages;
4245
}
46+
47+
// Change-track orders and items
48+
annotate AdminService.Orders {
49+
OrderNo @changelog;
50+
};
51+
52+
annotate AdminService.OrderItems {
53+
quantity @changelog;
54+
book @changelog: [
55+
book.title,
56+
book.isbn
57+
]
58+
};
59+
60+
// Assign identifiers to the tracked entities
61+
annotate AdminService.Orders with @changelog: [OrderNo];
62+
annotate AdminService.OrderItems with @changelog: [
63+
parent.OrderNo,
64+
book.title,
65+
];

srv/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
<scope>runtime</scope>
7373
</dependency>
7474

75+
<dependency>
76+
<groupId>com.sap.cds</groupId>
77+
<artifactId>cds-feature-change-tracking</artifactId>
78+
<scope>runtime</scope>
79+
</dependency>
80+
7581
<!-- CLOUD SDK dependencies -->
7682
<dependency>
7783
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>

0 commit comments

Comments
 (0)