Importer update add support for meta data and multiple inserts for some entities like addresses and phones, updated other things

This commit is contained in:
Simon Pocrnjič
2025-10-09 22:28:48 +02:00
parent c8029c9eb0
commit 0598261cdc
27 changed files with 2517 additions and 375 deletions
+32 -1
View File
@@ -130,6 +130,24 @@ function evaluateMappingSaved() {
persistedSignature.value = computeMappingSignature(mappingRows.value);
}
function normalizeOptions(val) {
if (!val) {
return {};
}
if (typeof val === "string") {
try {
const parsed = JSON.parse(val);
return parsed && typeof parsed === "object" ? parsed : {};
} catch (e) {
return {};
}
}
if (typeof val === "object") {
return val;
}
return {};
}
function computeMappingSignature(rows) {
return rows
.filter((r) => r && r.source_column)
@@ -270,6 +288,7 @@ function defaultEntityDefs() {
"description",
"type_id",
"client_case_id",
"meta",
],
},
{
@@ -359,6 +378,7 @@ const displayRows = computed(() => {
skip: false,
transform: "trim",
apply_mode: "both",
options: {},
position: idx,
}));
});
@@ -570,6 +590,7 @@ async function fetchColumns() {
skip: false,
transform: "trim",
apply_mode: "both",
options: {},
position: idx,
}));
suppressMappingWatch = false;
@@ -592,6 +613,7 @@ async function fetchColumns() {
skip: false,
transform: m.transform || "trim",
apply_mode: m.apply_mode || "both",
options: normalizeOptions(m.options),
position: idx,
};
});
@@ -685,6 +707,7 @@ async function loadImportMappings() {
field,
transform: m.transform || "",
apply_mode: m.apply_mode || "both",
options: normalizeOptions(m.options) || r.options || {},
skip: false,
position: idx,
};
@@ -738,7 +761,13 @@ async function saveMappings() {
target_field: `${entityKeyToRecord(r.entity)}.${r.field}`,
transform: r.transform || null,
apply_mode: r.apply_mode || "both",
options: null,
options:
r.field === "meta"
? {
key: r.options?.key ?? null,
type: r.options?.type ?? null,
}
: null,
}));
if (!mappings.length) {
mappingSaved.value = false;
@@ -820,6 +849,7 @@ onMounted(async () => {
skip: false,
transform: "trim",
apply_mode: "both",
options: {},
position: idx,
};
});
@@ -877,6 +907,7 @@ watch(
skip: false,
transform: "trim",
apply_mode: "both",
options: {},
position: idx,
};
});