cuba-platform / reports

CUBA Reports Addon
https://www.cuba-platform.com/
Apache License 2.0
9 stars 4 forks source link

Expose annotated standard actions #212

Closed alexbudarov closed 4 years ago

alexbudarov commented 5 years ago

Description of the bug or enhancement

CUBA 7.0 introduced standard actions: http://cubadev:8181/manual/standard_actions.html

These actions can be simply added to a table by typing "type" attribute. Also Studio scans these actions and suggests them to user in a Screen Designer.

From first glance, at least TablePrintFormAction / ListPrintFormAction can work as a standard action.

Updates

Relates to #178. The ExecutionHistoryAction, RunReportAction and ListPrintFormAction are implemented as standard actions.

ExecutionHistoryAction

ExecutionHistoryAction - standard action for displaying the report execution history. It should be defined on the screen that is associated with Report. It should be defined for a Button or a list component (Table, DataGrid, etc.). To view the report execution history set app property reporting.executionHistory.enabled = true.

Add ExecutionHistoryAction to Button
Action execReportAction = actions.create(ExecutionHistoryAction.class, "execHistoryReport");
execReportBtn.setAction(execReportAction);

When the action is performed, a modal ExecutionHistoryDialog will open where reports related to the current screen will be displayed (to link the screen and the report, see the corresponding section below).

ExecutionHistoryDialog

image.png After clicking on the Execution History button, the execution history for the selected reports will be displayed. If no reports have been selected, then a execution history will be displayed for all reports associated with the screen.

ListPrintFormAction

ListPrintFormAction - for printing reports for a list of entity instances associated with a list component (Table, DataGrid, etc.). It should be defined for a list component in a screen XML descriptor. The action only selects reports having an external parameter of the Entity or the List of entities type and where the parameter entity type matches the entity type displayed by the list component. If only one report is available as a result of selection, it is invoked immediately. If several reports are available, their list is offered to the user for selection.

When the action is performed, if no entities were selected from the list component, a confirmation window will be displayed. image.png After that, the modal Run reports dialog will open where reports related to the current screen will be displayed (to link the screen and the report, see the corresponding section below).

Print reports dialog

image.png From this modal screen, the user can run the selected report for the selected entity.

RunReportAction

RunReportAction - standard action for displaying the list of all available reports. It should be defined on the screen that is associated with Report. It should be defined for a Button or a list component (Table, DataGrid, etc.).

Add RunReportAction to Button
Action runReportAction = actions.create(RunReportAction.class, "runReport");
runReportBtn.setAction(runReportAction);

When the action is performed, a modal ReportRun dialog will open where reports related to the current screen will be displayed (to link the screen and the report, see the corresponding section below).

ReportRun dialog

image.png

How to link screen and report

To associate a screen with a report you need: 1) Open Report editor 2) Go to Roles and Screens tab 3) Add a new screen to report.

Test project

reports-standard-actions.zip

QA

1) Create Customer entity 2) Create Report for Customer entity 3) Add Customer.browse screen to report

andreysubbotin commented 4 years ago

Comments from Mario:

natfirst commented 4 years ago

RunReportAction and ExecutionHistoryAction return exception repot -est.zip

java.lang.UnsupportedOperationException: Unsupported meta class repotest_TotalEntity for runReport action
    at com.haulmont.reports.gui.actions.list.RunReportAction.actionPerform(RunReportAction.java:94)
    at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(WebButton.java:67)
    at com.haulmont.cuba.web.widgets.CubaButton.fireClick(CubaButton.java:76)
    at com.vaadin.ui.Button$1.click(Button.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:431)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:396)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1578)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
    at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
    at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108)
    at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)
    at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)