diff --git a/public/userarea/gridRenderer.js b/public/userarea/gridRenderer.js
index 57ce0e0..59743a4 100644
--- a/public/userarea/gridRenderer.js
+++ b/public/userarea/gridRenderer.js
@@ -395,7 +395,12 @@
case "tested_component":
div.style.overflow = "visible";
- div.innerHTML = `
`;
+ div.innerHTML = `
+
+
+
`;
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 || {};
diff --git a/public/userarea/imported.php b/public/userarea/imported.php
index 0b9b6f8..dac2e22 100644
--- a/public/userarea/imported.php
+++ b/public/userarea/imported.php
@@ -202,13 +202,13 @@ foreach ($importedData as $index => $row) {
'status' => $row['status'] ?? 'i',
'idclient' => $row['idclient'] ?? $default_idclient,
'cliente_fornitore_id' => $row['cliente_fornitore_id'] ?? null,
+ 'tested_component' => $row['tested_component'] ?? '',
'commessaweb' => $row['commessaweb'] ?? null,
'user_name' => $row['user_name'] ?? '',
'importreferencecode' => $row['importreferencecode'] ?? '',
'filename_import' => $row['filename_import'] ?? '',
'importdate' => $row['importdate'] ?? '',
];
-
// Fixed fields
$rowObj['fixedFields'] = [];
foreach ($fixedFields as $f) {
@@ -267,7 +267,12 @@ $gridColumns[] = ['type' => 'cliente_fornitore_id', 'key' => 'cliente_fornitore_
// 5. Auto fields
foreach ($allMappings as $mapping) {
- if (!$mapping['is_manual'] && $mapping['main_field'] != 1 && $mapping['is_visible_import'] == 1) {
+ if (
+ !$mapping['is_manual']
+ && $mapping['main_field'] != 1
+ && $mapping['is_visible_import'] == 1
+ && trim((string)$mapping['field_label']) !== 'Tested Component:'
+ ) {
$gridColumns[] = [
'type' => 'detail',
'key' => (string)$mapping['id'],
@@ -284,7 +289,12 @@ foreach ($allMappings as $mapping) {
// 6. Manual fields
foreach ($allMappings as $mapping) {
- if ($mapping['is_manual'] && $mapping['main_field'] != 1 && $mapping['is_visible_import'] == 1) {
+ if (
+ $mapping['is_manual']
+ && $mapping['main_field'] != 1
+ && $mapping['is_visible_import'] == 1
+ && trim((string)$mapping['field_label']) !== 'Tested Component:'
+ ) {
$gridColumns[] = [
'type' => 'detail',
'key' => (string)$mapping['id'],
diff --git a/public/userarea/modals_gridData.js b/public/userarea/modals_gridData.js
index 387edde..36959e6 100644
--- a/public/userarea/modals_gridData.js
+++ b/public/userarea/modals_gridData.js
@@ -121,8 +121,14 @@
body: formData,
});
}
+
+ if (row) {
+ row.tested_component = raw;
+ row._dirty = true;
+ }
+
alert(`Added ${uniqueParts.length} part(s).`);
- $input.val("");
+ $input.val(raw);
} catch (e) {
alert("Error: " + e.message);
}
diff --git a/public/userarea/save_edited_row.php b/public/userarea/save_edited_row.php
index 1a8185d..abc7f05 100644
--- a/public/userarea/save_edited_row.php
+++ b/public/userarea/save_edited_row.php
@@ -13,7 +13,7 @@ try {
$iddatadb = intval($_POST['iddatadb']);
$idclient = isset($_POST['idclient']) ? (is_numeric($_POST['idclient']) ? intval($_POST['idclient']) : null) : null;
$clienteFornitoreId = isset($_POST['cliente_fornitore_id']) ? (is_numeric($_POST['cliente_fornitore_id']) ? intval($_POST['cliente_fornitore_id']) : null) : null;
-
+ $testedComponent = isset($_POST['tested_component']) ? trim((string)$_POST['tested_component']) : null;
$db = DBHandlerSelect::getInstance();
$pdo = $db->getConnection();
@@ -144,7 +144,11 @@ try {
$setParts[] = "cliente_fornitore_id = ?";
$params[] = $clienteFornitoreId;
}
-
+ // 5a3) tested_component (se presente)
+ if (isset($testedComponent)) {
+ $setParts[] = "tested_component = ?";
+ $params[] = ($testedComponent === '') ? null : $testedComponent;
+ }
// 5b) fixed fields dal POST
// QUI è il punto chiave: accettiamo SOLO colonne reali (realWhitelist),
// ma se dal JS arrivassero ancora key logiche, funzionerebbe uguale