Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visibility control of the plugin #57

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The `@cap-js/attachments` package is a [CDS plugin](https://cap.cloud.sap/docs/n
- [Test-drive Locally](#test-drive-locally)
- [Using SAP Object Store](#using-sap-object-store)
- [Using SAP Malware Scanning service](#using-sap-malware-scanning-service)
- [@attachments.UI.Facet.skipAnnotation](#attachmentsuifacetskipannotation)
- [Contributing](#contributing)
- [Code of Conduct](#code-of-conduct)
- [Licensing](#licensing)
Expand Down Expand Up @@ -107,6 +108,23 @@ By default, malware scanning is enabled for all profiles except development prof
}
```

## @attachments.UI.Facet.skipAnnotation
This annotation allows developers to create their own custom facets, for example to control visibility of the plugin.
By setting the `@attachments.UI.Facet.skipAnnotation` property to `true`, developers can hide the plugin from the UI.
This feature is particularly useful in scenarios where the visibility of the plugin needs to be dynamically controlled based on certain conditions.

### Example Usage

```
entity Incidents {
// ...
@attachments.UI.Facet.skipAnnotation
attachments: Composition of many Attachments;
}

```
In this example, the `@attachments.UI.Facet.skipAnnotation` is set to `true`, which means the plugin will be hidden by default.

## Contributing

This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/attachments/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
Expand Down
1 change: 1 addition & 0 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cds.on("loaded", function unfoldModel(csn) {
let facets = comp.parent["@UI.Facets"];
if (!facets) return;
DEBUG?.("Adding @UI.Facet to:", comp.parent.name);
if(comp["@attachments.UI.Facet.skipAnnotation"] == true) return;
facets.push({
$Type: "UI.ReferenceFacet",
Target: `${comp.name}/@UI.LineItem`,
Expand Down