Sha256: 6495cf24ae538385e82329670aba7d351552c42d82f947d98572769291a568d0
Contents?: true
Size: 1.07 KB
Versions: 214
Compression:
Stored size: 1.07 KB
Contents
import { Controller } from '@hotwired/stimulus' export default class extends Controller { static targets = ['resourceAction', 'standaloneAction'] static classes = ['enabled', 'disabled'] target = {} get targetIsDisabled() { return this.target.dataset.disabled === 'true' } get actionsShowTurboFrame() { return document.querySelector('turbo-frame#actions_show') } enableTarget() { if (this.targetIsDisabled) { this.target.classList.remove(...this.disabledClasses) this.target.classList.add(...this.enabledClasses) this.target.dataset.disabled = false } } disableTarget() { this.target.classList.remove(...this.enabledClasses) this.target.classList.add(...this.disabledClasses) this.target.dataset.disabled = true } visitAction(event) { this.target = event.target if (this.targetIsDisabled) { event.preventDefault() return } this.disableTarget() const that = this setTimeout(() => { this.actionsShowTurboFrame.loaded.then(() => that.enableTarget(that.target)) }, 1) } }
Version data entries
214 entries across 214 versions & 1 rubygems