Skip to content

Commit 0d0b540

Browse files
authored
Allow for lazy loading of change history (SAP UI5) (#42)
1 parent 7d07e19 commit 0d0b540

File tree

4 files changed

+50
-17
lines changed

4 files changed

+50
-17
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7-
## Version 1.0.3 - TBD
7+
## Version 1.0.3 - 07.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.
812

913
### Changed
1014

1115
- Support cases where parent/child entries are created simultaneously.
16+
- Allow for lazy loading of change history table (with SAP UI5 release 1.120.0).
1217

1318
## Version 1.0.2 - 31.10.23
1419

README.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,28 @@ The `@cap-js/change-tracking` package is a [CDS plugin](https://cap.cloud.sap/do
88
2. [Add `@changelog` annotations to your CDS models](#annotations)
99
3. [Et voilà:](#change-history-view)
1010

11-
<img width="1300" alt="change-history-custom" src="_assets/changes.png">
11+
<img width="1300" alt="change-history-loading" src="_assets/change-history.gif">
1212

1313

1414

1515
### Table of Contents
1616

17-
- [Preliminaries](#preliminaries)
18-
- [Setup](#setup)
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)
25-
- [Contributing](#contributing)
26-
- [Code of Conduct](#code-of-conduct)
27-
- [Licensing](#licensing)
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)
2833

2934

3035

@@ -162,13 +167,19 @@ With the steps above, we have successfully set up change tracking for our refere
162167

163168
## Change History View
164169

170+
> [!IMPORTANT]
171+
> To ensure proper lazy loading of the Change History table, please use **SAPUI5 version 1.120.0** or higher.<br>
172+
> If you wish to *disable* this feature, please see the customization section on how to [disable lazy loading](#disable-lazy-loading).
173+
165174
<img width="1300" alt="change-history" src="_assets/changes.png">
166175

167176
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.
168177

169-
### Customizations
178+
## Customizations
179+
180+
### Altered table view
170181

171-
The 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:
182+
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:
172183

173184
```cds
174185
using from '@cap-js/change-tracking';
@@ -190,6 +201,24 @@ In the UI, the *Change History* table now contains 5 equally-spaced columns with
190201

191202
For more information and examples on adding Fiori Annotations, see [Adding SAP Fiori Annotations](https://cap.cloud.sap/docs/advanced/fiori#fiori-annotations).
192203

204+
### Disable lazy loading
205+
206+
To disable the lazy loading feature of the *Change History* table, you can add the following annotation to your `srv/change-tracking.cds`:
207+
208+
```cds
209+
using from '@cap-js/change-tracking';
210+
211+
annotate sap.changelog.aspect @(UI.Facets: [{
212+
$Type : 'UI.ReferenceFacet',
213+
ID : 'ChangeHistoryFacet',
214+
Label : '{i18n>ChangeHistory}',
215+
Target: 'changes/@UI.PresentationVariant',
216+
![@UI.PartOfPreview]
217+
}]);
218+
219+
```
220+
221+
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.
193222

194223
## Contributing
195224

_assets/change-history.gif

1.88 MB
Loading

index.cds

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ aspect aspect @(UI.Facets: [{
99
ID : 'ChangeHistoryFacet',
1010
Label : '{i18n>ChangeHistory}',
1111
Target: 'changes/@UI.PresentationVariant',
12-
//TODO: Use for lazy-loading once Fiori fixes bugs and v1.120 is released
13-
//![@UI.PartOfPreview]: false
12+
![@UI.PartOfPreview]: false
1413
}]) {
1514
// Essentially: Association to many Changes on changes.changeLog.entityKey = ID;
1615
changes : Association to many ChangeView on changes.entityKey = ID;

0 commit comments

Comments
 (0)