Sha256: 1661e543e53a0cd4d0b89aab5f20c746112aeb50fae44b6fa4e8ecd5523c6c12
Contents?: true
Size: 1.08 KB
Versions: 7
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true class CheckboxListCell < UiComponents::Cell attribute :form, mandatory: true, description: 'A form object.' attribute :name, mandatory: true, description: 'The name attribute.' attribute :values, mandatory: true, description: 'The value attributes of the checkboxes.' attribute :two_columns, description: 'Whether the checkboxes appear in two columns.' attribute :checkbox_class, description: 'extra classes per list-item.' attribute :wrapper_class, description: 'extra classes for the ul/wrapper element' def show content_tag(:ul, box_li_tags, class: css_class) end private def css_class "ui-components-checkbox-list #{'two-columns' if options[:two_columns]} #{wrapper_class}" end def box_li_tags boxes.map do |box| content_tag(:li, box, class: checkbox_class) end.join.html_safe end def boxes options[:values].map do |value| options[:form].check_box(options[:name], { multiple: true, label: label(value) }, value, nil) end end def label(key) controller.t(".#{options[:name]}.#{key}") end end
Version data entries
7 entries across 7 versions & 1 rubygems