Skip to content
Snippets Groups Projects
Commit 61b7b88e authored by pabois's avatar pabois
Browse files

treeview save

parent b17c11d4
No related branches found
No related tags found
No related merge requests found
......@@ -8,18 +8,16 @@ class Admin::Communication::Website::PagesController < Admin::Communication::Web
end
def reorder
parent_id = params[:parentId].blank? ? nil : params[:parentId]
parent_page = @website.pages.find(params[:parentId])
ids = params[:ids] || []
first_page = nil
ids.each.with_index do |id, index|
page = @website.pages.find(id)
first_page = page if index == 0
page.update(
parent_id: parent_id,
parent_id: parent_page.id,
position: index + 1
)
end
first_page.sync_with_git if first_page
parent_page.sync_with_git
end
def children
......
......@@ -13,18 +13,23 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro
def reorder
parent_id = params[:parentId].blank? ? nil : params[:parentId]
ids = params[:ids] || []
first_program = nil
ids.each.with_index do |id, index|
program = current_university.education_programs.find(id)
first_program = program if index == 0
program.update(
parent_id: parent_id,
position: index + 1,
skip_websites_categories_callback: true
)
unless parent_id
program.set_websites_categories
program.sync_with_git
end
end
if parent_id
parent = current_university.education_programs.find(parent_id)
parent.set_websites_categories
parent.sync_with_git
end
first_program.set_websites_categories if first_program
first_program.sync_with_git if first_program
end
def children
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment