Class: Ecm::Cms::NavigationItem

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Model::Ecm::Cms::NavigationItem::PropertiesConcern
Defined in:
app/models/ecm/cms/navigation_item.rb

Instance Method Summary collapse

Instance Method Details

#params_for_new_pageObject



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_labelObject



44
45
46
47
48
49
50
# File 'app/models/ecm/cms/navigation_item.rb', line 44

def to_label
  if depth > 0
    "#{'&nbsp;' * depth} &#9654; #{name}".html_safe
  else
    name
  end
end

#to_sObject



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 update_children_navigations!
  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 update_navigation_from_parent!
  update_navigation_from_parent
  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