I want to be able to update a Resource via an a...
# avo-2
w
I want to be able to update a Resource via an action in multiple steps. Step 1's data will inform Step 2 on what fields to show next. I was thinking of creating a custom Resource Tool and using Stimulus, but I still want to make sure it's an action modal. Does anyone have any recommendations on how to do that or know if it's possible?
m
Thread automatically created by tiff.raff in #740893011994738751
l
there are a few ways that come to mind. 1. using Avo actions you can start in one action, do your logic there and in the end redirect to another action using the
redirect
actions response. then you repeat (logic and redirect to a differnet action or page) 2. usign a custom tool. with this technique you should use regular Rails, Turbo and Stimulus code. depending on what you're trying to achieve, you might not need stimulus at all. But have one
modal
turbo frame and after each modal respond from the controller within the same frame with a new modal.
choosing a strategy depends on how complex and custom should the experience be.
if you go with no. 2, just do the regular Rails flow (view -> controller -> respond with view again). just like you'd do it regularly
I did it for a project and I didn't need to use any stimulus
w
Thanks for your quick response. For the
redirect
action response, would the path for another action be something like:
redirect_to avo.actions_step_two_path
?
l
it seems that the action routes are not named so the path helpers will not work
so you can now use regular strings to do it
redirect_to "/avo/resources/posts/1/actions?action_id=Sub::DummyAction"
we'll add them soon
w
It seems that the redirect using that route doesn't work and just runs the action, closing the modal and notifying the user that the action ran successfully. This is the case for:
redirect_to "/avo/resources/some_resource/#{model_id}/actions?action_id=StepTwo"
AND
redirect_to "/avo/resources/some_resource/1/actions?action_id=StepTwo"
I'll try option 2 next though.
l
Let me give it a try tomorrow
Ok. @loud-jewelry-99127 updated the codebase to support this use case for Avo 3 yesterday. He'll push an update on Avo 2 as well.
you can subscribe to this issue for tracking https://github.com/avo-hq/avo/issues/1993