From b44ffef49e8b2e38065703d7fd32ce15ef0e4da7 Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Wed, 11 Sep 2024 09:47:49 +0200 Subject: [PATCH] Select and move sections as one block --- CHANGELOG.rst | 4 ++++ .../static/content_editor/content_editor.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a46652b5..107507b7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,6 +12,10 @@ Next version - Fixed a bug where a plugin with multiple fieldsets wouldn't collapse completely. - Added Django 5.1 to the CI. +- Introduced sections. Content editor inlines can now define a ``sections`` + attribute; recommended values include 0 (the default), 1 (open one section) + and -1 (close one section). Those sections are collapsed and moved as one + unit during editing. 7.0 (2024-05-31) diff --git a/content_editor/static/content_editor/content_editor.js b/content_editor/static/content_editor/content_editor.js index ab58b86e..db2a4f9e 100644 --- a/content_editor/static/content_editor/content_editor.js +++ b/content_editor/static/content_editor/content_editor.js @@ -243,6 +243,10 @@ inline.addEventListener("drop", (e) => { if (window.__fs_dragging) { e.preventDefault() + for (let inline of qsa(".order-machine .inline-related.selected")) { + selectSection(inline) + } + const inline = e.target.closest(".inline-related") const toMove = qsa(".order-machine .inline-related.selected").map( (inline) => [inline, +inline.style.order], @@ -733,6 +737,16 @@ } } + function selectSection(inline) { + const children = childrenMap && childrenMap.get(inline) + if (children) { + for (let child of children) { + child.classList.add("selected") + selectSection(child) + } + } + } + // Initialize tabs and currentRegion. ;(() => { const tabContainer = $(".tabs.regions")