20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/knitkit/erp_app/desktop/website_controller.rb', line 20
def build_content_tree
nodes = []
if @website
if params[:record_type].blank?
@website.website_sections.positioned.each do |website_section|
nodes << build_section_hash(website_section)
end
else
case params[:record_type]
when 'WebsiteSection'
website_section = WebsiteSection.find(params[:record_id])
nodes = website_section.positioned_children.map { |child| build_section_hash(child) }
website_section.website_section_contents.order('position').each do |website_section_content|
nodes << build_article_hash(website_section_content, @website, website_section.is_blog?)
end
else
raise 'Unknown Node Type'
end
end
end
render :json => nodes
end
|