Skip to content

Commit bed2fa8

Browse files
committed
ReadMe update and revert changes done for running ITs
1 parent 57464f7 commit bed2fa8

5 files changed

Lines changed: 76 additions & 7 deletions

File tree

.github/workflows/cfdeploy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ jobs:
5555
- name: Verify and Checkout Deploy Branch 🔄
5656
run: |
5757
git fetch origin
58-
echo "📂 Verifying 'appChangesToDisableUploadBtn' branch..."
59-
if git rev-parse --verify origin/appChangesToDisableUploadBtn; then
60-
git checkout appChangesToDisableUploadBtn
58+
echo "📂 Verifying 'local_deploy' branch..."
59+
if git rev-parse --verify origin/local_deploy; then
60+
git checkout local_deploy
6161
echo "✅ Branch checked out successfully!"
6262
else
63-
echo "❌ Branch 'appChangesToDisableUploadBtn' not found. Please verify the branch name."
63+
echo "❌ Branch 'local_deploy' not found. Please verify the branch name."
6464
exit 1
6565
fi
6666

.github/workflows/multiTenancyDeployLocal.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Clone the cloud-cap-samples-java repo 🌐
6060
run: |
6161
echo "🔄 Cloning repository..."
62-
git clone --depth 1 --branch appChngsToDisableUploadBtn https://github.com/vibhutikumar07/cloud-cap-samples-java.git
62+
git clone --depth 1 --branch local_mtTests https://github.com/vibhutikumar07/cloud-cap-samples-java.git
6363
echo "✅ Repository cloned!"
6464
6565
- name: Override cds.services.version (runtime only)

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
2626
- 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.
2727
- Attachment Upload Status: Upload Status is the new field which displays the upload status of attachment when being uploaded.
2828
- 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.
2930

3031
## Table of Contents
3132

@@ -47,6 +48,7 @@ This plugin can be consumed by the CAP application deployed on BTP to store thei
4748
- [Support for Localization](#support-for-localization)
4849
- [Support for Attachment Upload Status](#support-for-attachment-upload-status)
4950
- [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)
5052
- [Known Restrictions](#known-restrictions)
5153
- [Support, Feedback, Contributing](#support-feedback-contributing)
5254
- [Code of Conduct](#code-of-conduct)
@@ -1392,6 +1394,74 @@ To create attachments on active entities, the leading application needs to trigg
13921394
Insert.into("MyService.MyEntity.attachments").entry(attachmentData)
13931395
);
13941396

1397+
## Support for Upload Button Visibility Control
1398+
1399+
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+
### How It Works
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`. The UI 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 Leading Applications
1407+
1408+
#### Step 1Add 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 : Boolean default true;
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 };
1451+
}
1452+
```
1453+
1454+
```cds
1455+
annotate MyService.Books.attachments with @(
1456+
Capabilities: { InsertRestrictions: { Insertable: up_.isAttachmentsUploadable } }
1457+
);
1458+
annotate MyService.Books.references with @(
1459+
Capabilities: { InsertRestrictions: { Insertable: up_.isReferencesUploadable } }
1460+
);
1461+
```
1462+
1463+
> **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+
13951465
## Known Restrictions
13961466

13971467
- UI5 Version 1.135.0: This version causes error in upload of attachments.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</developers>
2424

2525
<properties>
26-
<revision>1.0.0-RC1</revision>
26+
<revision>1.8.1-SNAPSHOT</revision>
2727
<java.version>17</java.version>
2828
<maven.compiler.source>${java.version}</maven.compiler.source>
2929
<maven.compiler.target>${java.version}</maven.compiler.target>

sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMAttachmentsServiceHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public void markAttachmentAsDeleted(AttachmentMarkAsDeletedEventContext context)
9393
String objectId = contextValues[0];
9494
String folderId = contextValues[1];
9595
String entity = contextValues[2];
96-
// 4th segment is upID embedded at creation time (absent in old contentId format → null)
9796
String upIDFromContentId = contextValues.length >= 4 ? contextValues[3] : null;
9897
logger.debug(
9998
"Processing deletion - objectId: {}, folderId: {}, entity: {}",

0 commit comments

Comments
 (0)