class Matestack::Ui::VueJs::Components::Form::Checkbox
Public Instance Methods
checkbox_attributes(item)
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 44 def checkbox_attributes(item) { ":id": item_id(item), type: :checkbox, name: item_label(item), value: item_value(item), ref: "select.multiple.#{key}", '@change': change_event, 'init-value': (init_value || []).to_json, 'v-bind:class': "{ '#{error_class}': #{error_key} }", 'value-type': value_type(item), "#{v_model_type(item)}": input_key, }.merge(self.options) end
checkbox_options()
click to toggle source
checkbox options
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 82 def checkbox_options @checkbox_options ||= options.delete(:options) end
component_id()
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 24 def component_id "checkbox-component-for-#{key}" end
init_value_for_single_input()
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 71 def init_value_for_single_input if init_value == true || init_value == 1 return "true" end if init_value == false || init_value == 0 return "false" end end
item_id(item)
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 96 def item_id(item) "#{id}+'_#{item_value(item).to_s.gsub(" ", '_')}'" end
item_label(item)
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 92 def item_label(item) item.is_a?(Array) ? item.first : item end
item_value(item)
click to toggle source
calculated attributes
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 88 def item_value(item) item.is_a?(Array) ? item.last : item end
render_checkbox_options()
click to toggle source
checkbox rendering
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 37 def render_checkbox_options checkbox_options.to_a.each do |item| input checkbox_attributes(item) label item_label(item), ":for": item_id(item) end end
render_options()
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 16 def render_options if checkbox_options render_checkbox_options else render_true_false_checkbox end end
render_true_false_checkbox()
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 59 def render_true_false_checkbox input true_false_checkbox_attributes.merge(type: :hidden, ":id": nil, value: 0) input true_false_checkbox_attributes.merge(type: :checkbox, ":id": item_id(1)) label input_label, ":for": item_id(1) if input_label end
response()
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 9 def response div class: 'matestack-ui-core-form-checkbox' do render_options render_errors end end
true_false_checkbox_attributes()
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 65 def true_false_checkbox_attributes attributes.merge({ 'init-value': init_value_for_single_input, }) end
vue_props()
click to toggle source
# File lib/matestack/ui/vue_js/components/form/checkbox.rb, line 28 def vue_props { init_value: init_value, key: key, } end