Module: ConstructorPages::TreeviewHelper
- Included in:
- PagesHelper, TemplatesController, TemplatesHelper
- Defined in:
- app/helpers/constructor_pages/treeview_helper.rb
Instance Method Summary collapse
Instance Method Details
#arrow_buttons_for(item) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/constructor_pages/treeview_helper.rb', line 33 def (item) output = "<div class='btn-group'>" {down: :right, up: :left}.each_pair do |a, b| sibling = item.send(b.to_s+'_sibling') if sibling and item.move_possible?(sibling) output += link_to("<i class='icon-arrow-#{a}'></i>".html_safe, "/admin/#{item.class.to_s.demodulize.downcase.pluralize}/move/#{a}/#{item.id}", class: 'btn btn-mini') end end output += "</div>" output.html_safe end |
#render_tree(roots, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/constructor_pages/treeview_helper.rb', line 3 def render_tree(roots, &block) output = '<ul>' roots.each do |root| level, last = root.level, nil root.self_and_descendants.each do |item| if item.level > level output += '<ul>' elsif item.level < level output += '</li>' output += '</ul></li>' * (level-item.level) elsif !item.root? output += '</li>' end output += '<li>' output += capture(item, &block) level, last = item.level, item end output += '</li>' output += '</ul></li>' * last.level end output.html_safe end |