add theme1 with subnavigation first setup kind of ugly layout

This commit is contained in:
2015-10-12 18:09:33 +02:00
parent ea287f2305
commit a3b3536adc
8 changed files with 103 additions and 4 deletions
+31
View File
@@ -221,4 +221,35 @@ module ApplicationHelper
end
end
end
# used for rendering page trees
def tree_ul(acts_as_tree_set, options = {}, &block)
# If only one option is given, a select is assumed
options = {:select => options} unless options.is_a?(Hash)
# Ensure a select option
options[:select] ||= lambda{|p| true}
options[:select] = options[:select].to_proc if options[:select].is_a?(Symbol)
block ||= lambda{|item| item.name }
acts_as_tree_set.reject!{|m| not options[:select].call(m)}
ret = ''
if acts_as_tree_set.size > 0
if list_id = options.delete(:list_id).presence
ret = %|<ul id="#{list_id}">|
else
ret = "<ul>"
end
acts_as_tree_set.collect do |item|
#next if item.parent_id && init
ret += '<li>'
ret += capture(item, &block)
#tmp = tree_ul(item.children, checker, &block) if item.children.size > 0
#return "#{tmp} is no valid result\n\n" unless tmp.is_a?(String)
#ret += tmp
ret += tree_ul(item.children, options, &block) if item.children.size > 0
ret += '</li>'
end
ret += '</ul>'
end
ret.html_safe
end
end