-
Notifications
You must be signed in to change notification settings - Fork 3
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
Nebulab/bulk actions #91
base: main
Are you sure you want to change the base?
Conversation
This commit is going to add a standard way to load the modals in solidus. They can be load and store as global object Spree.Views.Modals.
This is the base object to create the batch actions. Any batch action object should inherit from it and overriding the `call` method.
Include this concern into controller to manage a batch action list. e.g. ``` include Spree::Backend::Batch set_batch_actions [ { action: 'Spree::BatchAction::DestroyRecordAction', icon: :trash, label: :delete } ] ``` In this way the controller will be able to run the specified batch actions
This modal will show when a batch action is clicked. When the modal is shown it will be possible to show to the user an action preview, in this way we can ask to the user other configuration or just show what the action will do
This commit adds to the Spree::Backend::Batch concern the `preview_batch` action. It will render the related partial under `spree/admin/batch_actions/*BATCH_ACTION_NAME*/preview` template. In this way, any BatchAction would have been its template and ask to the user other fields required to process the collection.
This modal will render the batch action result.
process_batch action is used to execute the BatchAction and return the result as js.
542ace5
to
a1a4449
Compare
Execute the batch action and return the result in a modal.
This is the first batch action. It will handle the delete of multiple records. The partials _preview.html.erb and _result.html.erb are required to support admin user during usage.
a1a4449
to
df0d786
Compare
This is a great addition! A few notes: I changed the Batch Action interface on https://github.com/arfabrands/acs-core/pull/213 slightly to allow parameters to be passed to the batch_action. Basically, the concern collects all parameters under :batch_actions and passes to the action as a hash. I believe this gives greater flexibility to the interface. -- |
Thank you for this addition @cesartalves 💪 |
if (msg.responseJSON["error"]) { | ||
show_flash('error', msg.responseJSON["error"]); | ||
} else { | ||
show_flash('error', "There was a problem adding this coupon code."); |
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.
I believe we can change this to a more generic error message right?
We could also use i18n here so that users can easily customize this message.
if (msg.responseJSON["error"]) { | ||
show_flash('error', msg.responseJSON["error"]); | ||
} else { | ||
show_flash('error', "There was a problem adding this coupon code."); |
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.
Description
Allow executing an action on more than one product.
How it works:
When the item are selected the available actions will be shown at top right.
Click on the action and a modal preview will be open:
Confirm the modal and the BatchAction will be processed
How to make your own action 3b1a45f
Create your callable object under
app/models/spree/batch_action/
and let it to inheredit fromSpree::BatchAction::Base
and return the affected collection.Create the
_preview.html.erb
andresult.html.erb
partials underapp/views/spree/admin/batch_actions/destroy_record_action/
How to use an action on resource controller
df0d786
Add the following code to the Controller:
the
actionable_routes
concern on the related resources route.Make the resource table a selectable table and add the
actionable
class to it.Provide also the right data to it:
Checklist: