Module: WildayUi::Components::Button::Features::ConfirmDialog
- Included in:
- WildayUi::Components::Button::FeatureEngine
- Defined in:
- app/helpers/wilday_ui/components/button/features/confirm_dialog.rb
Constant Summary collapse
- FEATURE_CONFIG =
{ wrapper_required: true, stimulus_controller: "confirmation", default_stimulus_action: "click->confirmation#showDialog" }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #normalize_confirmation_options(options) ⇒ Object
- #setup_confirmation_options(options, additional_classes, confirm, wrapper_data) ⇒ Object
Class Method Details
.feature_config ⇒ Object
12 13 14 |
# File 'app/helpers/wilday_ui/components/button/features/confirm_dialog.rb', line 12 def self.feature_config { confirm: FEATURE_CONFIG } end |
Instance Method Details
#normalize_confirmation_options(options) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/wilday_ui/components/button/features/confirm_dialog.rb', line 45 def () if .is_a?(String) { title: "Confirm Action", message: , variant: :info, confirm_text: "Confirm", cancel_text: "Cancel" } else { title: [:title] || "Confirm Action", message: [:message], variant: [:variant] || :info, confirm_text: [:confirm_text] || "Confirm", cancel_text: [:cancel_text] || "Cancel", loading: [:loading] || false, loading_text: [:loading_text] || "Processing..." } end end |
#setup_confirmation_options(options, additional_classes, confirm, wrapper_data) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/wilday_ui/components/button/features/confirm_dialog.rb', line 16 def (, additional_classes, confirm, wrapper_data) return unless confirm.present? confirm_config = (confirm) # Use the same theme processing as regular buttons confirm_theme_styles = process_theme(:solid, { name: confirm_config[:variant] }) cancel_theme_styles = process_theme(:subtle, { name: :secondary }) wrapper_data.merge!( controller: FEATURE_CONFIG[:stimulus_controller], confirmation_title_value: confirm_config[:title], confirmation_message_value: confirm_config[:message], confirmation_icon_color_value: confirm_config[:variant], confirmation_confirm_text_value: confirm_config[:confirm_text], confirmation_cancel_text_value: confirm_config[:cancel_text], confirmation_confirm_styles_value: confirm_theme_styles, confirmation_cancel_styles_value: cancel_theme_styles ) # Only add loading state if enabled if confirm_config[:loading] wrapper_data.merge!( confirmation_loading_value: "true", confirmation_loading_text_value: confirm_config[:loading_text] ) end end |