cuba-platform / charts

Charts and Maps Addon
https://www.cuba-platform.com/
Apache License 2.0
5 stars 2 forks source link

ShowPivotAction doesn't support dataContainer #79

Closed Flaurite closed 5 years ago

Flaurite commented 5 years ago

Environment

Description of the bug or enhancement


Changes

In order to support new data containers created new ShowPivotAction and PivotScreenBuilder.

ShowPivotAction

ShowPivotAction has FQN com.haulmont.charts.gui.components.action.list.ShowPivotAction. It has ActionType annotation which allows to use this action from screen layout:

<groupTable id="ordersTable" dataContainer="ordersDc">
    ...
    <actions>
        <action id="showPivot" type="pivot_showPivot"/>
    </actions>

    <buttonsPanel id="buttonsPanel"
                  alwaysVisible="true">
        <button id="showPivotBtn" action="ordersTable.showPivot"/>
    </buttonsPanel>
    ...
</groupTable>

In this case ShowPivotAction will show all available properties in pivot table according to his action rules.

PivotScreenBuilder

PivotScreenBuilder is a spring bean, which provides API for configuring pivot table and selecting specific properties.

It has the same API as old ShowPivotAction

@Inject
protected BeanLocator beanLocator;
...
PivotScreenBuilder builder = beanLocator.getPrototype(PivotScreenBuilder.NAME, table);
builder.withIncludedProperties(Arrays.asList("name", "id"))
        .withItems(table.getItems().getItems())
        .build()
        .show();

For QA

  1. Use withIncludedProperties() and add property with property path (e.g. "customer.name")
  2. Create entity with embbeded id. Try to add to the pivot embbeded id properties.
  3. Create entity with Integer or String id. And try to add it to the pivot table.

You can try this project: showpivotdemo.zip