Sha256: a56bf91ff27f53fa1ecfb26fedc4a778a2779797cb1ba425c14f3542c171f277
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module SortableTreeHelper def render_sortable_tree(items, opts={}) render :partial=>'sortable_tree/sortable_tree', locals: {items: items, options: opts} end def sortable_tree_render_nested_groups(groups, opts={}) content_tag(:ol) do groups.map do |item, sub_groups| content_tag(:li, {id: "cat_#{item.id}"} ) do #(item.title + sortable_tree_render_nested_groups(sub_groups, opts)).html_safe s = content_tag(:div, {class: 'item'}) do ( #'<div class="cell left"><i class="handle"></i></div>'\ '<h3 class="cell left">'+item.send(opts[:name_method] || :name)+'</h3>'\ '<div class="cell right controls">'+sortable_tree_build_actions(item, opts)+'</div>' ).html_safe end (s + sortable_tree_render_nested_groups(sub_groups, opts)).html_safe end end.join.html_safe end end def sortable_tree_build_actions(item, opts={}) partial = opts[:controls_partial] || nil if partial render :partial=>partial, locals: {item: item, options: opts} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sortable_tree_rails-0.0.2 | app/helpers/sortable_tree_helper.rb |
sortable_tree_rails-0.0.1 | app/helpers/sortable_tree_helper.rb |