diff --git a/app/controllers/admin/communication/blocks/headings_controller.rb b/app/controllers/admin/communication/blocks/headings_controller.rb index e10f042ba50884e81f8c78b89fb9a32927de4d78..a6fcc60d82ad175a98887cb741ef881c09becde9 100644 --- a/app/controllers/admin/communication/blocks/headings_controller.rb +++ b/app/controllers/admin/communication/blocks/headings_controller.rb @@ -2,14 +2,18 @@ class Admin::Communication::Blocks::HeadingsController < Admin::Communication::B load_and_authorize_resource class: Communication::Block::Heading, through: :current_university, through_association: :communication_block_headings + def reorder parent_id = params[:heading] ids = params[:ids] || [] ids.each.with_index do |id, index| - heading = current_university.communication_block_headings.find(id) - heading.parent_id = parent_id - heading.position = index + 1 - heading.save + @heading = current_university.communication_block_headings.find(id) + @heading.update_columns position: index + 1, + parent_id: parent_id + end + if @heading.about&.respond_to?(:is_direct_object?) + @heading.about.is_direct_object? ? @heading.about.sync_with_git + : @heading.about.touch # Sync indirect object's direct sources through after_touch end end diff --git a/app/controllers/admin/communication/blocks_controller.rb b/app/controllers/admin/communication/blocks_controller.rb index 7adcae290de87a5f482f19bf437bf736767059c1..808d3796f3d84f9487e1ecd64a8963e63be92732 100644 --- a/app/controllers/admin/communication/blocks_controller.rb +++ b/app/controllers/admin/communication/blocks_controller.rb @@ -11,7 +11,10 @@ class Admin::Communication::BlocksController < Admin::Communication::Application @block.update_columns position: index + 1, heading_id: heading_id end - @block.about.touch + if @block.about&.respond_to?(:is_direct_object?) + @block.about.is_direct_object? ? @block.about.sync_with_git + : @block.about.touch # Sync indirect object's direct sources through after_touch + end end def new diff --git a/app/controllers/admin/education/programs_controller.rb b/app/controllers/admin/education/programs_controller.rb index 59a0f35341d48d284ee31506e1d1976da106258d..572ab0028d9214ef667a9e6381fe7096e6c8de1a 100644 --- a/app/controllers/admin/education/programs_controller.rb +++ b/app/controllers/admin/education/programs_controller.rb @@ -36,11 +36,11 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro if old_parent_id old_parent = current_university.education_programs.find(old_parent_id) old_parent.set_websites_categories - old_parent.sync_with_git + old_parent.touch end program = current_university.education_programs.find(params[:itemId]) program.set_websites_categories - program.sync_with_git + program.touch end def children diff --git a/app/controllers/concerns/admin/reorderable.rb b/app/controllers/concerns/admin/reorderable.rb index 783c36c0ae941d7102677a3408eec8a318b2df0a..cd6fa8d253f07fa1a780e0af3f03d2d9301fd942 100644 --- a/app/controllers/concerns/admin/reorderable.rb +++ b/app/controllers/concerns/admin/reorderable.rb @@ -8,7 +8,10 @@ module Admin::Reorderable object = model.find_by(id: id) object.update_column(:position, index + 1) unless object.nil? end - first_object.sync_with_git if first_object&.respond_to?(:sync_with_git) + if first_object&.respond_to?(:is_direct_object?) + first_object.is_direct_object? ? first_object.sync_with_git + : first_object.touch # Sync indirect object's direct sources through after_touch + end # Used to add extra code yield first_object if block_given? end diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 327082ab82b322f1aee761673bcb6d0be02d47e2..f180bd78ccea3767c8e81a7b21214ac05710d9a7 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -153,7 +153,7 @@ class Communication::Block < ApplicationRecord protected def last_ordered_element - about.blocks.ordered.last + about.blocks.where(heading_id: heading_id).ordered.last end def set_university_and_website_from_about diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index 8c1237b2e60616f47c047bcb9a3c929ee4ffd799..7ec3f4ab31691c985a7d735a2aaeb3aa0c2c5de9 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -99,7 +99,7 @@ class Communication::Website::Category < ApplicationRecord end def references - posts + [parent] + website.menus + posts + [parent] + siblings + website.menus end def update_children_paths diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 0cdbfd1fe8398c612d48acbc2621a3a355cf3974..dc4c2a23056f40047d55c26713ed1ab9cdd61e23 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -100,6 +100,7 @@ class Communication::Website::Page < ApplicationRecord def references [parent] + + siblings + website.menus + abouts_with_page_block end