forked from SAP-samples/cloud-cap-samples-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fiori-service.cds
172 lines (165 loc) · 4.41 KB
/
fiori-service.cds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
Annotations for the Manage Orders App
*/
using AdminService from '../../srv/admin-service';
annotate AdminService.Books with {
price @Common.FieldControl: #ReadOnly;
}
////////////////////////////////////////////////////////////////////////////
//
// Common
//
annotate AdminService.OrderItems with {
book @(
Common: {
Text: book.title,
FieldControl: #Mandatory
},
ValueList.entity:'Books',
);
amount @(
Common.FieldControl: #Mandatory
);
}
annotate AdminService.Orders with @(
UI: {
////////////////////////////////////////////////////////////////////////////
//
// Lists of Orders
//
SelectionFields: [ createdAt, createdBy ],
LineItem: [
{Value: createdBy, Label:'{i18n>CreatedBy}'},
{Value: total, Label: '{i18n>Total}' },
{Value: createdAt, Label:'{i18n>CreatedAt}'}
],
////////////////////////////////////////////////////////////////////////////
//
// Order Details
//
HeaderInfo: {
TypeName: '{i18n>Order}', TypeNamePlural: '{i18n>Orders}',
Title: {
Label: '{i18n>OrderNumber}', //A label is possible but it is not considered on the ObjectPage yet
Value: OrderNo
},
Description: {Value: createdBy}
},
Identification: [ //Is the main field group
{Value: createdBy, Label:'{i18n>CreatedBy}'},
{Value: createdAt, Label:'{i18n>CreatedAt}'},
{Value: OrderNo },
],
HeaderFacets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Created}', Target: '@UI.FieldGroup#Created'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Modified}', Target: '@UI.FieldGroup#Modified'},
],
Facets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: 'Items/@UI.LineItem'},
],
FieldGroup#Details: {
Data: [
{Value: total, Label:'{i18n>Total}'},
{Value: currency_code, Label:'{i18n>Currency}'}
]
},
FieldGroup#Created: {
Data: [
{Value: createdBy},
{Value: createdAt},
]
},
FieldGroup#Modified: {
Data: [
{Value: modifiedBy},
{Value: modifiedAt},
]
},
},
Common: {
SideEffects#AmountChanges: {
SourceEntities: [
Items
],
TargetProperties: [
total
]
},
SideEffects#CurrencyChanges: {
SourceProperties: [
currency_code
],
TargetProperties: [
currency.code,
total
]
}
}
) {
createdAt @UI.HiddenFilter:false;
createdBy @UI.HiddenFilter:false;
total
@Common.FieldControl: #ReadOnly
@Measures.ISOCurrency:currency.code; //Bind the currency field to the amount field
//In all services we always find currency as the code and not as an object that contains a property code
//it seems to work but at least to me this is unconventional modeling.
};
//The enity types name is AdminService.my_bookshop_OrderItems
//The annotations below are not generated in edmx WHY?
annotate AdminService.OrderItems with @(
UI: {
HeaderInfo: {
TypeName: '{i18n>OrderItem}', TypeNamePlural: '{i18n>OrderItems}',
Title: {
Value: book.title
},
Description: {Value: book.descr}
},
// There is no filterbar for items so the selctionfileds is not needed
SelectionFields: [ book_ID ],
////////////////////////////////////////////////////////////////////////////
//
// Lists of OrderItems
//
LineItem: [
{Value: book_ID, Label:'{i18n>Books}'},
//The following entry is only used to have the assoication followed in the read event
{Value: book.price, Label:'{i18n>BookPrice}'},
{Value: amount, Label:'{i18n>Amount}'},
{Value: netAmount, Label: '{i18n>NetAmount}'}
],
Identification: [ //Is the main field group
//{Value: ID, Label:'{i18n>ID}'}, //A guid shouldn't be on the UI
{Value: book_ID, Label:'{i18n>Book}'},
{Value: amount, Label:'{i18n>Amount}'},
{Value: netAmount, Label: '{i18n>NetAmount}'}
],
Facets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItem}', Target: '@UI.Identification'},
],
},
Common: {
SideEffects#AmountChanges: {
SourceProperties: [
amount
],
TargetProperties: [
netAmount, parent.total
]
},
SideEffects#BookChanges: {
SourceProperties: [
book_ID
],
TargetProperties: [
netAmount, book.price, parent.total
]
}
}
) {
netAmount
@Common.FieldControl: #ReadOnly;
//ERROR ALERT: The following line refering to the parents currency code will lead to a server error
//@Measures.ISOCurrency:parent.currency.code; //Bind the currency field to the amount field of the parent
};