This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/helpers/admin/item_helper.rb

46 lines
1.6 KiB
Ruby
Raw Normal View History

2011-06-01 02:24:14 +00:00
module Admin::ItemHelper
def render_node_and_children(node)
ret = ''
if node
2012-07-30 09:21:37 +00:00
case node.class
2011-06-01 02:24:14 +00:00
when 'Page'
dest = admin_page_path(node)
when 'Link'
dest = admin_link_path(node)
2012-05-11 08:16:09 +00:00
no_nested = 'no-nest'
2011-06-01 02:24:14 +00:00
end
2012-05-11 08:16:09 +00:00
ret << "<li id='#{node.id}' class='#{no_nested}'>"
2012-05-22 06:45:49 +00:00
# ret << "<i class='icons-moves'></i>"
ret << "<div class='with_action'><i class='icons-moves'></i>"
ret << (link_to node.title, dest, :class => 'js_history')
ret << "<div class='quick-edit hide'>"
2012-07-30 09:21:37 +00:00
ret << (link_to t('admin.edit'), eval("edit_admin_#{node.lass.downcase}_path(node)"), :class => 'js_history') if node.lass.eql?('Page')
ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.lass.eql?('Page')
ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.lass.eql?('Page')
ret << (link_to t(:delete), eval("delete_admin_#{node.lass.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history')
2012-04-19 03:50:54 +00:00
ret << "</div>"
ret << "</div>"
2012-04-19 03:50:54 +00:00
ret << render_children(node)
ret << "</li>"
2011-06-01 02:24:14 +00:00
end
ret.html_safe
end
2011-12-05 02:36:25 +00:00
def render_children(parent)
2012-05-11 08:16:09 +00:00
children = parent.children
if !parent.children.entries.blank?
2011-12-05 02:36:25 +00:00
ret = ''
ret << "<ol class='#{'sortable' if parent.parent.nil?}'>"
2011-12-05 02:36:25 +00:00
children.each do |child|
ret << render_node_and_children(child)
end
ret << '</ol>'
2011-12-05 02:36:25 +00:00
ret
else
''
2011-12-05 02:36:25 +00:00
end
end
end