@cap-js/change-tracking 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +46 -14
- package/index.cds +1 -2
- package/lib/entity-helper.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,30 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
6
6
|
|
|
7
|
+
## Version 1.0.3 - 10.11.23
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Added note about using `SAPUI5 v1.120.0` or later for proper lazy loading of the *Change History* table.
|
|
12
|
+
- In README, add warning about tracking personal data.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Support cases where parent/child entries are created simultaneously.
|
|
17
|
+
- Allow for lazy loading of change history table (with SAP UI5 release 1.120.0).
|
|
18
|
+
|
|
19
|
+
## Version 1.0.2 - 31.10.23
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- In README, use view of the full change-tracking table instead of the customized one for the main image.
|
|
24
|
+
|
|
7
25
|
## Version 1.0.1 - 26.10.23
|
|
8
26
|
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Flattened README structure.
|
|
30
|
+
|
|
9
31
|
### Fixed
|
|
10
32
|
|
|
11
33
|
- Labels are looked up from the service entity (not the db entity only).
|
package/README.md
CHANGED
|
@@ -8,23 +8,28 @@ The `@cap-js/change-tracking` package is a [CDS plugin](https://cap.cloud.sap/do
|
|
|
8
8
|
2. [Add `@changelog` annotations to your CDS models](#annotations)
|
|
9
9
|
3. [Et voilà:](#change-history-view)
|
|
10
10
|
|
|
11
|
-
<img width="1300" alt="change-history-
|
|
11
|
+
<img width="1300" alt="change-history-loading" src="_assets/change-history.gif">
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
### Table of Contents
|
|
16
16
|
|
|
17
|
-
- [
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
17
|
+
- [Change Tracking Plugin for SAP Cloud Application Programming Model (CAP)](#change-tracking-plugin-for-sap-cloud-application-programming-model-cap)
|
|
18
|
+
- [Table of Contents](#table-of-contents)
|
|
19
|
+
- [Preliminaries](#preliminaries)
|
|
20
|
+
- [Setup](#setup)
|
|
21
|
+
- [Annotations](#annotations)
|
|
22
|
+
- [Human-readable Types and Fields](#human-readable-types-and-fields)
|
|
23
|
+
- [Human-readable IDs](#human-readable-ids)
|
|
24
|
+
- [Human-readable Values](#human-readable-values)
|
|
25
|
+
- [Test-drive locally](#test-drive-locally)
|
|
26
|
+
- [Change History View](#change-history-view)
|
|
27
|
+
- [Customizations](#customizations)
|
|
28
|
+
- [Altered table view](#altered-table-view)
|
|
29
|
+
- [Disable lazy loading](#disable-lazy-loading)
|
|
30
|
+
- [Contributing](#contributing)
|
|
31
|
+
- [Code of Conduct](#code-of-conduct)
|
|
32
|
+
- [Licensing](#licensing)
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
|
|
@@ -64,6 +69,9 @@ npm add @cap-js/change-tracking
|
|
|
64
69
|
|
|
65
70
|
## Annotations
|
|
66
71
|
|
|
72
|
+
> [!WARNING]
|
|
73
|
+
> Please be aware that [**sensitive** or **personal** data](https://cap.cloud.sap/docs/guides/data-privacy/annotations#annotating-personal-data) should not be change tracked, since viewing the log allows users to circumvent [audit-logging](https://cap.cloud.sap/docs/guides/data-privacy/audit-logging#setup).
|
|
74
|
+
|
|
67
75
|
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_:
|
|
68
76
|
|
|
69
77
|
```cds
|
|
@@ -162,13 +170,19 @@ With the steps above, we have successfully set up change tracking for our refere
|
|
|
162
170
|
|
|
163
171
|
## Change History View
|
|
164
172
|
|
|
173
|
+
> [!IMPORTANT]
|
|
174
|
+
> To ensure proper lazy loading of the Change History table, please use **SAPUI5 version 1.120.0** or higher.<br>
|
|
175
|
+
> If you wish to *disable* this feature, please see the customization section on how to [disable lazy loading](#disable-lazy-loading).
|
|
176
|
+
|
|
165
177
|
<img width="1300" alt="change-history" src="_assets/changes.png">
|
|
166
178
|
|
|
167
179
|
If you have a Fiori Element application, the CDS plugin automatically provides and generates a view `sap.changelog.ChangeView`, the facet of which is automatically added to the Fiori Object Page of your change-tracked entities/elements. In the UI, this corresponds to the *Change History* table which serves to help you to view and search the stored change records of your modeled entities.
|
|
168
180
|
|
|
169
|
-
|
|
181
|
+
## Customizations
|
|
170
182
|
|
|
171
|
-
|
|
183
|
+
### Altered table view
|
|
184
|
+
|
|
185
|
+
The *Change History* view can be easily adapted and configured to your own needs by simply changing or extending it. For example, let's assume we only want to show the first 5 columns in equal spacing, we would extend `srv/change-tracking.cds` as follows:
|
|
172
186
|
|
|
173
187
|
```cds
|
|
174
188
|
using from '@cap-js/change-tracking';
|
|
@@ -190,6 +204,24 @@ In the UI, the *Change History* table now contains 5 equally-spaced columns with
|
|
|
190
204
|
|
|
191
205
|
For more information and examples on adding Fiori Annotations, see [Adding SAP Fiori Annotations](https://cap.cloud.sap/docs/advanced/fiori#fiori-annotations).
|
|
192
206
|
|
|
207
|
+
### Disable lazy loading
|
|
208
|
+
|
|
209
|
+
To disable the lazy loading feature of the *Change History* table, you can add the following annotation to your `srv/change-tracking.cds`:
|
|
210
|
+
|
|
211
|
+
```cds
|
|
212
|
+
using from '@cap-js/change-tracking';
|
|
213
|
+
|
|
214
|
+
annotate sap.changelog.aspect @(UI.Facets: [{
|
|
215
|
+
$Type : 'UI.ReferenceFacet',
|
|
216
|
+
ID : 'ChangeHistoryFacet',
|
|
217
|
+
Label : '{i18n>ChangeHistory}',
|
|
218
|
+
Target: 'changes/@UI.PresentationVariant',
|
|
219
|
+
![@UI.PartOfPreview]
|
|
220
|
+
}]);
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
The system now uses the SAPUI5 default setting `![@UI.PartOfPreview]: true`, such that the table will always shown when navigating to that respective Object page.
|
|
193
225
|
|
|
194
226
|
## Contributing
|
|
195
227
|
|
package/index.cds
CHANGED
|
@@ -9,8 +9,7 @@ aspect aspect @(UI.Facets: [{
|
|
|
9
9
|
ID : 'ChangeHistoryFacet',
|
|
10
10
|
Label : '{i18n>ChangeHistory}',
|
|
11
11
|
Target: 'changes/@UI.PresentationVariant',
|
|
12
|
-
|
|
13
|
-
//![@UI.PartOfPreview]: false
|
|
12
|
+
![@UI.PartOfPreview]: false
|
|
14
13
|
}]) {
|
|
15
14
|
// Essentially: Association to many Changes on changes.changeLog.entityKey = ID;
|
|
16
15
|
changes : Association to many ChangeView on changes.entityKey = ID;
|
package/lib/entity-helper.js
CHANGED
|
@@ -85,7 +85,9 @@ async function getObjectId (entityName, fields, curObj) {
|
|
|
85
85
|
if (IDval) try {
|
|
86
86
|
// REVISIT: This always reads all elements -> should read required ones only!
|
|
87
87
|
let ID = assoc.keys?.[0]?.ref[0] || 'ID'
|
|
88
|
-
|
|
88
|
+
// When parent/child nodes are created simultaneously, data is taken from draft table
|
|
89
|
+
_db_data = await SELECT.one.from(assoc._target).where({[ID]: IDval}) ||
|
|
90
|
+
await SELECT.one.from(`${assoc._target}.drafts`).where({[ID]: IDval}) || {}
|
|
89
91
|
} catch (e) {
|
|
90
92
|
LOG.error("Failed to generate object Id for an association entity.", e)
|
|
91
93
|
throw new Error("Failed to generate object Id for an association entity.", e)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/change-tracking",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CDS plugin providing out-of-the box support for automatic capturing, storing, and viewing of the change records of modeled entities.",
|
|
5
5
|
"repository": "cap-js/change-tracking",
|
|
6
6
|
"author": "SAP SE (https://www.sap.com)",
|