class Matestack::Ui::VueJs::Components::Form::Radio

Public Instance Methods

component_id() click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 23
def component_id
  "radio-component-for-#{key}"
end
item_id(item) click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 59
def item_id(item)
  "#{id || key}+'_#{item_value(item)}'"
end
item_label(item) click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 55
def item_label(item)
  item.is_a?(Array) ? item.first : item
end
item_name(item) click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 63
def item_name(item)
  "#{key}_#{item_value(item)}"
end
item_value(item) click to toggle source

calculated attributes

# File lib/matestack/ui/vue_js/components/form/radio.rb, line 51
def item_value(item)
  item.is_a?(Array) ? item.last : item
end
radio_attributes(item) click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 34
def radio_attributes(item)
  attributes.merge({
    ":id": item_id(item),
    name: item_name(item),
    value: item_value(item),
    type: :radio,
    ref: "select.#{key}",
    'value-type': value_type(item_value(radio_options.first))
  })
end
radio_options() click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 45
def radio_options
  @radio_options ||= options.delete(:options)
end
render_options() click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 16
def render_options
  radio_options.to_a.each do |item|
    input radio_attributes(item)
    label item_label(item), ":for": item_id(item)
  end
end
response() click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 9
def response
  div class: 'matestack-ui-core-form-radio' do
    render_options
    render_errors
  end
end
v_model_type() click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 67
def v_model_type
  item_value(radio_options.first).is_a?(Numeric) ? 'v-model.number' : 'v-model'
end
vue_props() click to toggle source
# File lib/matestack/ui/vue_js/components/form/radio.rb, line 27
def vue_props
  {
    init_value: init_value,
    key: key,
  }
end