added resort manually
This commit is contained in:
@@ -798,6 +798,48 @@ $(document).ready(function () {
|
||||
});
|
||||
}
|
||||
|
||||
function enableDragDropPartsList() {
|
||||
const list = $("#partsListAnnotations");
|
||||
if (!list.length || typeof $.ui === "undefined" || !$.ui.sortable) {
|
||||
console.warn("jQuery UI o .sortable non disponibile. Ritento...");
|
||||
setTimeout(enableDragDropPartsList, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
if (list.hasClass("ui-sortable")) {
|
||||
list.sortable("destroy"); // evita duplicati
|
||||
}
|
||||
|
||||
list.sortable({
|
||||
items: "li.list-group-item",
|
||||
placeholder: "list-group-item placeholder",
|
||||
axis: "y",
|
||||
containment: "parent",
|
||||
tolerance: "pointer",
|
||||
start: function (e, ui) {
|
||||
ui.item.addClass("dragging");
|
||||
},
|
||||
stop: function (e, ui) {
|
||||
ui.item.removeClass("dragging");
|
||||
const newOrder = [];
|
||||
list.find("li").each(function () {
|
||||
const partNumber = $(this).data("part-number");
|
||||
const part = partsListData.find(
|
||||
(p) => p.part_number == partNumber,
|
||||
);
|
||||
if (part) newOrder.push(part);
|
||||
});
|
||||
partsListData = newOrder;
|
||||
console.log(
|
||||
"Ordine parti aggiornato:",
|
||||
partsListData.map((p) => p.part_number),
|
||||
);
|
||||
markUnsaved();
|
||||
updateMarkers();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Delegazione evento per il checkbox
|
||||
$(document)
|
||||
.off("change.showMix", "#showMixPartsAnnotations")
|
||||
@@ -830,6 +872,7 @@ $(document).ready(function () {
|
||||
}
|
||||
updatePartsList();
|
||||
updateMarkers();
|
||||
setTimeout(enableDragDropPartsList, 50);
|
||||
if (
|
||||
photoAnnotations[$("#samplePhotoAnnotations").attr("src")]
|
||||
?.hasDescriptions
|
||||
|
||||
Reference in New Issue
Block a user