mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Have a tiny url state management by using replace_state of cable_ready
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
module Admin
|
||||
class ProductsV3Controller < Spree::Admin::BaseController
|
||||
def index; end
|
||||
def index
|
||||
@page = params[:page] || 1
|
||||
@per_page = params[:per_page] || 15
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,6 +28,10 @@ class ProductsReflex < ApplicationReflex
|
||||
locals: { products: @products, pagy: @pagy })
|
||||
).broadcast
|
||||
|
||||
cable_ready.replace_state(
|
||||
url: current_url,
|
||||
).broadcast_later
|
||||
|
||||
morph :nothing
|
||||
end
|
||||
|
||||
@@ -60,4 +64,11 @@ class ProductsReflex < ApplicationReflex
|
||||
# ]
|
||||
]
|
||||
end
|
||||
|
||||
def current_url
|
||||
url = URI(request.original_url)
|
||||
url.query = url.query.present? ? "#{url.query}&" : ""
|
||||
url.query += "page=#{@page}&per_page=#{@per_page}"
|
||||
url.to_s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
= render partial: 'spree/admin/shared/product_sub_menu'
|
||||
|
||||
#products_v3_page{"data-controller": "products"}
|
||||
#products_v3_page{"data-controller": "products", "data-page": @page , "data-perpage": @per_page}
|
||||
#loading-spinner.spinner-container{ "data-controller": "loading" }
|
||||
.spinner
|
||||
= t('.loading')
|
||||
|
||||
Reference in New Issue
Block a user