Fix for submenu automation
This commit is contained in:
parent
3cd3a8bd73
commit
aaf7f7362c
|
@ -23,7 +23,7 @@ class Item
|
||||||
|
|
||||||
before_destroy :destroy_children
|
before_destroy :destroy_children
|
||||||
after_rearrange :rebuild_path, :if => "parent_id_changed? || name_changed?"
|
after_rearrange :rebuild_path, :if => "parent_id_changed? || name_changed?"
|
||||||
after_save :rebuild_children_path, :rebuild_parent_path, :if => "path_changed?"
|
after_save :rebuild_children_path, :rebuild_page_children_path, :if => "path_changed?"
|
||||||
|
|
||||||
def enabled_for_lang(lang)
|
def enabled_for_lang(lang)
|
||||||
enabled_for.include?(lang) rescue false
|
enabled_for.include?(lang) rescue false
|
||||||
|
@ -92,9 +92,13 @@ class Item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def rebuild_parent_path
|
def rebuild_page_children_path
|
||||||
parent = self.parent
|
page = Page.find(self.id)
|
||||||
parent.descendants_and_self
|
page.children.each do |child|
|
||||||
|
child.path = (child.ancestors_and_self - [Page.root]).collect{|x| x.name}.join('/')
|
||||||
|
child.save
|
||||||
|
child.rebuild_children_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Enable the validation for parent_id
|
# Enable the validation for parent_id
|
||||||
|
|
Reference in New Issue