fixed mapping template
This commit is contained in:
parent
a8330d4aba
commit
9fe9243e60
@ -665,6 +665,61 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
|||||||
|
|
||||||
loadDropdownsWithOverlay();
|
loadDropdownsWithOverlay();
|
||||||
|
|
||||||
|
// =======================
|
||||||
|
// SAVE: SceltaMultipla dropdown (Select2-safe)
|
||||||
|
// =======================
|
||||||
|
|
||||||
|
// 1) listener nativo a livello document (più robusto del delegation su tbody)
|
||||||
|
document.addEventListener('change', function(event) {
|
||||||
|
const el = event.target;
|
||||||
|
if (!(el && el.matches && el.matches('select.manual-default.dropdown-select'))) return;
|
||||||
|
|
||||||
|
const tr = el.closest('tr');
|
||||||
|
const mappingId =
|
||||||
|
el.getAttribute('data-id') ||
|
||||||
|
tr?.querySelector('.mapping-select')?.getAttribute('data-id');
|
||||||
|
|
||||||
|
const xlsSelect = tr?.querySelector('.xls-columns');
|
||||||
|
|
||||||
|
console.log('[SceltaMultipla change] saving', {
|
||||||
|
mappingId,
|
||||||
|
value: el.value
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!mappingId) {
|
||||||
|
console.error('❌ Missing mappingId for SceltaMultipla dropdown');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveMapping(mappingId, 'manual', el.value, xlsSelect ? xlsSelect.value : null);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2) eventi Select2 (quando Select2 “mangia” il change)
|
||||||
|
if (window.jQuery) {
|
||||||
|
$(document).on('select2:select select2:clear', 'select.manual-default.dropdown-select', function() {
|
||||||
|
const el = this;
|
||||||
|
const tr = el.closest('tr');
|
||||||
|
const mappingId =
|
||||||
|
el.getAttribute('data-id') ||
|
||||||
|
tr?.querySelector('.mapping-select')?.getAttribute('data-id');
|
||||||
|
|
||||||
|
const xlsSelect = tr?.querySelector('.xls-columns');
|
||||||
|
|
||||||
|
console.log('[SceltaMultipla select2] saving', {
|
||||||
|
mappingId,
|
||||||
|
value: el.value
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!mappingId) {
|
||||||
|
console.error('❌ Missing mappingId for SceltaMultipla dropdown (select2)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveMapping(mappingId, 'manual', el.value, xlsSelect ? xlsSelect.value : null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async function loadClientAndSchemaNames() {
|
async function loadClientAndSchemaNames() {
|
||||||
if (<?php echo json_encode($template['idclient'] ?? 0); ?> > 0) {
|
if (<?php echo json_encode($template['idclient'] ?? 0); ?> > 0) {
|
||||||
let response = await fetch(`get_clienti.php?id=<?php echo $template['idclient']; ?>`);
|
let response = await fetch(`get_clienti.php?id=<?php echo $template['idclient']; ?>`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user