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/items_helper.rb

54 lines
1.9 KiB
Ruby

module Admin::ItemsHelper
def render_node_and_children(node)
ret = ''
if node
case node.class.to_s
when 'Page'
dest = admin_page_path(node)
when 'Link'
dest = admin_link_path(node)
no_nested = 'no-nest'
end
ret << "<li id='#{node.id}' class='#{no_nested}'>"
ret << "<div class='with_action'><i class='icons-plus-3'></i>"
ret << (link_to node.title, dest, :class => 'js_history')
ret << "<div class='quick-edit hide'>"
ret << (link_to t(:edit), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), :class => 'js_history') if node.class.to_s.eql?('Page')
ret << (link_to t('new.page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.class.to_s.eql?('Page')
ret << (link_to t('new.link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.class.to_s.eql?('Page')
ret << (link_to t(:delete_), eval("delete_admin_#{node.class.to_s.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history')
ret << "</div>"
ret << "</div>"
ret << render_children(node)
ret << "</li>"
end
ret.html_safe
end
def render_children(parent)
children = parent.children
if !parent.children.entries.blank?
ret = ''
ret << "<ol class='#{'sortable' if parent.parent.nil?}'>"
children.each do |child|
ret << render_node_and_children(child)
end
ret << '</ol>'
ret
else
''
end
end
def get_item_module_infos(item)
if module_app = item.module_app
app = OrbitApp::Module::Registration.find_by_key(module_app.key)
[t(app.get_label_i18n), (app.get_icon_class rescue 'icons-daniel-bruce-2')]
else
[t(:no_app), 'icons-daniel-bruce-2']
end
end
end