mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Extract common behavior to BulkActionsController
This commit is contained in:
23
app/webpacker/controllers/bulk_actions_controller.js
Normal file
23
app/webpacker/controllers/bulk_actions_controller.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import ApplicationController from "./application_controller";
|
||||
|
||||
export default class extends ApplicationController {
|
||||
connect() {
|
||||
super.connect();
|
||||
}
|
||||
|
||||
// abstract
|
||||
confirm(action) {
|
||||
this.stimulate(action, this.getOrdersIds());
|
||||
}
|
||||
|
||||
// private
|
||||
getOrdersIds() {
|
||||
const order_ids = [];
|
||||
document
|
||||
.querySelectorAll("#listing_orders input[name='order_ids[]']:checked")
|
||||
.forEach((checkbox) => {
|
||||
order_ids.push(checkbox.value);
|
||||
});
|
||||
return order_ids;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,11 @@
|
||||
import ApplicationController from "./application_controller";
|
||||
import BulkActionsController from "./bulk_actions_controller";
|
||||
|
||||
export default class extends ApplicationController {
|
||||
export default class extends BulkActionsController {
|
||||
connect() {
|
||||
super.connect();
|
||||
}
|
||||
|
||||
confirm() {
|
||||
const order_ids = [];
|
||||
document
|
||||
.querySelectorAll("#listing_orders input[name='order_ids[]']:checked")
|
||||
.forEach((checkbox) => {
|
||||
order_ids.push(checkbox.value);
|
||||
});
|
||||
|
||||
this.stimulate("ResendConfirmationEmailReflex#confirm", order_ids);
|
||||
super.confirm("ResendConfirmationEmailReflex#confirm");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user