[CUBA-component] Attachable - preview


(Mario David) #1

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.

  1. 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"
         }
     }
     
     // ...
    

    }

  2. 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

The latest version is: Download

Add custom application component to your project:

  • Artifact group: de.diedavids.cuba.attachable
  • Artifact name: attachable-global
  • Version: add-on version
  1. install the compatible version of cuba-component-declarative-controllers as another dependecy (see Table from 2. for version compatability).

(Ilia Rodionov) #2

Hi, Mario,
great work, man! I am particularly interested in the declarative controllers component in view of implementing functionality which can be described as “declarative component constraints”. I’d like to have a common mechanism to solve tasks like “if entity status is CLOSED you can change nothing” (a component should be disabled). It could be achieved easily for simple fields using Entity Attribute Access Control but this doesn’t work for collections when marking collections as read-only should lead to setting the corresponding table disable flag.

Regards,
Ilia.


(Mario David) #3

Hi,

just wanted to let you know that 0.3.0 is out for usage. The following things were added:

Added

  • Possibility to add Tags to Attachments (#1)
  • Multi Upload for attachments (#3)
  • Drag & Drop while uploading files (#5)
  • bugfix for erasing name after file upload (#2)

Check it out: https://bintray.com/mariodavid/cuba-components/cuba-component-attachable/0.3.0


(Mario David) #4

Attachable for @CubaPlatform is out in 0.4.0 with PostgreSQL support as well as Attachment Categories. Check it out: https://github.com/mariodavid/cuba-component-attachable