Sha256: 8cb127b38e4da31a86f873ad0b29cbbffc29ed3a50461cec2c542a5620051123

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

module TaoUi
  module Components
    module Tree
      class ListComponent < TaoOnRails::Components::Base

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

        def initialize view, items, options = {}
          super view, options
          @items = items
          @children_key = @options.delete(:children_key)
          @selectable = @options.delete(:selectable)
          @selected = @options.delete(:selected)
          @remote = @options.delete(:remote)
          @expanded = @options.delete(:expanded)
          @depth = @options.delete(:depth)
        end

        def render &block
          view.content_tag 'div', html_options do
            content = ''.html_safe
            items.each do |item|
              content += view.tao_tree_item item, {
                children_key: children_key,
                selectable: selectable,
                selected: selected,
                depth: depth,
                remote: remote,
                expanded: expanded
              }, &block
            end

            content
          end
        end

        def self.component_name
          :tree_list
        end

        private

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

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tao_ui-0.2.9 lib/tao_ui/components/tree/list_component.rb
tao_ui-0.2.8 lib/tao_ui/components/tree/list_component.rb
tao_ui-0.2.7 lib/tao_ui/components/tree/list_component.rb