1import { Controller } from "@hotwired/stimulus" 2import Sortable from "sortablejs" 3 4// Connects to data-controller="admin--localized-outline-list" 5export default class extends Controller { 6 connect () { 7 Sortable.create( 8 this.element, 9 { 10 // removeOnSpill: true, 11 // onSpill: (evt) => { 12 // this.removeListItem(evt.item.dataset.listItemId); 13 // }, 14 onEnd: (evt) => { 15 const listItemId = evt.item.dataset.listItemId; 16 this.moveListItem(listItemId, evt.newIndex); 17 } 18 } 19 ); 20 } 21 22 moveListItem (itemId, position) { 23 const path = `/admin/localized_outline_list_items/${itemId}/move_list_item?position=${position}` 24 const csrfToken = document.head.querySelector("meta[name=csrf-token]")?.content 25 fetch(path, { 26 headers: { "X-CSRF-Token": csrfToken, "Content-Type": "application/json" }, 27 method: 'POST' 28 }) 29 .then(response => response.json()) // No error handling 30 } 31 32 // removeListItem (itemId) { 33 // const path = `/admin/localized_outline_list_items/${itemId}/remove_list_item` 34 // const csrfToken = document.head.querySelector("meta[name=csrf-token]")?.content 35 // fetch(path, { 36 // headers: { "X-CSRF-Token": csrfToken, "Content-Type": "application/json" }, 37 // method: 'POST' 38 // }) 39 // .then(response => response.json()) 40 // } 41}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.