class Interview::Tree
Attributes
icon[RW]
sortable[RW]
Public Instance Methods
build(b)
click to toggle source
# File lib/interview/controls/tree.rb, line 6 def build(b) defaults = {} defaults[:icon] = @icon if @icon and @icon != :polymorphic objects = find_attribute! :objects data_content = objects.map do |object| object_data = { id: object.id.to_s, parent: object.parent_id ? object.parent_id.to_s : '#', text: object.human_id, state: { opened: true }, a_attr: { href: h.polymorphic_path(object) } }.merge defaults object_data[:icon] = object.icon if @icon == :polymorphic object_data end data = { content: CGI::escapeHTML(data_content.to_json) } data[:sortable] = true if @sortable b.section html_class: 'jstree', html_options: { data: data } end