mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
12398: update confirm_modal to use button_to form submission
This commit is contained in:
@@ -12,7 +12,8 @@ class ConfirmModalComponent < ModalComponent
|
||||
confirm_button_class: :primary,
|
||||
confirm_button_text: I18n.t('js.admin.modals.confirm'),
|
||||
cancel_button_text: I18n.t('js.admin.modals.cancel'),
|
||||
actions_alignment_class: 'justify-space-around'
|
||||
actions_alignment_class: 'justify-space-around',
|
||||
confirm_submit_method: nil
|
||||
)
|
||||
super(id:, close_button: true)
|
||||
@confirm_actions = confirm_actions
|
||||
@@ -24,6 +25,7 @@ class ConfirmModalComponent < ModalComponent
|
||||
@confirm_button_text = confirm_button_text
|
||||
@cancel_button_text = cancel_button_text
|
||||
@actions_alignment_class = actions_alignment_class
|
||||
@confirm_submit_method = confirm_submit_method
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -7,4 +7,9 @@
|
||||
|
||||
%div{ class: "modal-actions #{@actions_alignment_class}" }
|
||||
%input{ class: "button icon-plus #{close_button_class}", type: 'button', value: @cancel_button_text, "data-action": "click->modal#close" }
|
||||
%input{ id: 'modal-confirm-button', class: "button icon-plus #{@confirm_button_class}", type: 'button', value: @confirm_button_text, "data-action": @confirm_actions, "data-reflex": @confirm_reflexes }
|
||||
- # TODO: This if block needs to be removed when we completely get rid of Reflex
|
||||
- # The button's form action will be dynamically set when the modal is opened via modal-link-controller
|
||||
- if @confirm_submit_method
|
||||
= button_to @confirm_button_text, '', id: 'modal-confirm-button', method: @confirm_submit_method, data: { action: @confirm_actions }
|
||||
- else
|
||||
%input{ id: 'modal-confirm-button', class: "button icon-plus #{@confirm_button_class}", type: 'button', value: @confirm_button_text, "data-action": @confirm_actions, "data-reflex": @confirm_reflexes }
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
actions_alignment_class: 'justify-end',
|
||||
confirm_reflexes: "click->products#delete_#{object_type}",
|
||||
confirm_actions: "click->modal#close",
|
||||
confirm_submit_method: :delete,
|
||||
)
|
||||
= render delete_modal do
|
||||
%h2.margin-bottom-20.black-text
|
||||
|
||||
Reference in New Issue
Block a user