O:41:"Symfony\Component\AssetMapper\MappedAsset":12:{s:10:"sourcePath";s:77:"/home/montelg/grocerylist/assets/controllers/sortablecategories_controller.js";s:10:"publicPath";s:85:"/assets/controllers/sortablecategories_controller-f1104cd5379ef88d0dfb6d41f8a09c9d.js";s:23:"publicPathWithoutDigest";s:52:"/assets/controllers/sortablecategories_controller.js";s:15:"publicExtension";s:2:"js";s:7:"content";s:1933:"import { Controller } from '@hotwired/stimulus'; import '../Sortable.min.js'; /* * This is an example Stimulus controller! * * Any element with a data-controller="sortablecategories" attribute will cause * this controller to be executed. The name "sortablecategories" comes from the filename: * sortablecategories_controller.js -> "sortablecategories" * * Delete this file or adapt it for your use! */ export default class extends Controller { connect() { const self = this; const listhandler = document.getElementById("listhandler"); const trList = listhandler.getElementsByTagName("tr"); if(listhandler && trList.length > 0) { let sortable = new Sortable(listhandler, { handle: '.handle', animation: 150, onEnd: function (evt) { let idsPosition = []; [...trList].map(tr => { const id = tr.getAttribute('data-id'); idsPosition.push(id); return tr; }); self.execUpdate(idsPosition); }, }); } } execUpdate(ids) { fetch('/admin/ajax/categories-position/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' }, body: JSON.stringify({ ids: ids }) }) .then(response => { if (!response.status === 200) { throw new Error(`HTTP error! status: ${response.status}`); } //return response.json(); }) /*.then(data => { if (data.results && data.results.length > 0) this.buildList(data.results); else this.clearList(); })*/ .catch(error => console.error('Error:', error)); } }";s:6:"digest";s:32:"f1104cd5379ef88d0dfb6d41f8a09c9d";s:13:"isPredigested";b:0;s:8:"isVendor";b:0;s:55:"Symfony\Component\AssetMapper\MappedAssetdependencies";a:0:{}s:59:"Symfony\Component\AssetMapper\MappedAssetfileDependencies";a:0:{}s:60:"Symfony\Component\AssetMapper\MappedAssetjavaScriptImports";a:2:{i:0;O:56:"Symfony\Component\AssetMapper\ImportMap\JavaScriptImport":5:{s:10:"importName";s:18:"@hotwired/stimulus";s:16:"assetLogicalPath";s:43:"vendor/@hotwired/stimulus/stimulus.index.js";s:15:"assetSourcePath";s:76:"/home/montelg/grocerylist/assets/vendor/@hotwired/stimulus/stimulus.index.js";s:6:"isLazy";b:0;s:24:"addImplicitlyToImportMap";b:0;}i:1;O:56:"Symfony\Component\AssetMapper\ImportMap\JavaScriptImport":5:{s:10:"importName";s:23:"/assets/Sortable.min.js";s:16:"assetLogicalPath";s:15:"Sortable.min.js";s:15:"assetSourcePath";s:48:"/home/montelg/grocerylist/assets/Sortable.min.js";s:6:"isLazy";b:0;s:24:"addImplicitlyToImportMap";b:1;}}s:11:"logicalPath";s:44:"controllers/sortablecategories_controller.js";}