mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
11068, apply delete_modals partial
This commit is contained in:
@@ -77,6 +77,9 @@ class ProductsReflex < ApplicationReflex
|
||||
category_options: categories, category_id: @category_id })
|
||||
).broadcast
|
||||
|
||||
render_product_delete_modals
|
||||
render_variant_delete_modals
|
||||
|
||||
cable_ready.replace_state(
|
||||
url: current_url,
|
||||
).broadcast_later
|
||||
@@ -84,6 +87,28 @@ class ProductsReflex < ApplicationReflex
|
||||
morph :nothing
|
||||
end
|
||||
|
||||
def render_product_delete_modals
|
||||
product_ids = @products.pluck(:id)
|
||||
cable_ready.replace(
|
||||
selector: "#products-delete-action-modals",
|
||||
html: render(
|
||||
partial: "admin/products_v3/delete_modals",
|
||||
locals: { object_ids: product_ids, object_type: 'product' }
|
||||
)
|
||||
).broadcast
|
||||
end
|
||||
|
||||
def render_variant_delete_modals
|
||||
variant_ids = @products.joins(:variants).pluck('spree_variants.id')
|
||||
cable_ready.replace(
|
||||
selector: "#variant-delete-action-modals",
|
||||
html: render(
|
||||
partial: "admin/products_v3/delete_modals",
|
||||
locals: { object_ids: variant_ids, object_type: 'variant' }
|
||||
)
|
||||
).broadcast
|
||||
end
|
||||
|
||||
def render_products_form_with_flash
|
||||
locals = { products: @products }
|
||||
locals[:error_counts] = @error_counts if @error_counts.present?
|
||||
|
||||
@@ -17,22 +17,5 @@
|
||||
.spinner
|
||||
= t('.loading')
|
||||
#products-content
|
||||
|
||||
- delete_product_modal = ConfirmModalComponent.new(id: "delete_product",
|
||||
confirm_button_text: t('.delete_product_modal.confirmation_text'),
|
||||
cancel_button_text: t('.delete_product_modal.cancellation_text'),
|
||||
confirm_button_color: :red,
|
||||
controller: "product-actions",
|
||||
confirm_actions: "click->product-actions#delete",
|
||||
confirm_reflexes: nil)
|
||||
= render delete_product_modal do
|
||||
.margin-bottom-30
|
||||
= t('.delete_product_modal.prompt_html')
|
||||
|
||||
- delete_variant_modal = ConfirmModalComponent.new(id: "delete_variant",
|
||||
confirm_button_text: t('.delete_variant_modal.confirmation_text'),
|
||||
cancel_button_text: t('.delete_variant_modal.cancellation_text'),
|
||||
confirm_button_color: :red)
|
||||
= render delete_variant_modal do
|
||||
.margin-bottom-30
|
||||
= t('.delete_variant_modal.prompt_html')
|
||||
#products-delete-action-modals
|
||||
#variant-delete-action-modals
|
||||
|
||||
@@ -816,6 +816,7 @@ en:
|
||||
header:
|
||||
title: Bulk Edit Products
|
||||
loading: Loading your products
|
||||
delete_modals:
|
||||
delete_product_modal:
|
||||
prompt_html: "<h2 style='color: black'>Delete product</h2> <br>This will permanently remove it from your list."
|
||||
confirmation_text: "Delete product"
|
||||
|
||||
Reference in New Issue
Block a user