Is there a current moqui way to, when an action block is executing, and say a condition failed, to pop a container-dialog box for user input? I have been looking at the api docs and if there is a way to do this with a groovy script I have not found it yet. Any ideas?
An action block in Moqui is executed in groovy on the server. A container-dialog box is just javascript on the client. The only way to do this is to pass a message from the server to the client that the javascript will then execute.
Typically how this would be done in base Moqui is have a container dialog button with a conditional element that includes a boolean variable from the actions (which would be a message that is compiled on the server and sent to client).
If you want to get fancy with this, you may require custom javascript or extend a base widget in moqui. This would be when the user loads the page, moqui will send a parameter or json message down to the client that will automatically execute javascript to open the dialogue. You could keep it simple and pass a parameter like containerId
in the url. In the javascript, you’ll get the containerId
(if it exists), and then programatically open the containerId
of the container-dialog box.
thank you for the reply michael. I was talking about something like this:
<transition name="checkSomething">
<actions>
<if condition="somethingFailed"><then>
do popup - take user input - end execution - reload page
</then><else>
continue execution
</else>
</if>
</actions>
<default-response url="."/>
</transition>
I have not yet made any custom js to do something like this before. Where would you recommend i start example wise for doing this?
I would try to use different responses as a first approach, take a look at the conditional-response tags that could go before the default-response. It does not directly support the same UI as a popup, but it would implement the workflow you intend.
As jenshp said. Having a conditional response which directs to a page which includes some embedded js code to pop up a popup ui. The embedded js is written into page by using groovy string interpolating. This is what i come up with.