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

climate

parent ac9ef3f9
No related branches found
No related tags found
No related merge requests found
......@@ -30,34 +30,43 @@ window.osuny.contentEditor = {
onSortableEnd: function (event) {
'use strict';
var url,
to = event.to,
ids = [],
headingId = null,
child,
i;
if (event.from.classList.contains('content-editor--write')) {
// Mode écriture du contenu
url = this.sortBlocksUrl;
for (i = 0; i < to.children.length; i += 1) {
child = to.children[i];
// Nous utilisons une route déjà existante, dédiée aux blocs,
// pour gérer à la fois des blocs et des headings.
// Ca manque d'élégance.
ids.push({
id: child.dataset.id,
kind: child.dataset.kind
});
}
$.post(this.sortBlocksUrl, { ids: ids });
this.sortModeWrite(event.to);
} else if (event.from.classList.contains('content-editor--organize')) {
// Mode organisation du plan
for (i = 0; i < to.children.length; i += 1) {
child = to.children[i];
ids.push(child.dataset.id);
}
$.post(this.sortHeadingsUrl, { ids: ids });
this.sortModeOrganize(event.to);
}
},
// Mode écriture du contenu
sortModeWrite(to) {
'use strict';
var ids = [],
child,
i;
for (i = 0; i < to.children.length; i += 1) {
child = to.children[i];
// Nous utilisons une route déjà existante, dédiée aux blocs,
// pour gérer à la fois des blocs et des headings.
// Ca manque d'élégance.
ids.push({
id: child.dataset.id,
kind: child.dataset.kind
});
}
$.post(this.sortBlocksUrl, { ids: ids });
},
// Mode organisation du plan
sortModeOrganize(to) {
'use strict';
var ids = [],
child,
i;
for (i = 0; i < to.children.length; i += 1) {
child = to.children[i];
ids.push(child.dataset.id);
}
$.post(this.sortHeadingsUrl, { ids: ids });
},
invoke: function () {
......
......@@ -9,6 +9,8 @@ class Admin::Communication::Blocks::HeadingsController < Admin::Communication::B
ids.each.with_index do |id, index|
@heading = current_university.communication_block_headings.find(id)
@heading.update_columns parent_id: parent_id,
parent_id: nil,
level: Communication::Block::Heading::DEFAULT_LEVEL,
position: index + 1
end
if @heading.about&.respond_to?(:is_direct_object?)
......
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