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
@@ -556,6 +559,189 @@ This plugin provides capability to copy attachments from one entity to another.
556
559
}
557
560
```
558
561
562
+
## Support for link type attachments
563
+
564
+
> **Note:** Row-press is the new recommended approach for handling actions on attachment rows. With row-press enabled, the Attachments column will no longer appear as a separate action button. Instead, clicking on a row will automatically perform the appropriate action — opening a link or downloading a file, based on the attachment type.
565
+
566
+
This plugin provides the capability to create, open, rename and delete attachments of link type.
567
+
568
+
### Steps to Enable Row-Press for Open Link
569
+
570
+
1.**Add the `openAttachment` action to application's service definition**
571
+
572
+
See this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/srv/admin-service.cds#L19) from a sample Bookshop app.
573
+
574
+
```cds
575
+
action openAttachment() returns String;
576
+
```
577
+
578
+
2.**Add a custom controller extension**
579
+
580
+
In webapp/controller/custom.controller.js, copy and paste below content.
581
+
582
+
See this [example](https://github.com/cap-java/sdm/blob/develop_deploy/cap-notebook/demoapp/app/admin-books/webapp/controller/custom.controller.js) from a sample Bookshop app.
- Replace `books` in `ControllerExtension.extend` with the `SAPUI5.Component` name from your `app/appconfig/fioriSandboxConfig.json` file. See this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/appconfig/fioriSandboxConfig.json#L86).
621
+
- Replace `AdminService` in `invokeAction("AdminService.openAttachment")` with the name of your service.
622
+
623
+
3.**Add controlConfiguration for Row Press**
624
+
625
+
In your `sap.ui5.routing.targets` section, under the relevant Object Page (e.g., `BooksDetails`), add or extend the `controlConfiguration` for the facet you want to enhance by copy and pasting below content. See this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/admin-books/webapp/manifest.json#L121)
- Replace `attachments` with your entity’s facet name as needed.
639
+
- Repeat for other facets's if required.
640
+
- Replace `books` in `"rowPress": ".extension.books.controller.custom.onRowPress"` with the SAPUI5.Component name from your
641
+
`app/appconfig/fioriSandboxConfig.json` file. Refer this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/appconfig/fioriSandboxConfig.json#L86) from a sample Bookshop app.
642
+
643
+
4.**Register the Custom Controller Extension**
644
+
645
+
In the root of your `sap.ui5` section, add or extend the `extends` property to register your custom controller by copy and pasting below content. See this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/admin-books/webapp/manifest.json#L159)
- Replace `books` in `"sap.fe.templates.ObjectPage.ObjectPageController#books::BooksDetailsList"` with the SAPUI5.Component name from your
659
+
`app/appconfig/fioriSandboxConfig.json` file. Refer this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/appconfig/fioriSandboxConfig.json#L86) from a sample Bookshop app.
660
+
- Replace `BooksDetailsList` in `"sap.fe.templates.ObjectPage.ObjectPageController#books::BooksDetailsList"` with id of the relevant Object Page (e.g., BooksDetails). Refer this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/admin-books/webapp/manifest.json#L109) from a sample Bookshop app.
661
+
- Replace `books` in `"controllerName": "books.controller.custom"` with the SAPUI5.Component name from your
662
+
`app/appconfig/fioriSandboxConfig.json` file. Refer this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/app/appconfig/fioriSandboxConfig.json#L86) from a sample Bookshop app.
663
+
664
+
### Steps to Enable Create Link Feature in CAP Application
665
+
666
+
> **Note:** Enabling row-press for open link (see steps above) is a prerequisite for link support.
667
+
668
+
1.**Add the `createLink` action to application's service definition**
669
+
670
+
See this [example](https://github.com/cap-java/sdm/blob/90cfc716967d844e114457a710daebdd55431965/cap-notebook/demoapp/srv/admin-service.cds#L12) from a sample Bookshop app:
671
+
672
+
```cds
673
+
action createLink(
674
+
in:many $self,
675
+
@mandatory @Common.Label:'Name' name: String @UI.Placeholder: 'Enter a name for the link',
- Purpose: Enables users to create links with name and URL.
681
+
- Validation: Ensures only valid HTTP(S) URLs are accepted.
682
+
- UI Support: Provides labels and placeholders for better user experience.
683
+
684
+
### UI Annotation Setup
685
+
686
+
To enable the creation of links, you need to add a new button to the attachments table toolbar. This button will appear as a **menu button labeled "Create"** on the toolbar of the attachments table. When clicked, it will display a menu with the **"Link"** option, allowing users to create a new link-type attachment.
687
+
688
+
Add the following annotation block to your app/common.cds file. See this [example](https://github.com/cap-java/sdm/blob/4288ce6f58bc415a171a9e0340fa075aeac835ff/cap-notebook/demoapp/app/common.cds#L60)
annotate Attachments with @Common: {SideEffects #ContentChanged: {
735
+
SourceProperties: [content],
736
+
TargetProperties: ['status'],
737
+
TargetEntities : [Books.attachments]
738
+
}}{};
739
+
```
740
+
741
+
- Replace `my.Books.attachments` with the correct path for your entity and element (for example, `my.YourEntity.yourElement`) where you have defined `composition of many Attachments`.
742
+
- Replace `AdminService` in `Action: 'AdminService.createLink'` with the name of your service.
743
+
- Repeat for other entities and elements if you have defined multiple `composition of many Attachments`.
744
+
559
745
## Known Restrictions
560
746
561
747
- UI5 Version 1.135.0: This version causes error in upload of attachments.
0 commit comments