Hi,
i created a cuba app-component that you can use. It is in preview mode currently. Before releasing it “officially” i would like to get your feedback on it. It is open source (Apache 2 license) and you can find it on github:
If you have any thoughts on that, like bug, feature requests etc. i would love to hear from you.
I’ll just copy over the README.md so you get an impression on what it does:
CUBA Platform Component - Attachable
This application component lets you easily add attachments to any entity in your application.
Just add @WithAttachments
on the browse screen of your entity and the rest will be done by this app-component.
Usage
To add attachments to your entity, you have to add the following annotation to your browse / edit screen controller:
@WithAttachments(listComponent = "customersTable")
public class CustomerBrowse extends AnnotatableAbstractLookup {
}
For the @WithAttachments
annotation you need to define the list component on which it should add the attachments button.
Normally this is the id
of the table you defined in your browse screen.
This annotation will create a button in the buttonsPanel of the table and add the Attachments button after the default CUBA buttons.
The @WithAttachments
annotations can be customized through the following attributes:
-
String listComponent
- the id of the list component / table where the button will be added - REQUIRED -
String buttonId
- the id of the newly created button that will be created (“attachmentBtn” by default) -
String buttonsPanel
- the id of the buttons panel where the new button will be added (“buttonsPanel” by default)
Example usage
To see this application component in action, check out this example: cuba-example-using-attachable.
Attachment list
The attachment button will show all attachments that have been added to a particular selected entity.
It allows to add, edit & remove attachments to this entity.
Attachment preview
Furthermore it gives the user the option to preview the attachment directly in the browser or download the attachment.
The ability to do the preview depends on the attachment type and the browser capabilities.
Configuration options
The application components adds the following application properties, that can be changed in the corresponding screen (`Administration > Application Properties):
-
attachable.updateAttachmentCounterOnSelect
- whether or not a counter of attachments should be displayed after a particular entity is selected in the table
Installation
NOTE: Dependency: declarative-controllers
This application component requires declarative-controllers
as another dependency you have to add to your application.
The reason is, that you need to extend your screen from AnnotatableAbstractLookup
instead of AbstractLookup
.
This superclass is part of the app-component: cuba-component-declarative-controllers.
Technically it is not strictly required to directly add the dependency to declarative-controllers
, since attachable
already has a dependency on it.
However: since you directly depend on the app component (with extending your classes from AnnotatableAbstractLookup
),
it is a best practice to explicitly declare the dependency to it.
-
Add the following maven repository
https://dl.bintray.com/mariodavid/cuba-components
to the build.gradle of your CUBA application:buildscript {
//... repositories { // ... maven { url "https://dl.bintray.com/mariodavid/cuba-components" } } // ...
}
-
Select a version of the add-on which is compatible with the platform version used in your project:
Platform Version | declarative-controllers | Add-on Version |
---|---|---|
6.8.x | 0.4.x | 0.1.x |
Add custom application component to your project:
- Artifact group:
de.diedavids.cuba.attachable
- Artifact name:
attachable-global
- Version: add-on version
- install the compatible version of cuba-component-declarative-controllers as another dependecy (see Table from 2. for version compatability).