Skip to content

Commit

Permalink
Merge pull request #2815 from AlchemyCMS/local-sortable-elements
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen authored Apr 4, 2024
2 parents ae37c6e + 1e5766c commit fc97f93
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
2 changes: 0 additions & 2 deletions app/javascript/alchemy_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { LinkDialog } from "alchemy_admin/link_dialog"
import pictureSelector from "alchemy_admin/picture_selector"
import pleaseWaitOverlay from "alchemy_admin/please_wait_overlay"
import Sitemap from "alchemy_admin/sitemap"
import SortableElements from "alchemy_admin/sortable_elements"
import Spinner from "alchemy_admin/spinner"
import PagePublicationFields from "alchemy_admin/page_publication_fields"
import { reloadPreview } from "alchemy_admin/components/preview_window"
Expand Down Expand Up @@ -64,7 +63,6 @@ Object.assign(Alchemy, {
pictureSelector,
pleaseWaitOverlay,
Sitemap,
SortableElements,
Spinner,
PagePublicationFields,
reloadPreview
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/alchemy_admin/components/element_editor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ImageLoader from "alchemy_admin/image_loader"
import fileEditors from "alchemy_admin/file_editors"
import pictureEditors from "alchemy_admin/picture_editors"
import SortableElements from "alchemy_admin/sortable_elements"
import IngredientAnchorLink from "alchemy_admin/ingredient_anchor_link"
import { post } from "alchemy_admin/utils/ajax"
import { createHtmlElement } from "alchemy_admin/utils/dom_helpers"
Expand Down Expand Up @@ -44,6 +45,7 @@ export class ElementEditor extends HTMLElement {
`#${this.id} .ingredient-editor.file, #${this.id} .ingredient-editor.audio, #${this.id} .ingredient-editor.video`
)
pictureEditors(`#${this.id} .ingredient-editor.picture`)
SortableElements(`#${this.id} .nested-elements`)
}

handleEvent(event) {
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/alchemy_admin/components/elements_window.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SortableElements from "alchemy_admin/sortable_elements"

class ElementsWindow extends HTMLElement {
#visible = true

Expand All @@ -16,7 +18,7 @@ class ElementsWindow extends HTMLElement {
.querySelector(window.location.hash)
?.trigger("FocusElementEditor.Alchemy")
}
Alchemy.SortableElements()
SortableElements()
}

collapseAllElements() {
Expand Down
4 changes: 0 additions & 4 deletions app/javascript/alchemy_admin/sortable_elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,4 @@ export default function SortableElements(selector) {
})

sortable_areas.forEach((element) => createSortable(element))

document.querySelectorAll(".nested-elements").forEach((nestedElement) => {
createSortable(nestedElement)
})
}
2 changes: 0 additions & 2 deletions app/views/alchemy/admin/elements/create.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
$element_area.append(element_html);
<%- end -%>

Alchemy.SortableElements('[data-element-id="<%= @element.id %>"] .nested-elements');

Alchemy.growl('<%= Alchemy.t(:successfully_added_element) %>');
Alchemy.closeCurrentDialog();

Expand Down

0 comments on commit fc97f93

Please sign in to comment.