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
|
2012-05-11 02:00:45 +00:00
|
|
|
# ret << "<ol>" unless node.parent.nil?
|
|
|
|
ret << "<li id='#{node.id}'>"
|
2012-04-27 03:02:56 +00:00
|
|
|
ret << "<div class='with_action'>"
|
2012-02-24 11:11:51 +00:00
|
|
|
ret << (link_to node.i18n_variable[I18n.locale], dest)
|
2012-04-27 03:02:56 +00:00
|
|
|
ret << "<div class='quick-edit hide'>"
|
2012-04-19 03:50:54 +00:00
|
|
|
ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)")) if node._type.eql?('Page')
|
|
|
|
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')
|
|
|
|
ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete')
|
|
|
|
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>"
|
2012-05-11 02:00:45 +00:00
|
|
|
# ret << "</ol>" unless node.parent.nil?
|
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-05 16:35:13 +00:00
|
|
|
children = parent.ordered_children
|
|
|
|
if !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
|
|
|
|
|
2012-05-11 02:00:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# <ol class="sortable">
|
|
|
|
# <li><div>Some content</div></li>
|
|
|
|
# <li><div>Some content</div>
|
|
|
|
# <ol>
|
|
|
|
# <li><div>Some sub-item content</div></li>
|
|
|
|
# <li><div>Some sub-item content</div></li>
|
|
|
|
# </ol>
|
|
|
|
# </li>
|
|
|
|
# <li><div>Some content</div></li>
|
|
|
|
# </ol>
|