Class: SdrViewComponents::Elements::ButtonFormComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Elements::ButtonFormComponent
- Defined in:
- app/components/sdr_view_components/elements/button_form_component.rb
Overview
Component for a button that is wrapped in a form
Instance Attribute Summary collapse
-
#link ⇒ Object
readonly
Returns the value of attribute link.
Instance Method Summary collapse
- #call ⇒ Object
- #classes ⇒ Object
- #data ⇒ Object
-
#initialize(link:, label: nil, variant: :primary, classes: [], method: :get, confirm: nil, top: true, data: {}) ⇒ ButtonFormComponent
constructor
rubocop:disable Metrics/ParameterLists.
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(link:, label: nil, variant: :primary, classes: [], method: :get, confirm: nil, top: true, data: {}) ⇒ ButtonFormComponent
rubocop:disable Metrics/ParameterLists
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/components/sdr_view_components/elements/button_form_component.rb', line 7 def initialize(link:, label: nil, variant: :primary, classes: [], method: :get, confirm: nil, # rubocop:disable Metrics/ParameterLists top: true, data: {}) @link = link @label = label @variant = variant @classes = classes @method = method @confirm = confirm @top = top @data = data super() end |
Instance Attribute Details
#link ⇒ Object (readonly)
Returns the value of attribute link.
20 21 22 |
# File 'app/components/sdr_view_components/elements/button_form_component.rb', line 20 def link @link end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/components/sdr_view_components/elements/button_form_component.rb', line 22 def call (link, method: @method, class: ComponentSupport::ButtonSupport.classes(variant: @variant, classes:), form: { data: }) do @label || content end end |
#classes ⇒ Object
30 31 32 |
# File 'app/components/sdr_view_components/elements/button_form_component.rb', line 30 def classes merge_classes(@classes) end |
#data ⇒ Object
34 35 36 37 38 39 |
# File 'app/components/sdr_view_components/elements/button_form_component.rb', line 34 def data @data.tap do |data| data[:turbo_frame] = '_top' if @top data[:turbo_confirm] = @confirm if @confirm end end |