Sha256: c63d8687a4da646d0381dc80a1246d8c9ac1328eda5f75a8fd15b8cec5d86f24

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'tao_ui/components/tree/item_component'
require 'tao_ui/components/tree/list_component'

module TaoUi
  module Components
    class TreeComponent < TaoOnRails::Components::Base

      attr_reader :items, :selectable, :children_key, :remote, :expanded

      def initialize view, items, options = {}
        super view,options
        @items = items
        @children_key = @options.delete(:children_key)
        @selectable = @options[:selectable] || false
        @remote = @options.delete(:remote)
        @expanded = @options.delete(:expanded)
      end

      def render &block
        view.content_tag tag_name, html_options do
          view.tao_tree_list items, {
            depth: 0,
            selectable: selectable,
            remote: remote,
            expanded: expanded,
            children_key: children_key
          }, &block
        end
      end

      def self.component_name
        :tree
      end

      private

      def default_options
        {class: 'tao-tree', children_key: :children}
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tao_ui-0.2.10 lib/tao_ui/components/tree_component.rb
tao_ui-0.2.9 lib/tao_ui/components/tree_component.rb
tao_ui-0.2.8 lib/tao_ui/components/tree_component.rb
tao_ui-0.2.7 lib/tao_ui/components/tree_component.rb