Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: Add alchemy-action #2883

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/javascript/alchemy_admin/components/action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { reloadPreview } from "alchemy_admin/components/preview_window"

class Action extends HTMLElement {
constructor() {
super()
this.actions = {
reloadPreview
}
}

connectedCallback() {
const func = this.actions[this.name]

if (func) {
func.call()
} else {
console.error(`Unknown Alchemy action: ${this.name}`)
}
}

get name() {
return this.getAttribute("name")
}
}

customElements.define("alchemy-action", Action)
1 change: 1 addition & 0 deletions app/javascript/alchemy_admin/components/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "alchemy_admin/components/action"
import "alchemy_admin/components/attachment_select"
import "alchemy_admin/components/button"
import "alchemy_admin/components/char_counter"
Expand Down