@yuneta/gobj-ui 7.26.23 → 7.26.24
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/dist/gobj-ui.cjs.js
CHANGED
|
@@ -73644,17 +73644,23 @@ function plan_import(treedb, incoming, options) {
|
|
|
73644
73644
|
topic: name || "",
|
|
73645
73645
|
col: in_col.name
|
|
73646
73646
|
});
|
|
73647
|
+
let inner_id = (in_col.col || {}).id;
|
|
73648
|
+
if (typeof inner_id === "string" && inner_id !== in_col.name && col_name_breaks_the_rule(inner_id)) conflicts.push({
|
|
73649
|
+
code: "column name breaks the name rule",
|
|
73650
|
+
topic: name || "",
|
|
73651
|
+
col: inner_id
|
|
73652
|
+
});
|
|
73647
73653
|
let hook = (in_col.col || {}).hook;
|
|
73648
73654
|
if (hook && typeof hook === "object" && !Array.isArray(hook)) for (let [child_topic, fkey_col] of Object.entries(hook)) {
|
|
73649
73655
|
if (topic_name_breaks_the_rule(child_topic)) conflicts.push({
|
|
73650
73656
|
code: "topic name breaks the name rule",
|
|
73651
|
-
topic:
|
|
73652
|
-
col:
|
|
73657
|
+
topic: child_topic,
|
|
73658
|
+
col: ""
|
|
73653
73659
|
});
|
|
73654
73660
|
if (col_name_breaks_the_rule(fkey_col)) conflicts.push({
|
|
73655
73661
|
code: "column name breaks the name rule",
|
|
73656
|
-
topic:
|
|
73657
|
-
col:
|
|
73662
|
+
topic: child_topic,
|
|
73663
|
+
col: String(fkey_col)
|
|
73658
73664
|
});
|
|
73659
73665
|
}
|
|
73660
73666
|
}
|
|
@@ -76963,13 +76969,19 @@ function render_import_plan(gobj, plan) {
|
|
|
76963
76969
|
"div",
|
|
76964
76970
|
{ class: "SCHEMA_IMPORT_CONFLICTS notification is-danger is-light p-3" },
|
|
76965
76971
|
plan.conflicts.map((conflict) => {
|
|
76972
|
+
let where = conflict.col ? `${conflict.topic}.${conflict.col}` : conflict.topic;
|
|
76966
76973
|
return [
|
|
76967
76974
|
"p",
|
|
76968
|
-
{
|
|
76969
|
-
|
|
76970
|
-
|
|
76971
|
-
|
|
76972
|
-
|
|
76975
|
+
{ class: "SCHEMA_IMPORT_CONFLICT is-size-7" },
|
|
76976
|
+
[[
|
|
76977
|
+
"span",
|
|
76978
|
+
{ i18n: conflict.code },
|
|
76979
|
+
(0, i18next.t)(conflict.code)
|
|
76980
|
+
], where ? [
|
|
76981
|
+
"code",
|
|
76982
|
+
{ class: "SCHEMA_IMPORT_CONFLICT_NAME ml-2" },
|
|
76983
|
+
text_node(where)
|
|
76984
|
+
] : null].filter(Boolean)
|
|
76973
76985
|
];
|
|
76974
76986
|
})
|
|
76975
76987
|
]));
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -73639,17 +73639,23 @@ function plan_import(treedb, incoming, options) {
|
|
|
73639
73639
|
topic: name || "",
|
|
73640
73640
|
col: in_col.name
|
|
73641
73641
|
});
|
|
73642
|
+
let inner_id = (in_col.col || {}).id;
|
|
73643
|
+
if (typeof inner_id === "string" && inner_id !== in_col.name && col_name_breaks_the_rule(inner_id)) conflicts.push({
|
|
73644
|
+
code: "column name breaks the name rule",
|
|
73645
|
+
topic: name || "",
|
|
73646
|
+
col: inner_id
|
|
73647
|
+
});
|
|
73642
73648
|
let hook = (in_col.col || {}).hook;
|
|
73643
73649
|
if (hook && typeof hook === "object" && !Array.isArray(hook)) for (let [child_topic, fkey_col] of Object.entries(hook)) {
|
|
73644
73650
|
if (topic_name_breaks_the_rule(child_topic)) conflicts.push({
|
|
73645
73651
|
code: "topic name breaks the name rule",
|
|
73646
|
-
topic:
|
|
73647
|
-
col:
|
|
73652
|
+
topic: child_topic,
|
|
73653
|
+
col: ""
|
|
73648
73654
|
});
|
|
73649
73655
|
if (col_name_breaks_the_rule(fkey_col)) conflicts.push({
|
|
73650
73656
|
code: "column name breaks the name rule",
|
|
73651
|
-
topic:
|
|
73652
|
-
col:
|
|
73657
|
+
topic: child_topic,
|
|
73658
|
+
col: String(fkey_col)
|
|
73653
73659
|
});
|
|
73654
73660
|
}
|
|
73655
73661
|
}
|
|
@@ -76958,13 +76964,19 @@ function render_import_plan(gobj, plan) {
|
|
|
76958
76964
|
"div",
|
|
76959
76965
|
{ class: "SCHEMA_IMPORT_CONFLICTS notification is-danger is-light p-3" },
|
|
76960
76966
|
plan.conflicts.map((conflict) => {
|
|
76967
|
+
let where = conflict.col ? `${conflict.topic}.${conflict.col}` : conflict.topic;
|
|
76961
76968
|
return [
|
|
76962
76969
|
"p",
|
|
76963
|
-
{
|
|
76964
|
-
|
|
76965
|
-
|
|
76966
|
-
|
|
76967
|
-
|
|
76970
|
+
{ class: "SCHEMA_IMPORT_CONFLICT is-size-7" },
|
|
76971
|
+
[[
|
|
76972
|
+
"span",
|
|
76973
|
+
{ i18n: conflict.code },
|
|
76974
|
+
t(conflict.code)
|
|
76975
|
+
], where ? [
|
|
76976
|
+
"code",
|
|
76977
|
+
{ class: "SCHEMA_IMPORT_CONFLICT_NAME ml-2" },
|
|
76978
|
+
text_node(where)
|
|
76979
|
+
] : null].filter(Boolean)
|
|
76968
76980
|
];
|
|
76969
76981
|
})
|
|
76970
76982
|
]));
|
package/package.json
CHANGED
|
@@ -2684,8 +2684,15 @@ function render_import_plan(gobj, plan)
|
|
|
2684
2684
|
$pane.appendChild(createElement2(
|
|
2685
2685
|
["div", {class: "SCHEMA_IMPORT_CONFLICTS notification is-danger is-light p-3"},
|
|
2686
2686
|
plan.conflicts.map((conflict) => {
|
|
2687
|
-
|
|
2688
|
-
|
|
2687
|
+
/* What the conflict is about, said: two bad entries of
|
|
2688
|
+
* one hook map were two identical lines. */
|
|
2689
|
+
let where = conflict.col
|
|
2690
|
+
? `${conflict.topic}.${conflict.col}`
|
|
2691
|
+
: conflict.topic;
|
|
2692
|
+
return ["p", {class: "SCHEMA_IMPORT_CONFLICT is-size-7"}, [
|
|
2693
|
+
["span", {i18n: conflict.code}, t(conflict.code)],
|
|
2694
|
+
where ? ["code", {class: "SCHEMA_IMPORT_CONFLICT_NAME ml-2"}, text_node(where)] : null
|
|
2695
|
+
].filter(Boolean)];
|
|
2689
2696
|
})]
|
|
2690
2697
|
));
|
|
2691
2698
|
if(priv.import_run) {
|
|
@@ -1768,6 +1768,8 @@ describe("aria-invalid of the name field", () => {
|
|
|
1768
1768
|
};
|
|
1769
1769
|
save("a/b");
|
|
1770
1770
|
expect($value.getAttribute("aria-invalid")).toBe("true");
|
|
1771
|
+
save("users"); // a duplicate: the topic is there
|
|
1772
|
+
expect($value.getAttribute("aria-invalid")).toBe("true");
|
|
1771
1773
|
save("ok_name");
|
|
1772
1774
|
expect($value.getAttribute("aria-invalid")).toBe(null);
|
|
1773
1775
|
take("update-node");
|
package/src/schema_import.js
CHANGED
|
@@ -233,18 +233,28 @@ function plan_import(treedb, incoming, options)
|
|
|
233
233
|
if(col_name_breaks_the_rule(in_col.name)) {
|
|
234
234
|
conflicts.push({code: "column name breaks the name rule", topic: name || "", col: in_col.name});
|
|
235
235
|
}
|
|
236
|
+
/* A dict column carries its id twice: the key (what is
|
|
237
|
+
* imported) and its own `id`. One that breaks the rule is said
|
|
238
|
+
* too, not imported under the key in silence. */
|
|
239
|
+
let inner_id = (in_col.col || {}).id;
|
|
240
|
+
if(typeof inner_id === "string" && inner_id !== in_col.name &&
|
|
241
|
+
col_name_breaks_the_rule(inner_id)) {
|
|
242
|
+
conflicts.push({code: "column name breaks the name rule", topic: name || "", col: inner_id});
|
|
243
|
+
}
|
|
236
244
|
/* The hook map names a child topic and its fkey column: names
|
|
237
245
|
* the treedb refuses too, even when no column declares them. */
|
|
238
246
|
let hook = (in_col.col || {}).hook;
|
|
239
247
|
if(hook && typeof hook === "object" && !Array.isArray(hook)) {
|
|
240
248
|
for(let [child_topic, fkey_col] of Object.entries(hook)) {
|
|
249
|
+
/* The conflict names the BAD name (the child topic, its
|
|
250
|
+
* fkey), not the hook column that maps to it. */
|
|
241
251
|
if(topic_name_breaks_the_rule(child_topic)) {
|
|
242
252
|
conflicts.push({code: "topic name breaks the name rule",
|
|
243
|
-
topic:
|
|
253
|
+
topic: child_topic, col: ""});
|
|
244
254
|
}
|
|
245
255
|
if(col_name_breaks_the_rule(fkey_col)) {
|
|
246
256
|
conflicts.push({code: "column name breaks the name rule",
|
|
247
|
-
topic:
|
|
257
|
+
topic: child_topic, col: String(fkey_col)});
|
|
248
258
|
}
|
|
249
259
|
}
|
|
250
260
|
}
|
|
@@ -310,3 +310,22 @@ describe("the import reads the hook map and the treedb id (REV-CLOUD V15.4)", ()
|
|
|
310
310
|
expect(codes).toContain("column has no name");
|
|
311
311
|
});
|
|
312
312
|
});
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
describe("a conflict names the bad name (REV-CLOUD V16.5)", () => {
|
|
316
|
+
test("the child topic and the fkey of a hook map, and a dict column's inner id", () => {
|
|
317
|
+
let plan = plan_import(null, {
|
|
318
|
+
id: "db", schema_version: "1",
|
|
319
|
+
topics: [{id: "p", pkey: "id", cols: {
|
|
320
|
+
"id": {id: "id", type: "string"},
|
|
321
|
+
"kids": {id: "kids", type: "dict", flag: ["hook"], hook: {"a/b": "x`y"}},
|
|
322
|
+
"good": {id: "go`od", type: "string"},
|
|
323
|
+
}}]
|
|
324
|
+
});
|
|
325
|
+
expect(plan.writes).toEqual([]);
|
|
326
|
+
let named = plan.conflicts.map((c) => `${c.code}|${c.topic}|${c.col}`);
|
|
327
|
+
expect(named).toContain("topic name breaks the name rule|a/b|");
|
|
328
|
+
expect(named).toContain("column name breaks the name rule|a/b|x`y");
|
|
329
|
+
expect(named).toContain("column name breaks the name rule|p|go`od");
|
|
330
|
+
});
|
|
331
|
+
});
|