Skip to content
Snippets Groups Projects
Unverified Commit 045a8b4b authored by Sébastien Gaya's avatar Sébastien Gaya Committed by GitHub
Browse files

Merge pull request #1099 from noesya/heading-children-dependent

Ajustements headings et blocs
parents c1a563a0 fedb1feb
No related branches found
No related tags found
No related merge requests found
......@@ -68,11 +68,12 @@ window.osuny.contentEditor = {
onSortableMove: function (event) {
'use strict';
var draggedKind = event.dragged.dataset.kind,
relatedKind = event.related.dataset.kind;
relatedKind = event.related.dataset.kind,
firstHeading = this.sortableRootContainer.querySelector('.js-content-editor-element[data-kind="heading"]');
if (draggedKind === 'block') {
// Prevent dragging a block after a heading, instead of inside
return relatedKind !== 'heading' || !event.willInsertAfter;
return relatedKind !== 'heading' || !event.willInsertAfter && event.related === firstHeading;
}
return true;
},
......
......@@ -39,7 +39,8 @@ class Communication::Block::Heading < ApplicationRecord
optional: true
has_many :children,
class_name: 'Communication::Block::Heading',
foreign_key: :parent_id
foreign_key: :parent_id,
dependent: :nullify
has_many :blocks,
dependent: :nullify
......
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