You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: advanced/fiori.md
+33-57Lines changed: 33 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,63 +25,35 @@ This guide explains how to add one or more SAP Fiori elements apps to a CAP proj
25
25
26
26
For entities exposed via OData V4 there is a _Fiori preview_ link on the index page. It dynamically serves an SAP Fiori Elements list page that allows you to quickly see the effect of annotation changes without having to create a UI application first.
27
27
28
-
<divclass="impl node">
29
-
30
28
::: details Be aware that this is **not meant for production**.
31
29
30
+
<divclass="impl node">
31
+
32
32
The preview not meant as a replacement for a proper SAP Fiori Elements (UI5) application.
33
33
It is only active locally where the [development profile](../node.js/cds-env#profiles) is enabled.
34
34
35
-
To also enable it in cloud deployments, for test or demo purposes maybe, add the following configuration:
36
-
37
-
::: code-group
38
-
39
-
```json [package.json]
40
-
{
41
-
"cds": {
42
-
"features": {
43
-
"fiori_preview": true
44
-
}
45
-
}
46
-
}
47
-
```
48
-
```json [.cdsrc.json]
49
-
{
50
-
"features": {
51
-
"fiori_preview": true
52
-
}
53
-
}
54
-
```
55
-
56
-
:::
35
+
To also enable it in cloud deployments, for test or demo purposes maybe, set <Config>cds.fiori.preview:true</Config>.
57
36
58
37
</div>
59
38
60
39
<divclass="impl java">
61
40
62
-
::: details Be aware that this is **not meant for production**.
63
-
64
41
The preview not meant as a replacement for a proper SAP Fiori Elements (UI5) application.
65
42
It is active by default, but disabled automatically in case the [production profile](../java/developing-applications/configuring#production-profile) is enabled.
66
43
67
-
To also enable it in cloud deployments, for test or demo purposes maybe, add the following configuration:
44
+
To also enable it in cloud deployments, for test or demo purposes maybe, set <Configjava>cds.index-page.enabled:true</Config>.
45
+
46
+
</div>
68
47
69
-
::: code-group
70
-
```yaml [srv/src/main/resources/application.yaml]
71
-
cds:
72
-
index-page:
73
-
enabled: true
74
-
```
75
48
:::
76
49
77
-
</div>
78
50
79
51
## Adding Fiori Apps
80
52
81
53
As showcased in [cap/samples](https://github.com/sap-samples/cloud-cap-samples/tree/main/fiori/app), SAP Fiori apps should be added as sub folders to the `app/` of a CAP project. Each sub folder constitutes an individual SAP Fiori application, with [local annotations](#fiori-annotations), _manifest.json_, etc. So, a typical folder layout would look like this:
| `browse/`| SAP Fiori app for end users |
@@ -97,9 +69,12 @@ Links to Fiori applications created in the `app/` folder are automatically added
97
69
98
70
### Using SAP Fiori Tools
99
71
100
-
The SAP Fiori tools provide advanced support for adding SAP Fiori apps to existing CAP projects as well as a wealth of productivity tools, for example for adding SAP Fiori annotations, or graphical modeling and editing. They can be used locally in [Visual Studio Code (VS Code)](https://marketplace.visualstudio.com/items?itemName=SAPSE.sap-ux-fiori-tools-extension-pack) or in [SAP Business Application Studio](https://help.sap.com/docs/SAP_FIORI_tools/17d50220bcd848aa854c9c182d65b699/b0110400b44748d7b844bb5977a657fa.html).
72
+
The SAP Fiori tools provide advanced support for [adding SAP Fiori apps](https://help.sap.com/docs/SAP_FIORI_tools/17d50220bcd848aa854c9c182d65b699/db44d45051794d778f1dd50def0fa267.html) to existing CAP projects as well as a wealth of productivity tools, for example for adding SAP Fiori annotations, or graphical modeling and editing. They can be used locally in [Visual Studio Code (VS Code)](https://marketplace.visualstudio.com/items?itemName=SAPSE.sap-ux-fiori-tools-extension-pack) or in [SAP Business Application Studio](https://help.sap.com/docs/SAP_FIORI_tools/17d50220bcd848aa854c9c182d65b699/b0110400b44748d7b844bb5977a657fa.html).
73
+
101
74
102
-
[Learn more about **how to install SAP Fiori tools**.](https://help.sap.com/docs/SAP_FIORI_tools/17d50220bcd848aa854c9c182d65b699/2d8b1cb11f6541e5ab16f05461c64201.html){.learn-more}
75
+
### Using [`cds add`](../tools/cds-cli#sample)
76
+
77
+
Use `cds add sample` to add Fiori sample code to an existing project, or create a new one with `cds init <project> --add sample`.
103
78
104
79
105
80
### From [cap/samples](https://github.com/sap-samples/cloud-cap-samples)
@@ -152,14 +127,14 @@ While CDS in principle allows you to add such annotations everywhere in your mod
services.cds#> imports ./admin/fiori-service and ./browse/fiori-service
156
131
./srv #> all service definitions should stay clean in here:
157
132
admin-service.cds
158
133
cat-service.cds
159
134
...
160
135
```
161
136
162
-
[See this also in **cap/samples/fiori**.](https://github.com/sap-samples/cloud-cap-samples/tree/main/fiori/app){.learn-more}
137
+
[See this also in **cap/samples/fiori**.](https://github.com/SAP-samples/cloud-cap-samples/blob/6fa2aaee34e862337c5bc5a413817355ab283437/fiori/app/services.cds){.learn-more}
163
138
164
139
**Reasoning:** This recommendation essentially follows the best practices and guiding principles of [Conceptual Modeling](../guides/domain-modeling#domain-driven-design) and [Separation of Concerns](../guides/domain-modeling#separation-of-concerns).
165
140
@@ -187,7 +162,7 @@ The CDS OData Language Server provides a list of context-sensitive suggestions b
187
162
188
163
#### Using Code Completion
189
164
190
-
To trigger code completion, choose <kbd>⌘</kbd> + <kbd class="space">⎵</kbd> (macOS) or <kbd>Ctrl</kbd> + <kbd class="space">⎵</kbd> (other platforms). The list of suggested values is displayed.
165
+
To trigger code completion, choose <kbd>Ctrl</kbd><kbd>Space</kbd>. The list of suggested values is displayed.
191
166
192
167
> Note: You can filter the list of suggested values by typing more characters.
193
168
@@ -322,7 +297,7 @@ You can navigate to the referenced annotation using the [Peek Definition](#peek-
322
297
#### Peek Definition { #peek-definition}
323
298
324
299
Peek Definition lets you preview and update the referenced annotation without switching away from the code that you're writing. It's triggered when your cursor is inside the referenced annotation value.
325
-
- Using a keyboard: choose <kbd class="space">⌥</kbd> + <kbd>F12</kbd> (macOS) or <kbd>Alt</kbd> + <kbd>F12</kbd> (other platforms)
300
+
- Using a keyboard: choose <kbdclass="space">⌥</kbd><kbd>F12</kbd> (macOS) or <kbd>Alt</kbd><kbd>F12</kbd> (other platforms)
326
301
- Using a mouse: right-click and select **Peek Definition**
327
302
If an annotation is defined in multiple sources, all these sources are listed. You can select which one you want to view or update. Annotation layering isn't considered.
328
303
@@ -333,7 +308,7 @@ Go To Definition lets you navigate to the source of the referenced annotation an
333
308
334
309
Place your cursor inside the path referencing the annotation term segment or translatable string value, and trigger Go to Definition:
335
310
336
-
- Using a keyboard: choose <kbd>F12</kbd> in VS Code, or <kbd>Ctrl</kbd> + <kbd>F12</kbd> in SAP Business Application Studio
311
+
- Using a keyboard: choose <kbd>F12</kbd> in VS Code, or <kbd>Ctrl</kbd><kbd>F12</kbd> in SAP Business Application Studio
337
312
- Using a mouse: right-click and select **Go To Definition**
338
313
- Using a keyboard and mouse: <kbd>⌘</kbd> + mouse click (macOS) or <kbd>Ctrl</kbd> + mouse click (other platforms)
339
314
@@ -353,7 +328,7 @@ The annotation language server provides quick information for annotation terms,
353
328
354
329
To view the quick info for an annotation term, record type, or property used in the annotation file, hover your mouse over it. The accompanying documentation is displayed in a hover window, if provided in the respective OData vocabularies.
355
330
356
-
To view the quick info for each suggestion in the code completion list, either pressing <kbd>⌘</kbd> + <kbd class="space">⎵</kbd> (macOS) or <kbd>Ctrl</kbd> + <kbd class="space">⎵</kbd> (other platforms), or click the *info* icon. The accompanying documentation for the suggestion expands to the side. The expanded documentation stays open and updates as you navigate the list. You can close this by pressing <kbd>⌘</kbd> + <kbd class="space">⎵</kbd> / <kbd>Ctrl</kbd> + <kbd class="space">⎵</kbd> again or by clicking on the close icon.
331
+
To view the quick info for each suggestion in the code completion list, either pressing <kbd>Ctrl</kbd><kbd>Space</kbd>, or click the *info* icon. The accompanying documentation for the suggestion expands to the side. The expanded documentation stays open and updates as you navigate the list.
357
332
358
333
359
334
#### Internationalization Support
@@ -426,14 +401,15 @@ To enable draft for an entity exposed by a service, simply annotate it with `@od
426
401
annotate AdminService.Books with @odata.draft.enabled;
427
402
```
428
403
429
-
[See it live in **cap/samples**.](https://github.com/sap-samples/cloud-cap-samples/tree/main/fiori/app/admin-books/fiori-service.cds#L51){.learn-more}
404
+
[See it live in **cap/samples**.](https://github.com/SAP-samples/cloud-cap-samples/blob/6fa2aaee34e862337c5bc5a413817355ab283437/fiori/app/admin-books/fiori-service.cds#L94){.learn-more}
430
405
431
406
::: warning
432
407
You can't project from draft-enabled entities, as annotations are propagated. Either _enable_ the draft for the projection and not the original entity or _disable_ the draft on the projection using `@odata.draft.enabled: null`.
433
408
:::
434
409
435
410
### Difference between Compositions and Associations
436
-
Be aware that you must not modify associated entities through drafts. Only compositions will get a "Create" button in SAP Fiori elements UIs because they are stored as part of the same draft entity.
411
+
412
+
Be aware that you cannot modify _associated_ entities through drafts. Only _compositions_ will get a "Create" button in SAP Fiori elements UIs because they are stored as part of the same draft entity.
437
413
438
414
### Enabling Draft for [Localized Data](../guides/localized-data) {#draft-for-localized-data}
439
415
@@ -452,13 +428,14 @@ Adding the annotation `@fiori.draft.enabled` won't work if the corresponding `_t
452
428
:::
453
429
454
430
{style="margin:0"}
455
-
[See it live in **cap/samples**.](https://github.com/sap-samples/cloud-cap-samples/tree/main/fiori/app/admin-books/fiori-service.cds#L50){.learn-more}
456
431
457
-
If you're editing data in multiple languages, the _General_ tab in the example above is reserved for the default language (often "en"). Any change to other languages has to be done in the _Translations_ tab, where a corresponding language can be chosen [from a drop-down menu](https://github.com/SAP-samples/cloud-cap-samples/blob/14ac3efaa13fc025f621b4eed369d03f1ca48341/fiori/app/admin-books/fiori-service.cds#L70) as illustrated above. This also applies if you use the URL parameter `sap-language` on the draft page.
432
+
[See it live in **cap/samples**.](https://github.com/SAP-samples/cloud-cap-samples/blob/6fa2aaee34e862337c5bc5a413817355ab283437/fiori/app/admin-books/fiori-service.cds#L93){.learn-more}
433
+
434
+
If you're editing data in multiple languages, the _General_ tab in the example above is reserved for the default language (often "en"). Any change to other languages has to be done in the _Translations_ tab, where a corresponding language can be chosen [from a drop-down menu](https://github.com/SAP-samples/cloud-cap-samples/blob/6fa2aaee34e862337c5bc5a413817355ab283437/fiori/app/admin-books/fiori-service.cds#L116) as illustrated above. This also applies if you use the URL parameter `sap-language` on the draft page.
458
435
459
436
### Validating Drafts
460
437
461
-
You can add [custom handlers](../guides/providing-services#custom-logic) to add specific validations, as usual. In addition, for a draft, you can register handlers to the `PATCH` events to validate input per field, during the edit session, as follows.
438
+
You can add [custom handlers](../guides/providing-services#custom-logic) to add specific validations, as usual. In addition, for a draft, you can register handlers to the respective `UPDATE` events to validate input per field, during the edit session, as follows.
462
439
463
440
464
441
##### ... in Java
@@ -626,7 +603,7 @@ We're going to look at three things.
626
603
1. Dynamically define the buttons status on the UI
627
604
628
605
629
-
First you need to define an action, like in the [_travel-service.cds_ file](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/srv/travel-service.cds#L11).
606
+
First you need to define an action, like in the [_travel-service.cds_ file](https://github.com/SAP-samples/cap-sflight/blob/42ee666e40f9dba1176f8263b512c10d23f07907/srv/travel-service.cds#L11).
630
607
631
608
```cds
632
609
entity Travel as projection on my.Travel actions {
@@ -637,16 +614,15 @@ entity Travel as projection on my.Travel actions {
637
614
};
638
615
```
639
616
640
-
To define what the action actually is doing, you need to write some custom code. See the [_travel-service.js_](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/srv/travel-service.js#L126) file for example:
617
+
To define what the action actually is doing, you need to write some custom code. See the [_travel-service.ts_](https://github.com/SAP-samples/cap-sflight/blob/42ee666e40f9dba1176f8263b512c10d23f07907/srv/travel-service.ts#L86) file for example:
> Note: `req._target` is a workaround that has been [introduced in SFlight](https://github.com/SAP-samples/cap-sflight/blob/685867de9e6a91d61276671e4af7354029c70ac8/srv/workarounds.js#L52). In the future, there might be an official API for it.
646
622
647
-
Create the buttons, to bring this action onto the UI and make it actionable for the user. There are two buttons: On the overview and in the detail screen. Both are defined in the [_layouts.cds_](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/app/travel_processor/layouts.cds) file.
623
+
Create the buttons, to bring this action onto the UI and make it actionable for the user. There are two buttons: On the overview and in the detail screen. Both are defined in the [_layouts.cds_](https://github.com/SAP-samples/cap-sflight/blob/42ee666e40f9dba1176f8263b512c10d23f07907/app/travel_processor/layouts.cds) file.
648
624
649
-
For the overview of all travels, use the [`@UI.LineItem` annotation](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/app/travel_processor/layouts.cds#L40-L41).
625
+
For the overview of all travels, use the [`@UI.LineItem` annotation](https://github.com/SAP-samples/cap-sflight/blob/42ee666e40f9dba1176f8263b512c10d23f07907/app/travel_processor/layouts.cds#L40-L41).
650
626
651
627
```cds
652
628
annotate TravelService.Travel with @UI : {
@@ -658,7 +634,7 @@ LineItem : [
658
634
};
659
635
```
660
636
661
-
For the detail screen of a travel, use the [`@UI.Identification` annotation](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/app/travel_processor/layouts.cds#L9-L10).
637
+
For the detail screen of a travel, use the [`@UI.Identification` annotation](https://github.com/SAP-samples/cap-sflight/blob/42ee666e40f9dba1176f8263b512c10d23f07907/app/travel_processor/layouts.cds#L9-L10).
662
638
663
639
```cds
664
640
annotate TravelService.Travel with @UI : {
@@ -670,7 +646,7 @@ annotate TravelService.Travel with @UI : {
670
646
};
671
647
```
672
648
673
-
Now, the buttons are there and connected to the action. The missing piece is to define the availability of the buttons dynamically. Annotate the `Travel` entity in the `TravelService` service accordingly in the [_field-control.cds_](https://github.com/SAP-samples/cap-sflight/blob/8f65dc8b7985bc22584d2a9f94335f110c0450ea/app/travel_processor/field-control.cds#L20-L32) file.
649
+
Now, the buttons are there and connected to the action. The missing piece is to define the availability of the buttons dynamically. Annotate the `Travel` entity in the `TravelService` service accordingly in the [_field-control.cds_](https://github.com/SAP-samples/cap-sflight/blob/42ee666e40f9dba1176f8263b512c10d23f07907/app/travel_processor/field-control.cds#L23-L36) file.
674
650
675
651
```cds
676
652
annotate TravelService.Travel with actions {
@@ -683,7 +659,7 @@ annotate TravelService.Travel with actions {
683
659
This annotation uses [dynamic expressions](../advanced/odata#dynamic-expressions) to control the buttons for each action. And the status of a travel on the UI is updated, triggered by the `@Common.SideEffects.TargetProperties` annotation.
684
660
685
661
:::info More complex calculation
686
-
If you have the need for a more complex calculation, then the interesting parts in SFLIGHT are [virtual fields in _field-control.cds_](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/app/travel_processor/field-control.cds#L10-L16) (also lines 37-44) and [custom code in _travel-service.js_](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/srv/travel-service.js#L13-L22).
662
+
If you have the need for a more complex calculation, then the interesting parts in (an older version of) SFLIGHT are [virtual fields in _field-control.cds_](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/app/travel_processor/field-control.cds#L10-L16) (also lines 37-44) and [custom code in _travel-service.js_](https://github.com/SAP-samples/cap-sflight/blob/dfc7827da843ace0ea126f76fc78a6591b325c67/srv/travel-service.js#L13-L22).
0 commit comments