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:
@@ -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,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user