We are developing a feature for an avo application that functions very much like a "wish list" that you might be familiar with from much larger ecommerce websites. Here's a quick sketch of the intended process:
The application has Clients, Products, Admins, Wishlists (one per client), and WishlistItems (one per product on a WishList).
Admins need to be able to create lists of Products for specific Clients
The ideal place to start this process is from the Client Show page. We have an action that redirects the user to the Products Index Page, and it supplies a search filter to the products that's based on data from the Client.
On the Products Index page, we have an action named "add to wish list". The intent is that selecting Products and running the action should find or create a Wishlist for the Client (from Step 3), and find or create WishlistItems for each Product passed to the action.
The wrinkle in all of this is how to preserve the one piece of state we need (the ID of the client from Step 3) so that it's accessible to the "add to wishlist" action in Step 4. Action arguments appear to be designed for defining at the resource class level, so they don't seem to be a good fit for this kind of per-request parameter. I do not see a way to "pre-load" the value into the Action when the ActionsComponent is rendered on the Products index page either.
Current workarounds
It is possible to define a client_id text field on the AddToWishlist action, and that will generate a form input on the action modal. However, I have not come up with a way to supply that value from within the application.
Another potential workaround is to have the action from step 3 write the client_id onto the Admin record as something like current_wishlist_client_id. We could then have access to that client ID in the action on step 4 via current_user. We would probably also want to add some sort of UI element indicating that the admin has a client selected, and giving the admin a way to unselect the client.
Do you have any other ideas about how we might accomplish this?
Feature
We are developing a feature for an avo application that functions very much like a "wish list" that you might be familiar with from much larger ecommerce websites. Here's a quick sketch of the intended process:
The wrinkle in all of this is how to preserve the one piece of state we need (the ID of the client from Step 3) so that it's accessible to the "add to wishlist" action in Step 4. Action arguments appear to be designed for defining at the resource class level, so they don't seem to be a good fit for this kind of per-request parameter. I do not see a way to "pre-load" the value into the Action when the ActionsComponent is rendered on the Products index page either.
Current workarounds
It is possible to define a
client_id
text field on the AddToWishlist action, and that will generate a form input on the action modal. However, I have not come up with a way to supply that value from within the application.Another potential workaround is to have the action from step 3 write the client_id onto the Admin record as something like
current_wishlist_client_id
. We could then have access to that client ID in the action on step 4 viacurrent_user
. We would probably also want to add some sort of UI element indicating that the admin has a client selected, and giving the admin a way to unselect the client.Do you have any other ideas about how we might accomplish this?