Sha256: 3b1c5ea0850019e4703513552096a3aa209663568a64d9d27c2b4f2463de63cc

Contents?: true

Size: 1.24 KB

Versions: 25

Compression:

Stored size: 1.24 KB

Contents

import { on } from "alchemy_admin/utils/events"

/**
 * Multiple picture select handler for the picture archive.
 */
export default function PictureSelector() {
  const selectedItemTools = document.querySelector(".selected_item_tools")
  const checkedInputs = () =>
    document.querySelectorAll("#picture_archive input:checked")

  // make the item toolbar visible and show the checkbox also if it is not hovered anymore
  on("change", ".picture_tool.select", "input", (event) => {
    selectedItemTools.style.display =
      checkedInputs().length > 0 ? "block" : "none"

    const parentElementClassList = event.target.parentElement.classList
    const checked = event.target.checked

    parentElementClassList.toggle("visible", checked)
    parentElementClassList.toggle("hidden", !checked)
  })

  // open the edit view in a dialog modal
  on("click", ".selected_item_tools", "a#edit_multiple_pictures", (event) => {
    event.preventDefault()

    const searchParameters = new URLSearchParams()
    checkedInputs().forEach((entry) =>
      searchParameters.append(entry.name, entry.value)
    )
    const url = event.target.href + "?" + searchParameters.toString()

    Alchemy.openDialog(url, {
      title: event.target.title,
      size: "400x295"
    })
  })
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
alchemy_cms-7.2.8 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.13 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.2.7 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.2.6 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.2.5 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.12 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.2.4 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.11 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.2.3 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.10 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.2.2 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.9 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.2.1 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.8 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.7 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.6 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.5 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.4 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.3 app/javascript/alchemy_admin/picture_selector.js
alchemy_cms-7.1.2 app/javascript/alchemy_admin/picture_selector.js