Class: DcSimpleMenu
- Inherits:
-
Object
- Object
- DcSimpleMenu
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/dc_simple_menu.rb
Overview
Schema information
Collection name: dc_simple_menu : Simple menus
_id BSON::ObjectId _id
created_at Time created_at
updated_at Time updated_at
name String Menu name
description String Short description of menu
div_name String Div id name around menu area
link_prepend String Link field usually holds direct link to document. Prepand field holds data, that has to be prepanded to the link.
css String CSS for this menu
active Mongoid::Boolean Active
created_by BSON::ObjectId created_by
updated_by BSON::ObjectId updated_by
dc_simple_menu_items Embedded:DcSimpleMenuItem Menu items
Simple menus were first menu system developed for DRG CMS. They can be only two menu levels deep. Menus are described in dc_simple_menu_items embedded documents.
Class Method Summary collapse
-
.choices4_menu(site) ⇒ Object
Will return all top level menu items of specified menu.
-
.choices4_menu_as_tree(site_id = nil) ⇒ Object
Will return menu structure for menus belonging to the site.
-
.update_menu_item_link(document) ⇒ Object
Will update link value of selected menu_item.
Class Method Details
.choices4_menu(site) ⇒ Object
Will return all top level menu items of specified menu. Used in DcPage document for selecting top level selected menu, when document displayed in browser.
Called from DcApplicationHelper :dc_choices4_menu: method.
Parameters:
- Site
-
DcSite document. Site for which menu belongs to. If site is not specified
all current menus in collection will be returned.
Returns: Array. Of choices prepared for select input field.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/dc_simple_menu.rb', line 78 def self.(site) rez = [] = (site..blank? ? all : where(name: site.)).to_a .each do || rez << [.name, nil] ..where(active: true).order_by(:order => 1).each do || rez << ['-- ' + ., ._id] end end rez end |
.choices4_menu_as_tree(site_id = nil) ⇒ Object
Will return menu structure for menus belonging to the site.
Parameters:
- Site
-
DcSite document. Site for which menu belongs to. If site is not specified
all current menus in collection will be returned.
Returns: Array. Of choices prepared for tree:select input field.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/models/dc_simple_menu.rb', line 100 def self.(site_id=nil) qry = where(active: true) # ar = [nil] ar << (site_id.respond_to?(:id) ? site_id.id : site_id) qry = qry.in(dc_site_id: ar) # result = [] qry.each do || result << [.name, .id, nil,0] ..order_by(order: 1).each do |item| result << [item., item.id, .id, item.order] end end result end |
.update_menu_item_link(document) ⇒ Object
Will update link value of selected menu_item.
Do nothing. The method is defined only for compatibility.
122 123 |
# File 'app/models/dc_simple_menu.rb', line 122 def self.(document) end |