mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Simplify: don't need to pass through the js controller
Use the reflex itself + Don't need to create a method that will be called only in the connect + Simply code by adding only two lifecycle methods Actually it seems that all reflex related to products controller should show/hide loading
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
= t(".pagination.total_html", total: pagy.count, from: pagy.from, to: pagy.to)
|
||||
%div.with-dropdown
|
||||
= t(".pagination.per_page.show")
|
||||
= select_tag :per_page, options_for_select([15, 25, 50, 100].collect{|i| [t('.pagination.per_page.per_page', num: i), i]}, pagy.items), data: { action: "change->products#changePerPage" }
|
||||
= select_tag :per_page, options_for_select([15, 25, 50, 100].collect{|i| [t('.pagination.per_page.per_page', num: i), i]}, pagy.items), data: { reflex: "change->products#change_per_page" }
|
||||
|
||||
@@ -4,38 +4,14 @@ export default class extends ApplicationController {
|
||||
connect() {
|
||||
super.connect();
|
||||
// Fetch the products on page load
|
||||
this.fetch();
|
||||
}
|
||||
|
||||
fetch = () => {
|
||||
this.stimulate("Products#fetch");
|
||||
};
|
||||
}
|
||||
|
||||
changePerPage = (event) => {
|
||||
this.stimulate("Products#change_per_page", event.target);
|
||||
};
|
||||
|
||||
beforeFilter() {
|
||||
beforeReflex() {
|
||||
this.showLoading();
|
||||
}
|
||||
|
||||
afterFilter() {
|
||||
this.hideLoading();
|
||||
}
|
||||
|
||||
beforeChangePerPage() {
|
||||
this.showLoading();
|
||||
}
|
||||
|
||||
afterChangePerPage() {
|
||||
this.hideLoading();
|
||||
}
|
||||
|
||||
beforeFetch() {
|
||||
this.showLoading();
|
||||
}
|
||||
|
||||
afterFetch() {
|
||||
afterReflex() {
|
||||
this.hideLoading();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user