Skip to content

Commit

Permalink
Select and move sections as one block
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 11, 2024
1 parent 1d10777 commit b44ffef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions content_editor/static/content_editor/content_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit b44ffef

Please sign in to comment.