billowy-easter-81499
05/02/2023, 4:28 AMredirect_to avo.resources_communities_path Avo::Filters::BaseFilter.encode_filters({"ClientFilter"=>models[0].id})
Produces
http://localhost:3000/crm/resources/communities.eyJwYXJhbXMiOnt9fQ==%0A
While I believe for this whole thing to work it needs to produce this
localhost:3000/crm/resources/communities?page=1&filters=eyJDbGllbnRGaWx0ZXIiOjQwMDExfQ==%0A
Am I not encoding it properly? Is there another, easier, way to pass data via URLs I am missing?
Thanks!lemon-wall-20836
05/02/2023, 5:17 AMfilters
paramlemon-wall-20836
05/02/2023, 5:18 AMruby
redirect_to avo.resources_communities_path(filters: Avo::Filters::BaseFilter.encode_filters({"ClientFilter"=>models[0].id}))
lemon-wall-20836
05/02/2023, 5:18 AMbillowy-easter-81499
05/02/2023, 5:35 AMlemon-wall-20836
05/02/2023, 5:38 AMbillowy-easter-81499
05/02/2023, 5:38 AMclass DummyAction < Avo::BaseAction
self.name = "Dummy action"
def handle(**args)
filters = Avo::Filters::BaseFilter.decode_filters(params[:filters])
do_something_important_with_the_filters filters
end
end
Are we able to access any URL params from an Action? I.e. do I need to even encode something I simply want to pass from a URL to an Action?lemon-wall-20836
05/02/2023, 5:40 AMparams
objectlemon-wall-20836
05/02/2023, 5:40 AMbillowy-easter-81499
05/02/2023, 5:41 AMAvo::Filters::BaseFilter.decode_filters(params[:filters])
?lemon-wall-20836
05/02/2023, 5:41 AMparams
🙂lemon-wall-20836
05/02/2023, 5:41 AMlemon-wall-20836
05/02/2023, 5:42 AMlemon-wall-20836
05/02/2023, 5:42 AMbillowy-easter-81499
05/02/2023, 5:43 AMbillowy-easter-81499
05/02/2023, 5:43 AMlemon-wall-20836
05/02/2023, 5:43 AMlemon-wall-20836
05/02/2023, 5:43 AMbillowy-easter-81499
05/02/2023, 2:50 PMaction ExportCsv
action ShortlistCommunities,
arguments: {
client_id: Avo::App.view_context.params[:client_id].to_i
}
However, this does work!
CLIENT_ID = Avo::App.view_context.params[:client_id].to_i
action ExportCsv
action ShortlistCommunities,
arguments: {
client_id: CLIENT_ID
}
lemon-wall-20836
05/02/2023, 3:58 PMAvo::App.view_context.params[:client_id].to_i
can be shortened to skip the view_context
like so Avo::App.params[:client_id].to_i
AFAIKbillowy-easter-81499
05/02/2023, 4:56 PMlemon-wall-20836
05/02/2023, 5:36 PMview_context
it is 😛billowy-easter-81499
05/02/2023, 6:05 PMlemon-wall-20836
05/02/2023, 7:35 PMlemon-wall-20836
05/02/2023, 7:36 PMreload
action reponsebillowy-easter-81499
05/02/2023, 8:04 PMAvo::App.view_context.params[:client_id].to_i
in CommunityResource and pass the params as arguments to an Action. This works the first time, but does not in subsequent routes (ie navigate to another page and back).
In my console I can see Avo::CommunitiesController is able to detect the query params as the URL changes even after first load. Wondering how I can expose those params to CommunityResource and Action?
The end goal =
1. visit Client profile and Select "Search Communities" action which navigates to Community Index View with query param containing client_id
2. on Community Index View evaluate the client_id param (if available) and show the user which Client they are currently searching Communities on behalf of
3. select a subset communities and utilize an Action to save them to a list for that specific client (currently I am passing the client_id as an argument to the Action from the CommunityResource)lemon-wall-20836
05/02/2023, 8:05 PMlemon-wall-20836
05/02/2023, 8:05 PMbillowy-easter-81499
05/02/2023, 8:06 PMwide-art-99889
05/02/2023, 9:35 PMlemon-wall-20836
05/03/2023, 5:41 AM