Module: Admin::NodeHelper
- Included in:
- PagesHelper
- Defined in:
- app/helpers/admin/node_helper.rb
Instance Method Summary collapse
- #expanded ⇒ Object
- #expanded_rows ⇒ Object
- #expander(level) ⇒ Object
- #homepage ⇒ Object
- #icon ⇒ Object
- #node_title ⇒ Object
- #page_type ⇒ Object
- #prepare_page(page) ⇒ Object
- #render_node(page, index, parent_index = nil, simple = false) ⇒ Object
- #render_nodes(page, starting_index, parent_index = nil, simple = false) ⇒ Object
- #show_all? ⇒ Boolean
- #spinner ⇒ Object
Instance Method Details
#expanded ⇒ Object
55 56 57 |
# File 'app/helpers/admin/node_helper.rb', line 55 def show_all? || .include?(@current_node.id) end |
#expanded_rows ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/admin/node_helper.rb', line 34 def unless @expanded_rows @expanded_rows = if rows = [:expanded_rows] rows.split(',').map do |x| begin Integer(x) rescue StandardError nil end end .compact else [] end if homepage && !@expanded_rows.include?(homepage.id) @expanded_rows << homepage.id end end @expanded_rows end |
#expander(level) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'app/helpers/admin/node_helper.rb', line 59 def (level) if @current_node.children.empty? || (level == 0) '' else image(( ? 'collapse' : 'expand'), class: 'expander', alt: 'toggle children', title: '') end end |
#homepage ⇒ Object
26 27 28 |
# File 'app/helpers/admin/node_helper.rb', line 26 def homepage @homepage ||= Page.find_by_parent_id(nil) end |
#icon ⇒ Object
69 70 71 72 |
# File 'app/helpers/admin/node_helper.rb', line 69 def icon icon_name = @current_node.virtual? ? 'virtual_page' : 'page' image(icon_name, class: 'icon', alt: '', title: '') end |
#node_title ⇒ Object
74 75 76 |
# File 'app/helpers/admin/node_helper.rb', line 74 def node_title %{<span class="title">#{h(@current_node.title)}</span>}.html_safe end |
#page_type ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'app/helpers/admin/node_helper.rb', line 78 def page_type display_name = @current_node.class.display_name if display_name == 'Page' '' else %{<span class="info">(#{h(display_name)})</span>}.html_safe end end |
#prepare_page(page) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/helpers/admin/node_helper.rb', line 17 def prepare_page(page) page.extend MenuRenderer page.view = self if page. page.extend(*page.) end page end |
#render_node(page, index, parent_index = nil, simple = false) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'app/helpers/admin/node_helper.rb', line 8 def render_node(page, index, parent_index = nil, simple = false) @current_node = prepare_page(page) @rendered_html += (render partial: 'admin/pages/node', locals: { level: index, index: index, parent_index: parent_index, page: page, simple: simple, branch: (page.children.count.positive?) }) index end |
#render_nodes(page, starting_index, parent_index = nil, simple = false) ⇒ Object
2 3 4 5 6 |
# File 'app/helpers/admin/node_helper.rb', line 2 def render_nodes(page, starting_index, parent_index = nil, simple = false) @rendered_html = '' render_node page, starting_index, parent_index, simple @rendered_html end |
#show_all? ⇒ Boolean
30 31 32 |
# File 'app/helpers/admin/node_helper.rb', line 30 def show_all? controller.action_name == 'remove' end |
#spinner ⇒ Object
87 88 89 90 91 92 |
# File 'app/helpers/admin/node_helper.rb', line 87 def spinner image('spinner.gif', class: 'busy', id: "busy_#{@current_node.id}", alt: '', title: '', style: 'display: none;') end |