ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 8 replies, has 3 voices, and was last updated by golriz.nourani golriz.nourani 1 year, 6 months ago.

  • Creator
    Topic
  • #16277

    fdellutri
    Participant

    Hi all,
    I’m developing a custom mass action that, before to be performed on selected records, it must show a dialog window to user with a custom form that I defined as a Type. As the user compiles the form and submits it, the mass action can be performed on selected records. In my case, the mass action consists in the creation of a batch job.

    My question is about which is the best method to follow between:
    1) to perform the logic of the mass action directly in the controller of the window dialog, by receiving the post with the form’s data and by creating the job. In this case I need a way to get in the dialog controller the records that the user has selected in the datagrid: in case the user have selected “all”, i need the querybuilder coming from the datagrid.

    2) to receive data in the dialog controller as in the case (1), but passing the data to a specific handler implementing the MassActionHandlerInterface, like it happens in the AjaxMassAction. I see that in this case I’m able to give the querybuilder, but I don’t know how to invoke that handler from the submit button of the dialog and pass form’s data to it.

    Any help will be appreciated!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #16293

    fdellutri
    Participant

    any suggestion?

    #16299
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    Hello, fdellutri.

    It should be rather second option. Here is what I think.

    You can use WidgetMassAction (that was created to handle action with any widget) to handle dialog. This dialog will have it’s own controller to render form, but result should be sent to GridController::massActionAction (like regular delete action) – just don’t forget to include original mass action options (inset, values, filters). Then you should create your own handler (implementation of MassActionHandlerInterface), specify it as a service and pass service ID to mass action. During the action execution your handler will be triggered, and it will receive all request data (including your form data) via $data argument. The final thing you need to do is to handle json response at your dialog.

    I hope it will help you. Feel free to post here any questions related to this issue.

    #16300
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    Also, if you need some additional form processing logic – you can submit form to your own controller, process it there and then call mass action dispatcher.

    #16313

    fdellutri
    Participant

    Thank you Yevhen, it works!

    #17421
    golriz.nourani
    golriz.nourani
    Participant

    Hello
    is it possible explain how should I set original mass action options , and how could I define dialog of mass action?
    is there any example?
    thanks

    #17422
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    Hello.

    Mass action options can be defined in mass action itself and in grid configuration, later they will be merged (datagrid options should have higher priority).

    As for dialog – you should use WidgetMassAction as a basic action and create appropriate JS action (defined in “frontend_type” option). Unfortunately, we don’t have any examples of dialog mass action out of the box, but you can use regular dialog action as an example – technically mass actions are regular grid actions, so interfaces are quite the same.

    #17470
    golriz.nourani
    golriz.nourani
    Participant

    Thanks for your explanation ,
    I am working on it.

    #17673
    golriz.nourani
    golriz.nourani
    Participant

    Dear Sir

    Is it possible to see this forum
    https://www.orocrm.com/forums/topic/%D1%81ustom-javascript-action#post-17668

    thanks

Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.