added resort manually
This commit is contained in:
parent
a482d975da
commit
e75be99e43
@ -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
|
||||
|
||||
@ -255,4 +255,20 @@
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
#partsListAnnotations .list-group-item.dragging {
|
||||
opacity: 0.6;
|
||||
background-color: #d1e7dd !important;
|
||||
transform: rotate(3deg);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
#partsListAnnotations .placeholder {
|
||||
background-color: #f8d7da !important;
|
||||
border: 2px dashed #dc3545;
|
||||
height: 40px;
|
||||
margin: 2px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
|
||||
Loading…
x
Reference in New Issue
Block a user