Skip to content
Snippets Groups Projects
Commit 9b78184d authored by Arnaud Levy's avatar Arnaud Levy
Browse files

climate

parent 617d0fc1
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ window.osuny.contentEditor = {
},
// Mode écriture du contenu
sortModeWrite(to) {
sortModeWrite: function (to) {
'use strict';
var ids = [],
child,
......@@ -57,7 +57,7 @@ window.osuny.contentEditor = {
},
// Mode organisation du plan
sortModeOrganize(to) {
sortModeOrganize: function (to) {
'use strict';
var ids = [],
child,
......
......@@ -6,28 +6,15 @@ class Admin::Communication::BlocksController < Admin::Communication::Application
def reorder
# Cette action est très étrange, elle ne met pas en ordre les blocs seuls.
# En fait, elle met en ordre dans le mode "Ecrire le contenu", à la fois les headings et les blocks.
ids = params[:ids] || []
index_block = 0
index_heading = 0
heading = nil
ids.values.each do |object|
id = object[:id]
if object[:kind] == 'heading'
heading = current_university.communication_block_headings.find(id)
heading.update_columns position: index_heading
index_block = 0
index_heading += 1
else
@block = current_university.communication_blocks.find(id)
@block.update_columns position: index_block,
heading_id: heading&.id
index_block += 1
end
end
if @block && @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
@ids = params[:ids] || []
@index_block = 0
@index_heading = 0
@heading = nil
@ids.values.each do |object|
@object = object
reorder_object
end
sync_after_reorder
end
def new
......@@ -79,6 +66,32 @@ class Admin::Communication::BlocksController < Admin::Communication::Application
protected
def reorder_object
@id = @object[:id]
@object[:kind] == 'heading' ? reorder_heading
: reorder_block
end
def reorder_heading
@heading = current_university.communication_block_headings.find(@id)
@heading.update_columns position: @index_heading
@index_block = 0
@index_heading += 1
end
def reorder_block
@block = current_university.communication_blocks.find(@id)
@block.update_columns position: @index_block,
heading_id: @heading&.id
@index_block += 1
end
def sync_after_reorder
return unless @block
return unless @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
def website_id
params[:website_id] || @block.about&.website.id
rescue
......
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