Sha256: 28a2414498509918d1400e84fe048956fb0357b0a2c20cea0aa28d0ffc8f68d7

Contents?: true

Size: 968 Bytes

Versions: 17

Compression:

Stored size: 968 Bytes

Contents

import { patch } from "alchemy_admin/utils/ajax"

export class PublishElementButton extends HTMLElement {
  constructor() {
    super()

    this.addEventListener("sl-change", this)
  }

  handleEvent(event) {
    const elementEditor = event.target.closest("alchemy-element-editor")
    if (elementEditor === this.elementEditor) {
      patch(Alchemy.routes.publish_admin_element_path(this.elementId))
        .then((response) => {
          this.elementEditor.published = response.data.public
          this.tooltip.setAttribute("content", response.data.label)
          Alchemy.reloadPreview()
        })
        .catch((error) => Alchemy.growl(error.message, "error"))
    }
  }

  get elementEditor() {
    return this.closest("alchemy-element-editor")
  }

  get tooltip() {
    return this.closest("sl-tooltip")
  }

  get elementId() {
    return this.elementEditor.elementId
  }
}

customElements.define("alchemy-publish-element-button", PublishElementButton)

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
alchemy_cms-7.1.13 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.12 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.11 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.10 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.9 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.8 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.7 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.6 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.5 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.4 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.3 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.2 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.1 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.0 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.0.pre.rc1 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.0.pre.b2 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js
alchemy_cms-7.1.0.pre.b1 app/javascript/alchemy_admin/components/element_editor/publish_element_button.js