fixed mescole matrici
This commit is contained in:
parent
f043b43791
commit
bc806f37f4
@ -1117,28 +1117,48 @@
|
|||||||
$("#mm_matrice_name").text(nome);
|
$("#mm_matrice_name").text(nome);
|
||||||
|
|
||||||
const $sel = $("#mm_mescole");
|
const $sel = $("#mm_mescole");
|
||||||
$sel.empty().trigger("change");
|
$sel.empty();
|
||||||
|
|
||||||
|
// Placeholder temporaneo mentre carica
|
||||||
|
const loadingOption = new Option("Caricamento mescole...", "", false, false);
|
||||||
|
$sel.append(loadingOption).trigger("change");
|
||||||
|
|
||||||
|
const modalEl = document.getElementById('matriceMescoleModal');
|
||||||
|
const modal = new bootstrap.Modal(modalEl);
|
||||||
|
modal.show();
|
||||||
|
|
||||||
fetch("get_matrice_mescole.php?id=" + encodeURIComponent(idmatrice))
|
fetch("get_matrice_mescole.php?id=" + encodeURIComponent(idmatrice))
|
||||||
.then(r => r.json())
|
.then(r => {
|
||||||
|
if (!r.ok) {
|
||||||
|
throw new Error("HTTP " + r.status);
|
||||||
|
}
|
||||||
|
return r.json();
|
||||||
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
Swal.fire({
|
throw new Error(data.message || "Impossibile caricare le mescole");
|
||||||
icon: "error",
|
|
||||||
title: "Errore",
|
|
||||||
text: data.message || "Impossibile caricare le mescole"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data.mescole.forEach(m => {
|
$sel.empty();
|
||||||
|
|
||||||
|
(data.mescole || []).forEach(m => {
|
||||||
const label = m.nomeuscita ? `${m.nome} (${m.nomeuscita})` : m.nome;
|
const label = m.nomeuscita ? `${m.nome} (${m.nomeuscita})` : m.nome;
|
||||||
const opt = new Option(label, m.id, false, false);
|
const opt = new Option(label, m.id, false, false);
|
||||||
$sel.append(opt);
|
$sel.append(opt);
|
||||||
});
|
});
|
||||||
|
|
||||||
$sel.val((data.selected_ids || []).map(String)).trigger("change");
|
$sel.val((data.selected_ids || []).map(String)).trigger("change");
|
||||||
new bootstrap.Modal(document.getElementById('matriceMescoleModal')).show();
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error("Errore caricamento mescole:", err);
|
||||||
|
|
||||||
|
$sel.empty().trigger("change");
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
icon: "error",
|
||||||
|
title: "Errore",
|
||||||
|
text: err.message || "Errore durante il caricamento delle mescole"
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user