Class: Knitkit::ErpApp::Desktop::AppController
- Inherits:
-
ErpApp::Desktop::BaseController
- Object
- ErpApp::Desktop::BaseController
- Knitkit::ErpApp::Desktop::AppController
- Defined in:
- app/controllers/knitkit/erp_app/desktop/app_controller.rb
Direct Known Subclasses
ArticlesController, CommentsController, ContentController, InquiriesController, OnlineDocumentSectionsController, PositionController, VersionsController, WebsiteController, WebsiteNavController, WebsiteSectionController
Constant Summary collapse
Instance Method Summary collapse
Instance Method Details
#websites ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 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 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/knitkit/erp_app/desktop/app_controller.rb', line 7 def websites websites = Website.order('name ASC').all tree = [] websites.each do |website| @website_primary_host = website.config_value('primary_host') website_hash = { :text => website.name, :configurationId => website.configurations.first.id, :iconCls => 'icon-globe_disconnected', :id => "website_#{website.id}", :leaf => false, :url => "http://#{@website_primary_host}", :name => website.name, :title => website.title, :subtitle => website.subtitle, :isWebsite => true, :siteName => website.name, :children => [] } #handle hosts hosts_hash = {:text => 'Hosts', :iconCls => 'icon-gear', :isHostRoot => true, :websiteId => website.id, :leaf => false, :children => []} website.hosts.each do |website_host| hosts_hash[:children] << {:text => website_host.attributes['host'], :websiteHostId => website_host.id, :host => website_host.attributes['host'], :iconCls => 'icon-globe', :url => "http://#{website_host.attributes['host']}", :isHost => true, :leaf => true, :children => []} end website_hash[:children] << hosts_hash #handle sections sections_hash = {:text => 'Sections', :isSectionRoot => true, :websiteId => website.id, :iconCls => 'icon-content', :leaf => false, :children => []} website.website_sections.positioned.each do |website_section| sections_hash[:children] << build_section_hash(website_section, website) end website_hash[:children] << sections_hash #handle menus = {:text => 'Menus', :iconCls => 'icon-content', :isMenuRoot => true, :websiteId => website.id, :leaf => false, :children => []} website.website_navs.each do |website_nav| = {:text => website_nav.name, :websiteNavId => website_nav.id, :websiteId => website.id, :canAddMenuItems => true, :iconCls => 'icon-index', :isWebsiteNav => true, :leaf => false, :children => []} [:children] = website_nav.website_nav_items.positioned.map{|item|(website, item)} [:children] << end website_hash[:children] << #added website to main tree tree << website_hash end render :json => tree end |