23 lines
831 B
Ruby
23 lines
831 B
Ruby
|
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
|
||
|
ret << "<li>"
|
||
|
ret << (link_to node.name, dest)
|
||
|
ret << ' | ' << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id)) if node._type.eql?('Page')
|
||
|
ret << ' | ' << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id)) if node._type.eql?('Page')
|
||
|
ret << ' | ' << (link_to t(:delete), delete_admin_link_path(node, :authenticity_token => form_authenticity_token), :confirm => t('sure?'), :class => 'delete') if node._type.eql?('Link')
|
||
|
ret << render_children(node)
|
||
|
ret << "</li>"
|
||
|
end
|
||
|
ret.html_safe
|
||
|
end
|
||
|
|
||
|
end
|