Add sub_menu to children

This commit is contained in:
Christophe Vilayphiou committed 2012-05-09 04:15:45 +08:00
1 parent 49e2eb0187
commit 26a50cc862
7 files changed
+36 -12

No files matched your search

+10 -1
View File
@@ -43,8 +43,8 @@ class Admin::PagePartsController < ApplicationController
def update
@part = PagePart.find(params[:id])
if @part.update_attributes(params[:page_part])
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
flash.now[:notice] = t('admin.update_success_content')
@part.save
respond_to do |format|
format.html {
redirect_to admin_page_url( @part.page )
@@ -86,5 +86,14 @@ class Admin::PagePartsController < ApplicationController
format.js {}
end
end
protected
def set_children_sub_menu(part)
part.page.children.each do |child|
child_part = child.page_parts.detect{ |x| x.name.eql?(part.name) } rescue nil
child_part.update_attributes(:kind => part.kind, :public_r_tag => part.public_r_tag, :public_r_tag_object_id => part.public_r_tag_object_id) rescue nil
end
end
end