diff --git a/app/components/confirm_modal_component.rb b/app/components/confirm_modal_component.rb index 8149a729e3..7034db03c6 100644 --- a/app/components/confirm_modal_component.rb +++ b/app/components/confirm_modal_component.rb @@ -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 diff --git a/app/components/confirm_modal_component/confirm_modal_component.html.haml b/app/components/confirm_modal_component/confirm_modal_component.html.haml index 1184602a67..210bc724a8 100644 --- a/app/components/confirm_modal_component/confirm_modal_component.html.haml +++ b/app/components/confirm_modal_component/confirm_modal_component.html.haml @@ -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 } diff --git a/app/views/admin/products_v3/_delete_modal.html.haml b/app/views/admin/products_v3/_delete_modal.html.haml index 40b6fbd32d..ca0987ab4e 100644 --- a/app/views/admin/products_v3/_delete_modal.html.haml +++ b/app/views/admin/products_v3/_delete_modal.html.haml @@ -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