orbit-basic/app/helpers/admin/item_helper.rb

26 lines
1.0 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
case node._type
when 'Page'
dest = admin_page_path(node)
when 'Link'
dest = admin_link_path(node)
end
2011-06-10 05:57:42 +00:00
ret << "<ul>"
2011-06-01 02:24:14 +00:00
ret << "<li>"
ret << (link_to node.name, dest)
ret << ' | ' << (link_to t('admin.code'), eval("edit_admin_#{node._type.downcase}_path(node, :code => true)")) if node._type.eql?('Page')
2011-06-10 05:57:42 +00:00
ret << ' | ' << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page') if node._type.eql?('Page')
ret << ' | ' << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link') if node._type.eql?('Page')
2011-06-01 04:00:41 +00:00
ret << ' | ' << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete')
2011-06-01 02:24:14 +00:00
ret << render_children(node)
ret << "</li>"
2011-06-10 05:57:42 +00:00
ret << "</ul>"
2011-06-01 02:24:14 +00:00
end
ret.html_safe
end
end