fixed renumerate parts
This commit is contained in:
@@ -488,8 +488,13 @@ $(document).ready(function () {
|
||||
mix: part.partDescription.startsWith("Mix") ? "Y" : "N",
|
||||
}));
|
||||
|
||||
console.log(
|
||||
"Dati inviati a renumber_parts.php:",
|
||||
JSON.stringify({ iddatadb: iddatadb, parts: partsToSave }),
|
||||
);
|
||||
|
||||
$.ajax({
|
||||
url: "save_parts.php",
|
||||
url: "renumber_parts.php",
|
||||
method: "POST",
|
||||
data: JSON.stringify({
|
||||
iddatadb: iddatadb,
|
||||
@@ -497,12 +502,17 @@ $(document).ready(function () {
|
||||
}),
|
||||
contentType: "application/json",
|
||||
success: function (response) {
|
||||
console.log("Risposta da renumber_parts.php:", response);
|
||||
if (response.success) {
|
||||
$rows.each(function (index) {
|
||||
const $row = $(this);
|
||||
if (response.part_ids && response.part_ids[index]) {
|
||||
$row.attr("data-part-id", response.part_ids[index]);
|
||||
$row.data("part-id", response.part_ids[index]);
|
||||
const newPartId =
|
||||
response.part_ids && response.part_ids[index]
|
||||
? response.part_ids[index]
|
||||
: $row.data("part-id");
|
||||
if (newPartId) {
|
||||
$row.attr("data-part-id", newPartId);
|
||||
$row.data("part-id", newPartId);
|
||||
}
|
||||
const $saveStatus = $row.find(".save-status");
|
||||
const $saveLoading = $row.find(".save-loading");
|
||||
@@ -515,14 +525,21 @@ $(document).ready(function () {
|
||||
updateDescriptions();
|
||||
markUnsaved();
|
||||
} else {
|
||||
console.error("Errore dal server:", response.message);
|
||||
alert(
|
||||
"Errore nel salvataggio delle parti: " +
|
||||
"Errore nella rinumerazione delle parti: " +
|
||||
response.message,
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
alert("Errore nel salvataggio delle parti: " + error);
|
||||
console.error("Errore AJAX:", status, error, xhr.responseText);
|
||||
alert(
|
||||
"Errore nella rinumerazione delle parti: " +
|
||||
error +
|
||||
" - " +
|
||||
xhr.responseText,
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user