From 5d490ded1581f1bb687fd1067eb7e61b7db92902 Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Sat, 25 Nov 2023 15:00:48 +0500 Subject: [PATCH] #11068, update ConfirmModalComponent to take more options --- app/components/confirm_modal_component.rb | 16 ++++++++++++++-- .../confirm_modal_component.html.haml | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/components/confirm_modal_component.rb b/app/components/confirm_modal_component.rb index ccd0c67797..39ed7f90e0 100644 --- a/app/components/confirm_modal_component.rb +++ b/app/components/confirm_modal_component.rb @@ -1,14 +1,26 @@ # frozen_string_literal: true class ConfirmModalComponent < ModalComponent - def initialize(id:, confirm_actions: nil, reflex: nil, controller: nil, message: nil, - confirm_reflexes: nil) + def initialize( + id:, + reflex: nil, + controller: nil, + message: nil, + confirm_actions: nil, + confirm_reflexes: nil, + confirm_button_color: :primary, + confirm_button_text: I18n.t('js.admin.modals.confirm'), + cancel_button_text: I18n.t('js.admin.modals.cancel') + ) super(id:, close_button: true) @confirm_actions = confirm_actions @reflex = reflex @confirm_reflexes = confirm_reflexes @controller = controller @message = message + @confirm_button_color = confirm_button_color + @confirm_button_text = confirm_button_text + @cancel_button_text = cancel_button_text 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 1b3e1ff217..5049e9e52c 100644 --- a/app/components/confirm_modal_component/confirm_modal_component.html.haml +++ b/app/components/confirm_modal_component/confirm_modal_component.html.haml @@ -6,5 +6,5 @@ = render @message if @message .modal-actions - %input{ class: "button icon-plus #{close_button_class}", type: 'button', value: t('js.admin.modals.cancel'), "data-action": "click->modal#close" } - %input{ class: "button icon-plus primary", type: 'button', value: t('js.admin.modals.confirm'), "data-action": @confirm_actions, "data-reflex": @confirm_reflexes } + %input{ class: "button icon-plus #{close_button_class}", type: 'button', value: @cancel_button_text, "data-action": "click->modal#close" } + %input{ class: "button icon-plus #{@confirm_button_color}", type: 'button', value: @confirm_button_text, "data-action": @confirm_actions, "data-reflex": @confirm_reflexes }