diff --git a/README.md b/README.md index e20415b3..75f22617 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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). diff --git a/lib/plugin.js b/lib/plugin.js index 5357b55a..7a985788 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -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`,