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: README.md
+70Lines changed: 70 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
26
26
- Localization of error messages and UI fields: Provides the capability to have the UI fields and error messages translated to the local language of the leading application.
27
27
- Attachment Upload Status: Upload Status is the new field which displays the upload status of attachment when being uploaded.
28
28
- Active entity attachment creation: Provides the capability to create attachments directly on active (non-draft) entities.
29
+
- Upload button visibility control: Provides the capability to automatically show or hide the Upload button based on the configured `maxCount` limit.
29
30
30
31
## Table of Contents
31
32
@@ -47,6 +48,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
47
48
-[Support for Localization](#support-for-localization)
48
49
-[Support for Attachment Upload Status](#support-for-attachment-upload-status)
49
50
-[Support for Attachment creation in Active Entities](#support-for-attachment-creation-in-active-entities)
51
+
-[Support for Upload Button Visibility Control](#support-for-upload-button-visibility-control)
The plugin can automatically **hide the Upload button** once the configured `maxCount` is reached, and **re-enable it** when an attachment is deleted and the count drops back below the limit. This gives end users immediate visual feedback about whether further uploads are allowed, without relying solely on an error message after the attempt.
1400
+
1401
+
### HowItWorks
1402
+
1403
+
1.**On upload (create):**After a successful upload, the plugin compares the current attachment count with `maxCount`.If the count reaches or exceeds `maxCount`, a boolean flag on the parent entity (e.g. `isAttachmentsUploadable`) is set to `false`.TheUI reads this flag via a `Capabilities` annotation and hides the Upload button.
1404
+
2.**On delete:**After an attachment is deleted, if the remaining count is below `maxCount`, the same flag is set back to `true` and the Upload button reappears.
1405
+
1406
+
### Usage in LeadingApplications
1407
+
1408
+
#### Step1 — Add a boolean field to the parent entity
1409
+
1410
+
Add a boolean field for each attachment facet that should have Upload button control. The field name must follow the pattern `is<FacetName>Uploadable` where `<FacetName>` is the capitalised name of the composition (e.g. `attachments` → `isAttachmentsUploadable`).
1411
+
1412
+
```cds
1413
+
entity Books {
1414
+
key ID:UUID;
1415
+
...
1416
+
isAttachmentsUploadable :Booleandefaulttrue;
1417
+
attachments :Composition of many Attachments@SDM.Attachments:{ maxCount:4 };
1418
+
}
1419
+
```
1420
+
1421
+
> **Note:** Initialise the field to `true` so the Upload button is visible before any attachment is added.
1422
+
1423
+
#### Step 2 — Annotate the composition at the service layer
1424
+
1425
+
Use the `@Capabilities.InsertRestrictions.Insertable` annotation to bind the Upload button visibility to the flag on the parent entity:
1426
+
1427
+
```cds
1428
+
annotate MyService.Books.attachments with @(
1429
+
Capabilities: {
1430
+
InsertRestrictions: {
1431
+
Insertable: up_.isAttachmentsUploadable
1432
+
}
1433
+
}
1434
+
);
1435
+
```
1436
+
1437
+
The `up_` navigation property refers to the parent `Books` entity. The UI framework reads this annotation and enables or disables the Upload button accordingly.
1438
+
1439
+
#### Multiple facets
1440
+
1441
+
For each additional facet, add its own boolean field and annotation:
1442
+
1443
+
```cds
1444
+
entity Books {
1445
+
key ID : UUID;
1446
+
...
1447
+
isAttachmentsUploadable : Boolean default true;
1448
+
isReferencesUploadable : Boolean default true;
1449
+
attachments : Composition of many Attachments @SDM.Attachments:{ maxCount: 4 };
1450
+
references : Composition of many Attachments @SDM.Attachments:{ maxCount: 3 };
> **Note:** No additional Java or configuration changes are required in the leading application. The plugin derives the field name from the facet's composition name automatically.
1464
+
1395
1465
## Known Restrictions
1396
1466
1397
1467
- UI5 Version 1.135.0: This version causes error in upload of attachments.
0 commit comments