Sha256: b31f3ce8f30f99731e0b427245b432a234f309cbe25391c48d28af7354d5c1a5
Contents?: true
Size: 718 Bytes
Versions: 31
Compression:
Stored size: 718 Bytes
Contents
import { Controller } from "@hotwired/stimulus" import { put } from "https://esm.sh/@rails/request.js@0.0.11?standalone" import Sortable from "https://esm.sh/sortablejs@1.15.6?standalone" export default class extends Controller { static values = { url: String, group: String, handle: String } connect() { this.sortable = new Sortable(this.element, this.#options) } disconnect() { this.sortable.destroy() } #submit({ item, newIndex, to }) { put(item.dataset.urlValue, { query: { position: newIndex, parent_id: to.dataset.parentId } }) } get #options() { return { animation: 150, onAdd: this.#submit, onUpdate: this.#submit, group: this.groupValue, handle: this.handleValue } } }
Version data entries
31 entries across 31 versions & 1 rubygems