multicloud_rule_manager 1.1.42 → 1.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/retrievedatamap.js +31 -41
- package/package.json +1 -1
|
@@ -13,21 +13,40 @@ export default {
|
|
|
13
13
|
function buildNodes(children) {
|
|
14
14
|
if (!Array.isArray(children) || children.length === 0) return [];
|
|
15
15
|
|
|
16
|
-
const sorted =
|
|
16
|
+
const sorted = (children);
|
|
17
17
|
|
|
18
18
|
return sorted.map(child => {
|
|
19
19
|
const template = {
|
|
20
|
-
|
|
21
|
-
attributes: [],
|
|
22
|
-
children: []
|
|
20
|
+
name: child.name || "NO_NAME"
|
|
23
21
|
};
|
|
24
22
|
|
|
25
|
-
if (Array.isArray(child.
|
|
26
|
-
|
|
23
|
+
if (Array.isArray(child.map_object_items)) {
|
|
24
|
+
for (const item of hild.map_object_items) {
|
|
25
|
+
|
|
26
|
+
if (!item.system_record) {
|
|
27
|
+
var ultimoNodo = {
|
|
28
|
+
|
|
29
|
+
"label": item.label,
|
|
30
|
+
"relationship_object": item.relationship_object,
|
|
31
|
+
"relationship_target_source_field": item.relationship_target_source_field,
|
|
32
|
+
"overridable": item.overridable,
|
|
33
|
+
"price_model_selectable": item.price_model_selectable,
|
|
34
|
+
"value": item.value,
|
|
35
|
+
"engine_field": item.engine_field,
|
|
36
|
+
"source_field": item.source_field,
|
|
37
|
+
"type": item.type,
|
|
38
|
+
"relationship_target_field": item.relationship_target_field,
|
|
39
|
+
"field_type": item.field_type,
|
|
40
|
+
"target_name": item.target_name
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
template.map_object_items = (ultimoNodo);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
27
46
|
}
|
|
28
47
|
|
|
29
|
-
if (Array.isArray(child.
|
|
30
|
-
template.
|
|
48
|
+
if (Array.isArray(child.map_objects) && child.map_objects.length > 0) {
|
|
49
|
+
template.map_objects = buildNodes(child.map_objects); // ricorsione
|
|
31
50
|
}
|
|
32
51
|
|
|
33
52
|
return template;
|
|
@@ -36,31 +55,6 @@ export default {
|
|
|
36
55
|
|
|
37
56
|
|
|
38
57
|
|
|
39
|
-
function sortNodes(nodes) {
|
|
40
|
-
if (!Array.isArray(nodes)) return nodes;
|
|
41
|
-
|
|
42
|
-
// ordina alfabeticamente per _key
|
|
43
|
-
nodes.sort((a, b) => {
|
|
44
|
-
const ka = (a._key || "").toLowerCase();
|
|
45
|
-
const kb = (b._key || "").toLowerCase();
|
|
46
|
-
return ka.localeCompare(kb);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// ricorsione su nodi annidati
|
|
50
|
-
for (const node of nodes) {
|
|
51
|
-
if (Array.isArray(node._children)) {
|
|
52
|
-
node._children = sortNodes(node._children);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (Array.isArray(node._attributes)) {
|
|
56
|
-
node._attributes = sortNodes(node._attributes);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return nodes;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
58
|
|
|
65
59
|
try {
|
|
66
60
|
console.log("🔹 Retrieve Datamap in corso..");
|
|
@@ -148,22 +142,18 @@ export default {
|
|
|
148
142
|
|
|
149
143
|
const mapData = await mapResp.json();
|
|
150
144
|
|
|
151
|
-
var map = mapData?.
|
|
145
|
+
var map = mapData?.map_objects;
|
|
152
146
|
|
|
153
147
|
// costruzione JSON finale
|
|
154
148
|
const result = {
|
|
155
|
-
attributes: [],
|
|
156
|
-
children: []
|
|
157
149
|
};
|
|
158
150
|
|
|
159
151
|
if (map) {
|
|
160
152
|
|
|
161
|
-
if (Array.isArray(map._attributes)) {
|
|
162
|
-
result.attributes = sortNodes(map._attributes);
|
|
163
|
-
}
|
|
164
153
|
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
|
|
155
|
+
if (Array.isArray(map)) {
|
|
156
|
+
result = buildNodes(map);
|
|
167
157
|
}
|
|
168
158
|
|
|
169
159
|
|