2012-10-09 06:47:16 +00:00
|
|
|
module Admin::ItemsHelper
|
2011-06-01 02:24:14 +00:00
|
|
|
|
|
|
|
def render_node_and_children(node)
|
|
|
|
ret = ''
|
|
|
|
if node
|
2012-07-30 10:34:54 +00:00
|
|
|
case node.class.to_s
|
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}'>"
|
2013-01-09 07:57:31 +00:00
|
|
|
ret << "<div class='with_action'><i class='icons-plus-3'></i>"
|
2012-07-25 21:07:32 +00:00
|
|
|
ret << (link_to node.title, dest, :class => 'js_history')
|
2012-04-27 03:02:56 +00:00
|
|
|
ret << "<div class='quick-edit hide'>"
|
2012-09-21 04:58:44 +00:00
|
|
|
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')
|
2012-09-12 11:12:50 +00:00
|
|
|
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')
|
2012-11-27 03:15:15 +00:00
|
|
|
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')
|
2012-04-19 03:50:54 +00:00
|
|
|
ret << "</div>"
|
2012-04-27 03:02:56 +00:00
|
|
|
ret << "</div>"
|
2012-04-19 03:50:54 +00:00
|
|
|
ret << render_children(node)
|
2012-04-27 03:02:56 +00:00
|
|
|
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 = ''
|
2012-05-11 02:00:45 +00:00
|
|
|
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
|
2012-05-11 02:00:45 +00:00
|
|
|
ret << '</ol>'
|
2011-12-05 02:36:25 +00:00
|
|
|
ret
|
2012-05-05 16:35:13 +00:00
|
|
|
else
|
|
|
|
''
|
2011-12-05 02:36:25 +00:00
|
|
|
end
|
|
|
|
end
|
2013-04-11 19:13:03 +00:00
|
|
|
|
2013-04-25 11:37:00 +00:00
|
|
|
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
|
|
|
|
|
2012-05-11 02:00:45 +00:00
|
|
|
end
|