Sha256: aaa6186f8140a74464d0d127a4972e62a2f590d62cbb932049f11a70fcc6d6ba

Contents?: true

Size: 746 Bytes

Versions: 41

Compression:

Stored size: 746 Bytes

Contents

module Plugins
  module Core
    class BooleanCell < Plugins::Core::Cell
      def checkbox
        render
      end

      def switch
        render
      end

      private

      def value
        if data
          data['value'] == 'true' ? true : false
        else
          false
        end
      end

      def checkbox_id
        @options[:field_name]
      end

      def render_checkbox_label
        @options[:form].label :data, field.name, class: 'mdl-checkbox__label'
      end

      def render_checkbox
        @options[:form].check_box 'data[value]', { checked: value, class: 'mdl-checkbox__input', id: checkbox_id }, 'true', 'false'
      end

      def render_switch
        raise 'not implemented'
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
cortex-plugins-core-0.3.0 app/cells/plugins/core/boolean_cell.rb