fix SceltaMultipla mapping
This commit is contained in:
@@ -460,9 +460,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
$autoValue = $mapping['auto_value'] ?? 'none';
|
||||
$hasAuto = ($autoValue && $autoValue !== 'none');
|
||||
|
||||
if ($isSceltaMultipla) {
|
||||
$mappingValue = 'manual';
|
||||
} elseif ($hasAuto) {
|
||||
if ($hasAuto && !$isSceltaMultipla) {
|
||||
$mappingValue = 'auto';
|
||||
} elseif ($sourceType === 'XLS' && !empty($mapping['excel_column'])) {
|
||||
$mappingValue = 'xls';
|
||||
@@ -471,24 +469,26 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
} elseif ((int)$mapping['is_manual'] === 1) {
|
||||
$mappingValue = 'manual';
|
||||
} else {
|
||||
$mappingValue = '';
|
||||
// SceltaMultipla senza colonna: valore di default dal dropdown
|
||||
$mappingValue = $isSceltaMultipla ? 'manual' : '';
|
||||
}
|
||||
?>
|
||||
|
||||
<select class="form-select mapping-select"
|
||||
data-id="<?php echo (int)$mapping['id']; ?>"
|
||||
data-field-id="<?php echo (int)$mapping['field_id']; ?>"
|
||||
<?php echo $isSceltaMultipla ? 'disabled' : ''; ?>>
|
||||
data-field-id="<?php echo (int)$mapping['field_id']; ?>">
|
||||
|
||||
<?php if (!$isSceltaMultipla): ?>
|
||||
<option value="">Select Option</option>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($sourceType === 'XLS'): ?>
|
||||
<option value="xls" <?php echo ($mappingValue === 'xls') ? 'selected' : ''; ?>>Map to XLS Column</option>
|
||||
<?php elseif ($sourceType === 'API'): ?>
|
||||
<option value="json" <?php echo ($mappingValue === 'json') ? 'selected' : ''; ?>>Map to JSON Node</option>
|
||||
<?php endif; ?>
|
||||
<?php if ($sourceType === 'XLS'): ?>
|
||||
<option value="xls" <?php echo ($mappingValue === 'xls') ? 'selected' : ''; ?>>Map to XLS Column</option>
|
||||
<?php elseif ($sourceType === 'API'): ?>
|
||||
<option value="json" <?php echo ($mappingValue === 'json') ? 'selected' : ''; ?>>Map to JSON Node</option>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$isSceltaMultipla): ?>
|
||||
<option value="auto" <?php echo ($mappingValue === 'auto') ? 'selected' : ''; ?>>Auto value</option>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -544,6 +544,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
|
||||
<td>
|
||||
<?php if ($mapping['data_type'] === 'SceltaMultipla'): ?>
|
||||
<div class="scelta-default-wrap" style="display:<?php echo ($mappingValue === 'xls' || $mappingValue === 'json') ? 'none' : 'block'; ?>;">
|
||||
<select class="form-select dropdown-select manual-default"
|
||||
data-id="<?php echo (int)$mapping['id']; ?>"
|
||||
data-field-id="<?php echo (int)$mapping['field_id']; ?>"
|
||||
@@ -551,6 +552,10 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
style="display:block;">
|
||||
<option value="">Seleziona...</option>
|
||||
</select>
|
||||
</div>
|
||||
<small class="text-muted scelta-binding-hint" style="display:<?php echo ($mappingValue === 'xls' || $mappingValue === 'json') ? 'block' : 'none'; ?>;">
|
||||
Values from the file are linked to the LIMS list via Value Bindings
|
||||
</small>
|
||||
<?php else: ?>
|
||||
<input type="text"
|
||||
class="form-control manual-default"
|
||||
@@ -1751,6 +1756,17 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
// SceltaMultipla: il default è un dropdown (Select2) nel wrapper; con colonna/nodo
|
||||
// mappato si nasconde (il valore arriva dal file e passa dal binding).
|
||||
const sceltaWrap = tr.querySelector('.scelta-default-wrap');
|
||||
const sceltaHint = tr.querySelector('.scelta-binding-hint');
|
||||
if (sceltaWrap) {
|
||||
const fromFile = mappingSelect.value === 'xls' || mappingSelect.value === 'json';
|
||||
sceltaWrap.style.display = fromFile ? 'none' : 'block';
|
||||
if (sceltaHint) sceltaHint.style.display = fromFile ? 'block' : 'none';
|
||||
}
|
||||
const isScelta = !!sceltaWrap;
|
||||
|
||||
if (mappingSelect.value === 'xls') {
|
||||
if (xlsSelect) xlsSelect.style.display = 'block';
|
||||
|
||||
@@ -1762,7 +1778,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
|
||||
if (autoSelect) autoSelect.style.display = 'none';
|
||||
|
||||
if (manualInput) {
|
||||
if (manualInput && !isScelta) {
|
||||
manualInput.style.display = 'none';
|
||||
manualInput.value = '';
|
||||
}
|
||||
@@ -1785,7 +1801,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
|
||||
if (autoSelect) autoSelect.style.display = 'none';
|
||||
|
||||
if (manualInput) {
|
||||
if (manualInput && !isScelta) {
|
||||
manualInput.style.display = 'none';
|
||||
manualInput.value = '';
|
||||
}
|
||||
@@ -1831,7 +1847,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
jsonSelect.value = '';
|
||||
}
|
||||
|
||||
if (manualInput) {
|
||||
if (manualInput && !isScelta) {
|
||||
manualInput.style.display = 'none';
|
||||
manualInput.value = '';
|
||||
}
|
||||
@@ -1855,7 +1871,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
|
||||
if (autoSelect) autoSelect.style.display = 'none';
|
||||
|
||||
if (manualInput) {
|
||||
if (manualInput && !isScelta) {
|
||||
manualInput.style.display = 'none';
|
||||
manualInput.value = '';
|
||||
}
|
||||
@@ -2064,7 +2080,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
mappingSelect.value = '';
|
||||
if (mappedColumn) mappedColumn.style.display = 'none';
|
||||
e.target.style.display = 'none';
|
||||
saveMapping(mappingId, '', '', null, null, null);
|
||||
if (!resetSceltaToManual(tr, mappingId)) saveMapping(mappingId, '', '', null, null, null);
|
||||
updateXlsDropdowns();
|
||||
});
|
||||
}
|
||||
@@ -2144,7 +2160,7 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
console.log("Removing XLS mapping:", {
|
||||
id: mappingId
|
||||
});
|
||||
saveMapping(mappingId, '', '', null, null, null);
|
||||
if (!resetSceltaToManual(tr, mappingId)) saveMapping(mappingId, '', '', null, null, null);
|
||||
updateXlsDropdowns();
|
||||
}
|
||||
});
|
||||
@@ -2174,11 +2190,26 @@ $apiSampleJson = $template['api_sample_json'] ?? '';
|
||||
|
||||
event.target.style.display = 'none';
|
||||
|
||||
saveMapping(mappingId, '', '', null, null, null);
|
||||
if (!resetSceltaToManual(tr, mappingId)) saveMapping(mappingId, '', '', null, null, null);
|
||||
updateJsonDropdowns();
|
||||
}
|
||||
});
|
||||
|
||||
// Rimozione colonna/nodo: un campo SceltaMultipla torna a "Manual Entry" col suo dropdown default
|
||||
// (non ha l'opzione vuota). Ritorna true se gestito.
|
||||
function resetSceltaToManual(tr, mappingId) {
|
||||
const wrap = tr.querySelector('.scelta-default-wrap');
|
||||
if (!wrap) return false;
|
||||
const sel = tr.querySelector('.mapping-select');
|
||||
if (sel) sel.value = 'manual';
|
||||
wrap.style.display = 'block';
|
||||
const hint = tr.querySelector('.scelta-binding-hint');
|
||||
if (hint) hint.style.display = 'none';
|
||||
const dd = tr.querySelector('select.manual-default.dropdown-select');
|
||||
saveMapping(mappingId, 'manual', dd ? dd.value : '', null, null, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
function saveMapping(mappingId, mappingType, defaultValue, excelColumn, autoValue, jsonNode) {
|
||||
console.log("Saving mapping:", {
|
||||
id: mappingId,
|
||||
|
||||
Reference in New Issue
Block a user