forked from saurabh/orbit4-5
child page relocation fixed
This commit is contained in:
parent
bd7e29773f
commit
a160c6b020
|
@ -131,6 +131,17 @@ class PagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def update_child_pages_url(page)
|
||||
page.child_page.each do |cp|
|
||||
if !cp.child_page.blank?
|
||||
update_child_pages_url(cp)
|
||||
else
|
||||
cp.url = page.url + "/#{cp.page_id}"
|
||||
cp.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_item_position
|
||||
@page = Page.find(params[:id])
|
||||
new_parent_page = Page.find(params[:parent_id])
|
||||
|
@ -139,6 +150,9 @@ class PagesController < ApplicationController
|
|||
if new_parent_page.id != old_parent_page_id
|
||||
url = (new_parent_page.url == "/" ? "" : new_parent_page.url)
|
||||
@page.url = url + "/#{@page.page_id}"
|
||||
if !@page.child_page.blank?
|
||||
update_child_pages_url(@page)
|
||||
end
|
||||
end
|
||||
@page.save
|
||||
params["children_ids"].each_with_index do |child,i|
|
||||
|
|
Loading…
Reference in New Issue