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
The `@cap-js/change-tracking` package is a [CDS plugin](https://cap.cloud.sap/docs/node.js/cds-plugins#cds-plugin-packages) providing out-of-the box support for automatic capturing, storing, and viewing of the change records of modeled entities as simple as that:
6
+
7
+
1.[Install the plugin: `npm add @cap-js/change-tracking`](#setup)
8
+
2.[Add `@changelog` annotations to your CDS models](#annotations)
The `@cap-js/change-tracking` package is a [CDS plugin](https://cap.cloud.sap/docs/node.js/cds-plugins#cds-plugin-packages) providing out-of-the box support for automatic capturing, storing, and viewing of the change records of modeled entities.
-[Human-readable Types and Fields](#human-readable-types-and-fields)
10
-
-[Human-readable IDs](#human-readable-ids)
11
-
-[Human-readable Values](#human-readable-values)
12
-
-[Test-drive locally](#test-drive-locally)
13
-
-[Change History View](#change-history-view)
14
-
-[Customizations](#customizations)
19
+
-[Annotations](#annotations)
20
+
-[Human-readable Types and Fields](#human-readable-types-and-fields)
21
+
-[Human-readable IDs](#human-readable-ids)
22
+
-[Human-readable Values](#human-readable-values)
23
+
-[Test-drive locally](#test-drive-locally)
24
+
-[Change History View](#change-history-view)
15
25
-[Contributing](#contributing)
16
-
-[Code of Conduct](#code-of-conduct)
26
+
-[Code of Conduct](#code-of-conduct)
17
27
-[Licensing](#licensing)
18
28
19
29
20
30
31
+
## Preliminaries
32
+
33
+
In this guide, we use the [Incidents Management reference sample app](https://github.com/cap-js/incidents-app) as the base to add change tracking to. Clone the repository and apply the step-by-step instructions:
34
+
35
+
```sh
36
+
git clone https://github.com/cap-js/incidents-app
37
+
cd incidents-app
38
+
npm i
39
+
```
40
+
41
+
**Alternatively**, you can clone the incidents app including the prepared enhancements for change-tracking:
In this guide, we use the [Incidents Management reference sample app](https://github.com/cap-js/incidents-app) as the base to add change tracking to.
34
-
35
-
### Add `@changelog` Annotations
65
+
## Annotations
36
66
37
67
All we need to do is to identify what should be change-tracked by annotating respective entities and elements in our model with the `@changelog` annotation. Following the [best practice of separation of concerns](https://cap.cloud.sap/docs/guides/domain-modeling#separation-of-concerns), we do so in a separate file _srv/change-tracking.cds_:
38
68
@@ -55,9 +85,9 @@ The minimal annotation we require for change tracking is `@changelog` on element
55
85
Additional identifiers or labels can be added to obtain more *human-readable* change records as described below.
56
86
57
87
58
-
####Human-readable Types and Fields
88
+
### Human-readable Types and Fields
59
89
60
-
By default the implementation looks up *Object Type* names or *Field* namesfrom respective `@title` or `@Common.Label` annotations, and applies i18n lookups. If no such annotations are given, the technical names of the respective CDS definitions are displayed.
90
+
By default the implementation looks up *Object Type* names or *Field* namesfrom respective `@title` or `@Common.Label` annotations, and applies i18n lookups. If no such annotations are given, the technical names of the respective CDS definitions are displayed.
61
91
62
92
For example, without the `@title` annotation, changes to conversation entries would show up with the technical entity name:
63
93
@@ -74,7 +104,7 @@ We get a human-readable display for *Object Type*:
Expanding the changelog annotation by additional identifiers `[author, timestamp]`, we can now better identify the `message` change events by their respective author and timestamp.
98
128
99
129
100
-
####Human-readable Values
130
+
### Human-readable Values
101
131
102
132
The changelog annotations for *New Value* and *Old Value* are defined at element level.
103
133
@@ -120,7 +150,7 @@ Hence, here it is essential to add a unique identifier to obtain human-readable
With the steps above, we have successfully set up change tracking for our reference application. Let's see that in action.
126
156
@@ -130,7 +160,7 @@ With the steps above, we have successfully set up change tracking for our refere
130
160
```
131
161
2.**Make a change** on your change-tracked elements. This change will automatically be persisted in the database table (`sap.changelog.ChangeLog`) and made available in a pre-defined view, namely the [Change History view](#change-history-view) for your convenience.
@@ -166,7 +196,7 @@ For more information and examples on adding Fiori Annotations, see [Adding SAP F
166
196
This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/change-tracking/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
167
197
168
198
169
-
###Code of Conduct
199
+
## Code of Conduct
170
200
171
201
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.
0 commit comments