Sha256: bbae77b440ce88756cfe533c31ba571db46abd773b0f3660dc859069d588c12d
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
import {Controller} from "stimulus" import {Headmin} from "../headmin"; export default class extends Controller { static get targets() { return ["form", "list", "input", "template", "button"] } add(event) { event.preventDefault() const name = event.target.dataset.filterName const button = this.getButtonByName(name) if (button) { this.openFilter(button) } else { const template = this.getTemplateByName(name) this.listTarget.insertAdjacentHTML('beforeend', template.innerHTML) const button = this.getButtonByName(name) Headmin.initPlugins() } } remove(event) { const filter = event.currentTarget.closest('.h-filter') filter.remove() this.formTarget.submit() } removeAll(event) { this.listTarget.innerHTML = "" this.formTarget.submit() } update(event) { this.formTarget.submit() } getTemplateByName(name) { return this.templateTargets.find(function (element) { return element.dataset.filterName === name }) } getButtonByName(name) { return this.buttonTargets.find(function (element) { return element.dataset.filterName === name }) } openFilter(button) { button.controller.open() } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
headmin-0.1.2 | src/js/headmin/controllers/filters_controller.js |
headmin-0.1.1 | src/js/headmin/controllers/filters_controller.js |