app/components/coco/app/elements/button/button.rb in coveragebook_components-0.7.8 vs app/components/coco/app/elements/button/button.rb in coveragebook_components-0.7.9

- old
+ new

@@ -42,10 +42,25 @@ set_option_value(:confirm, true) Coco::App::Elements::ConfirmPanel.new(**kwargs) end } + before_initialize do |kwargs| + kwargs[:button_element] ||= {} + if kwargs.key?(:modal) + modal_name = (kwargs[:modal] == true) ? "default" : kwargs[:modal] + kwargs[:button_element][:data] = kwargs[:button_element].fetch(:data, {}).merge(coco_modal_data_attributes(modal_name)) + kwargs.delete(:modal) + end + if kwargs.key?(:frame) + turbo_data = {turbo: true, turbo_frame: kwargs[:frame]} + kwargs[:button_element][:data] = kwargs[:button_element].fetch(:data, {}).merge(turbo_data) + kwargs.delete(:frame) + end + kwargs + end + before_render do if confirm? && !dropdown? with_confirmation do |confirm| confirm.with_text { "Are you sure?" } confirm.with_button { "Yes, continue" } @@ -57,9 +72,13 @@ with_dropdown_content(...) end def with_confirmation(...) with_dropdown_confirmation(...) + end + + class << self + include Coco::BaseHelper end end end end end