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