tested component fixed

This commit is contained in:
2026-04-19 17:38:35 +02:00
parent 66be442eb6
commit fa7997c980
4 changed files with 74 additions and 7 deletions
+48 -1
View File
@@ -395,7 +395,12 @@
case "tested_component":
div.style.overflow = "visible";
div.innerHTML = `<div style="display:flex; align-items:center; gap:4px; width:100%; height:100%;"><input type="text" class="cell-input manual-input" style="flex:1; min-width:0; height:28px;"><button type="button" class="add-part-btn btn btn-sm btn-primary" data-row="${rowIndex}" data-iddatadb="${row.iddatadb}" style="display:inline-flex; align-items:center; justify-content:center; min-width:28px; width:28px; height:28px; padding:0; font-size:12px; flex-shrink:0; text-align:center;"><i class="fas fa-plus" style="margin:0; padding:0;"></i></button></div>`;
div.innerHTML = `<div style="display:flex; align-items:center; gap:4px; width:100%; height:100%;">
<input type="text" class="cell-input manual-input tested-component-input" value="${esc(row.tested_component || "")}" style="flex:1; min-width:0; height:28px;">
<button type="button" class="add-part-btn btn btn-sm btn-primary" data-row="${rowIndex}" data-iddatadb="${row.iddatadb}" style="display:inline-flex; align-items:center; justify-content:center; min-width:28px; width:28px; height:28px; padding:0; font-size:12px; flex-shrink:0; text-align:center;">
<i class="fas fa-plus" style="margin:0; padding:0;"></i>
</button>
</div>`;
break;
case "awb":
@@ -890,6 +895,9 @@
rowIndex,
value,
);
} else if (colType === "tested_component") {
data[rowIndex].tested_component = value;
data[rowIndex]._dirty = true;
}
// Visual feedback
@@ -897,6 +905,44 @@
updateDirtyIndicator();
});
rowContainer.addEventListener("input", function (e) {
const cell = e.target.closest(".grid-cell");
if (!cell || !cell.dataset.row) return;
const rowIndex = parseInt(cell.dataset.row, 10);
const colType = cell.dataset.colType;
if (colType === "tested_component") {
data[rowIndex].tested_component = e.target.value;
data[rowIndex]._dirty = true;
cell.classList.add("cell-changed");
updateDirtyIndicator();
}
});
// Persist tested_component before clicking +
document.addEventListener("mousedown", function (e) {
const btn = e.target.closest(".add-part-btn");
if (!btn) return;
const rowIndex = parseInt(btn.dataset.row, 10);
if (isNaN(rowIndex) || !data[rowIndex]) return;
const rowEl = btn.closest(".grid-row");
if (!rowEl) return;
const testedInput = rowEl.querySelector(".tested-component-input");
if (!testedInput) return;
data[rowIndex].tested_component = testedInput.value || "";
data[rowIndex]._dirty = true;
const cell = testedInput.closest(".grid-cell");
if (cell) cell.classList.add("cell-changed");
updateDirtyIndicator();
});
// Propagate buttons
document.addEventListener("click", function (e) {
const btn = e.target.closest(".propagate-btn");
@@ -1045,6 +1091,7 @@
// Client
if (row.idclient) formData.append("idclient", row.idclient);
formData.append("cliente_fornitore_id", row.cliente_fornitore_id || "");
formData.append("tested_component", row.tested_component || "");
// Fixed fields → real column names
const aliasMap = meta.fixedAliasMap || {};