Sha256: 399fdef00932374c0a1c0d6aad877e8c8c676ad9fdd2b9aa7832e0653f639b72

Contents?: true

Size: 560 Bytes

Versions: 5

Compression:

Stored size: 560 Bytes

Contents

module FieldTypes
  module Core
    class TreeCell < FieldTypes::Core::Cell
      def checkboxes
        render
      end

      def dropdown
        render
      end

      private

      def value
        data&.[]('values') || @options[:default_value]
      end

      def render_select
        @options[:form].select 'data[values]', metadata_values, {selected: value}
      end

      def metadata_values
        @options[:metadata]["data"]["tree_array"].map do |value|
          [value["node"]["name"], value["id"]]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cortex-field_types-core-0.2.3 app/cells/field_types/core/tree_cell.rb
cortex-field_types-core-0.2.2 app/cells/field_types/core/tree_cell.rb
cortex-field_types-core-0.2.1 app/cells/field_types/core/tree_cell.rb
cortex-field_types-core-0.1.1 app/cells/field_types/core/tree_cell.rb
cortex-field_types-core-0.1.0 app/cells/field_types/core/tree_cell.rb