Coder Social home page Coder Social logo

cubait / cuba-component-dynamic-columns Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 2.0 440 KB

A CUBA Framework component that adds dynamic columns support (user created) for Table components (Web module only)

Java 98.58% Shell 1.42%
cuba addon cuba-platform cuba-component dynamic-columns

cuba-component-dynamic-columns's Introduction

license Marketplace


๐Ÿšจ WARNING ๐Ÿšจ

Please read this issue: The add-on is not compatible with new Screens and Data components API in CUBA 7.0

Subscribe to the issue to be notified when progress is made. New screen API support is planned for version 3.0


CUBA Dynamic Columns Add-on

A CUBA Framework add-on component that adds dynamic columns support (user created) for Table components.

Basically it provides a custom action that you can add to your table components, and associate to a button (or context menu item, or whatever you want) that when triggered display a dialog where the user can add/edit/remove dynamic columns whose value is generated by a Groovy script.

Installation

NOTE: This add-on's repository is officially linked to the main CUBA repository.

You can jump straight to step 2. for instructions on how to add it to your project, or optionally you can choose to add my repository to your project's repositories.

  1. [OPTIONAL] Add the following maven repository https://dl.bintray.com/pfurini/cuba-components to the build.gradle of your CUBA application:
buildscript {
    
    //...
    
    repositories {
    
        // ...
    
        maven {
            url  "https://dl.bintray.com/pfurini/cuba-components"
        }
    }
    
    // ...
}
  1. Select a version of the add-on which is compatible with the platform version used in your project:
Platform Version Add-on Version Coordinates
6.8.x 1.0.0 it.nexbit.cuba.dynamiccolumns:nxdcol-global:1.0.0
6.9.x 1.1.0 it.nexbit.cuba.dynamiccolumns:nxdcol-global:1.1.0
6.10.x 1.2.0 it.nexbit.cuba.dynamiccolumns:nxdcol-global:1.2.0
7.0.x 2.0.0 it.nexbit.cuba.dynamiccolumns:nxdcol-global:2.0.0

The latest stable version is: 2.0.0 for CUBA 7.0

  1. Install the correct add-on version in your project using CUBA Studio, or manually by editing your build.gradle file.

Supported DBMS engines

N/A - This component does not add any new table. It relies on the UserSettingService and its underlying table (SEC_USER_SETTING).

Created tables

NONE

Usage

Configuration

Some component behaviour can be altered by means of configuration properties.

Application properties

The following properties can be set in *.properties files (typically in your web-app.properties file). For programmatic access use the DynamicColumnsConfig interface.

Property Default Value Description
nxdcol.editActionShortcut CTRL-ALT-D The keyboard shortcut associated with the editDynamicColumns action

How to use in your project

The component is designed to enhance the Table components in a web module.

To use it, create a new browse screen or open an existing one in your project, then add the <yourTableId>.editDynamicColumns like in the following example:

...
<groupTable id="orderLinesTable"
            width="100%">
    <actions>
        <action id="create"/>
        <action id="edit"/>
        <action id="remove"/>
        <action id="refresh"/>
    </actions>
    <columns>
        <column id="productName"/>
        <column id="price"/>
        <column id="quantity"/>
    </columns>
    <rows datasource="orderLinesDs"/>
    <rowsCount/>
    <buttonsPanel id="buttonsPanel"
                  alwaysVisible="true">
        <button id="createBtn"
                action="orderLinesTable.create"/>
        <button id="editBtn"
                action="orderLinesTable.edit"/>
        <button id="removeBtn"
                action="orderLinesTable.remove"/>
        <button id="refreshBtn"
                action="orderLinesTable.refresh"/>
        <!-- WE ARE ADDING THE ACTION TO A BUTTON IN THE TABLE'S BUTTONSPANEL -->
        <button id="editDynamicColsBtn"
                action="orderLinesTable.editDynamicColumns"/>
    </buttonsPanel>
</groupTable>
...

Now you need to inject the action to your table. For this you need to put some code in the screen's controller:

public class OrderLineBrowse extends AbstractLookup {

    /* 
       The @InjectDynamicColumnsAction can be added to any table field in your controller,
       and it accepts an optional `dynamicCaption` argument.
       The default value is `true` if omitted, but you can set it to `false` like in the 
       following example.
       When `dynamicCaption` is `true`, the Caption of the GUI component associated to the action
       (in our case a Button) becomes an integer, that represents the number of dynamic columns
       defined for the associated table (starting from 0).
     */ 
    @InjectDynamicColumnsAction(dynamicCaption = false)
    @Inject
    private GroupTable<OrderLine> orderLinesTable;

    @Override
    public void init(Map<String, Object> params) {

        // ... other init code here ...
        
        // the following line initialises the actions for all table components marked with the
        // @InjectDynamicColumnsAction attribute. Put this at the end of your `init()` method.
        DynamicColumnsManager.inject(this);
    }

}

That's it! The following screenshot shows the browse screen with one Dynamic Column and a dynamicCaption enabled button:

While the following is the same browse screen but with dynamicCaption = false:

Clicking on the Dynamic Columns button opens a dialog where each user can add/edit/remove own dynamic columns, for that specific table in that specific screen. Every user has their unique settings.

Extending

The dynamic-column-browse screen can be extended in the usual CUBA way, so you can alter the standard behaviour to better suit your needs.

The component registers the following beans, that you can override in your project:

  • nxdcol_EditDynamicColumnsAction - prototype component implemented by the EditDynamicColumnsAction class
  • nxdcol_DynamicColumnsManager - prototype component which interface is DynamicColumnsManager and implemented by the concrete class DynamicColumnsManagerImpl

cuba-component-dynamic-columns's People

Contributors

pfurini avatar

Watchers

 avatar  avatar  avatar

Forkers

douit flavio58it

cuba-component-dynamic-columns's Issues

The add-on is not compatible with new Screens and Data components API in CUBA 7.0

The add-on has been updated to compile with CUBA 7.0 in version 2.0, but its usage is compatible only with the legacy GUI APIs (see https://doc.cuba-platform.com/manual-7.1/gui_legacy.html).

In its current form it can be used to support the upgrade of older projects, written for framework 6.x, to CUBA 7.0, as long as the project keeps using the legacy screens and datasources APIs.

If you plan to add new screens in your project, you won't be able to use the Dynamic Columns add-on in them.

Add configurable result formatting

Now the result from Groovy script is simply displayed as a string, without custom formatting.
We should add the ability to format the result, like in a spreadsheet cell (for ex: Currency, Date/time, and so on, plus custom format string).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.