Class: Arara::Tags::ChipChoice
- Inherits:
-
ActionView::Helpers::Tags::Base
- Object
- ActionView::Helpers::Tags::Base
- Arara::Tags::ChipChoice
- Defined in:
- app/components/arara/tags/chip_choice.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(object_name, method_name, template_object, checked_value, unchecked_value, options) ⇒ ChipChoice
constructor
A new instance of ChipChoice.
- #render ⇒ Object
Constructor Details
#initialize(object_name, method_name, template_object, checked_value, unchecked_value, options) ⇒ ChipChoice
Returns a new instance of ChipChoice.
8 9 10 11 12 |
# File 'app/components/arara/tags/chip_choice.rb', line 8 def initialize(object_name, method_name, template_object, checked_value, unchecked_value, ) @checked_value = checked_value @unchecked_value = unchecked_value super(object_name, method_name, template_object, ) end |
Instance Method Details
#render ⇒ Object
14 15 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 |
# File 'app/components/arara/tags/chip_choice.rb', line 14 def render = @options.stringify_keys ["type"] = "checkbox" ["value"] = @checked_value ["checked"] = "checked" if input_checked?() ["selected"] = !!["checked"] if ["multiple"] add_default_name_and_id_for_value(@checked_value, ) .delete("multiple") else add_default_name_and_id() end include_hidden = .delete("include_hidden") { true } ["data"] ||= {} ["data"]["rails-chip-set-filter-target"] = "rails-chip-set-filter.#{["id"].camelize(:lower)}" checkbox = @template_object.template.render(Arara::ChipComponent, .symbolize_keys) if include_hidden hidden = hidden_field_for_checkbox() hidden + checkbox else checkbox end end |