-
-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhancement: access to the query
on all action blocks
#3581
enhancement: access to the query
on all action blocks
#3581
Conversation
Code Climate has analyzed commit 0ef9f22 and detected 0 issues on this pull request. View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @Nevelito!
I've manually tested this PR with the following action code, but it seems there's currently no access to the query
object inside the actions.
Let's make sure the query
object is accessible within action messages/fields.
Additionally, I've left some code review comments, let me know if you have any questions!
class Avo::Actions::Sub::DummyAction < Avo::BaseAction
self.name = -> { "Dummy action" }
self.message = -> { query.first.name }
self.cancel_button_label = -> { query.first.name }
self.confirm_button_label = -> { query.first.name }
self.standalone = true
def fields
field :name, default: query.first.name
end
def handle(query:, **args)
succeed query.first.name
end
end
before_action :set_query, only: [:show, :handle], if: ->(request) do | ||
# set query will fail in show if user will not select some row | ||
# params[:fields] are set during selecting row or in show view | ||
request.params[:fields].present? | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach makes sense for show
, but we should ensure that the conditional check does not apply to handle
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work done here @Nevelito it's looking good!
I'll take over from here and adjust the last details before merging.
query
on action view
query
on action viewquery
on all action blocks
query
on all action blocksquery
on all action blocks
Description
Fixes #2935
Grants access to the
query
object throughout the action, enabling its use when rendering the action view.Here is an example with a test action:
Checklist: