fixed sticky bars with toggle
This commit is contained in:
@@ -895,6 +895,76 @@
|
||||
updateDirtyIndicator();
|
||||
}
|
||||
|
||||
// Aggiorna in-place SOLO le celle di una colonna in tutte le righe visibili,
|
||||
// senza distruggere/ricostruire l'intera griglia (evita il freeze in propagazione).
|
||||
function updateColumnCells(colKey, colType) {
|
||||
if (!rowContainer) return;
|
||||
const cells = rowContainer.querySelectorAll(
|
||||
`.grid-cell[data-col="${CSS.escape(String(colKey))}"][data-col-type="${colType}"]`,
|
||||
);
|
||||
cells.forEach((cell) => {
|
||||
const rowIndex = parseInt(cell.dataset.row, 10);
|
||||
if (Number.isNaN(rowIndex) || !data[rowIndex]) return;
|
||||
|
||||
// Ricava il valore corrente dal modello dati
|
||||
let value = "";
|
||||
if (colType === "detail" || colType === "main_field") {
|
||||
value = data[rowIndex].details?.[String(colKey)] ?? "";
|
||||
} else if (colType === "fixed") {
|
||||
value = data[rowIndex].fixedFields?.[colKey] ?? "";
|
||||
} else if (colType === "cliente_fornitore_id") {
|
||||
value = data[rowIndex].cliente_fornitore_id ?? "";
|
||||
}
|
||||
|
||||
const input = cell.querySelector(".cell-input");
|
||||
if (!input) return;
|
||||
|
||||
if ($(input).hasClass("select2-hidden-accessible")) {
|
||||
// Assicura che l'opzione selezionata esista, poi imposta il valore
|
||||
if (
|
||||
value &&
|
||||
!input.querySelector(
|
||||
`option[value="${CSS.escape(String(value))}"]`,
|
||||
)
|
||||
) {
|
||||
const label =
|
||||
clientNameCache[value] ||
|
||||
(input.dataset?.fieldId
|
||||
? dropdownNameCache[
|
||||
input.dataset.fieldId + "_" + value
|
||||
]
|
||||
: null) ||
|
||||
value;
|
||||
input.add(new Option(label, value, true, true));
|
||||
}
|
||||
$(input)
|
||||
.val(value ? String(value) : "")
|
||||
.trigger("change.select2");
|
||||
} else if (input.tagName === "SELECT") {
|
||||
// Select nativo: aggiungi opzione se manca
|
||||
if (
|
||||
value &&
|
||||
!input.querySelector(
|
||||
`option[value="${CSS.escape(String(value))}"]`,
|
||||
)
|
||||
) {
|
||||
const label =
|
||||
(input.dataset?.fieldId
|
||||
? dropdownNameCache[
|
||||
input.dataset.fieldId + "_" + value
|
||||
]
|
||||
: null) || value;
|
||||
input.add(new Option(label, value, true, true));
|
||||
}
|
||||
input.value = value;
|
||||
} else {
|
||||
input.value = value;
|
||||
}
|
||||
|
||||
cell.classList.add("cell-changed");
|
||||
});
|
||||
}
|
||||
|
||||
function renderSingleRow(rowIndex) {
|
||||
const existing = rowContainer.querySelector(
|
||||
`.grid-row[data-id="${data[rowIndex].iddatadb}"]`,
|
||||
@@ -1546,7 +1616,10 @@
|
||||
row._dirty = true;
|
||||
});
|
||||
|
||||
renderVisibleRows();
|
||||
updateColumnCells(
|
||||
"cliente_fornitore_id",
|
||||
"cliente_fornitore_id",
|
||||
);
|
||||
updateDirtyIndicator();
|
||||
return;
|
||||
}
|
||||
@@ -1565,7 +1638,7 @@
|
||||
row._dirty = true;
|
||||
});
|
||||
|
||||
renderVisibleRows();
|
||||
updateColumnCells(fixedKey, "fixed");
|
||||
updateDirtyIndicator();
|
||||
return;
|
||||
}
|
||||
@@ -1595,7 +1668,15 @@
|
||||
row._dirty = true;
|
||||
});
|
||||
|
||||
renderVisibleRows();
|
||||
updateColumnCells(col.key, col.type);
|
||||
// Se esiste una colonna auto-copiata (es. Arrival→Unlock), aggiorna anche quella
|
||||
if (autoPair) {
|
||||
const pairCol = columns.find(
|
||||
(c) => String(c.key) === String(autoPair.toKey),
|
||||
);
|
||||
if (pairCol) updateColumnCells(pairCol.key, pairCol.type);
|
||||
}
|
||||
|
||||
updateDirtyIndicator();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user