Class: Ecm::Cms::NavigationItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ecm::Cms::NavigationItem
- Includes:
- Model::Ecm::Cms::NavigationItem::PropertiesConcern
- Defined in:
- app/models/ecm/cms/navigation_item.rb
Instance Method Summary collapse
- #params_for_new_page ⇒ Object
- #to_label ⇒ Object
- #to_s ⇒ Object
- #update_children_navigations! ⇒ Object
- #update_navigation_from_parent! ⇒ Object
- #update_url_form_page! ⇒ Object
Instance Method Details
#params_for_new_page ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/ecm/cms/navigation_item.rb', line 32 def params_for_new_page return {} if self.new_record? match = url.scan(/(#{I18n.available_locales.join('|')})$/) return { locale: match[0][0], pathname: '/', basename: 'home', title: name, ecm_cms_navigation_item_ids: [to_param] } if match.size > 0 match = url.scan(/(#{I18n.available_locales.join('|')})(.*)\/(.*)/) return {} unless match.first.respond_to?(:size) # && match.first.size != 3 params = match.first return {} if params.size != 3 params[1] << '/' unless params[1].end_with?('/') { locale: params[0], pathname: params[1], basename: params[2], title: name, ecm_cms_navigation_item_ids: [to_param] } end |
#to_label ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/models/ecm/cms/navigation_item.rb', line 44 def to_label if depth > 0 "#{' ' * depth} ▶ #{name}".html_safe else name end end |
#to_s ⇒ Object
52 53 54 |
# File 'app/models/ecm/cms/navigation_item.rb', line 52 def to_s "#{ecm_cms_navigation}: #{name}" end |
#update_children_navigations! ⇒ Object
61 62 63 |
# File 'app/models/ecm/cms/navigation_item.rb', line 61 def descendants.map(&:"update_navigation_from_parent!") end |
#update_navigation_from_parent! ⇒ Object
56 57 58 59 |
# File 'app/models/ecm/cms/navigation_item.rb', line 56 def save! end |
#update_url_form_page! ⇒ Object
65 66 67 68 69 |
# File 'app/models/ecm/cms/navigation_item.rb', line 65 def update_url_form_page! # self.url = build_url_from_page(ecm_cms_page.locale, ecm_cms_page.pathname, ecm_cms_page.basename, ecm_cms_page.home_page?) update_url_form_page save! end |