@yuneta/gobj-ui 5.17.0 → 6.1.0
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/README.md +103 -8
- package/dist/gobj-ui.cjs.js +5397 -489
- package/dist/gobj-ui.es.js +5397 -490
- package/index.js +1 -0
- package/package.json +3 -3
- package/src/c_yui_form.js +11 -3
- package/src/c_yui_schema_editor.css +133 -0
- package/src/c_yui_schema_editor.js +3217 -0
- package/src/c_yui_treedb_schema.js +22 -3
- package/src/c_yui_treedb_topic_with_form.js +5 -1
- package/src/schema_descs.js +164 -0
- package/src/schema_descs.test.js +145 -0
- package/src/schema_flags.js +237 -0
- package/src/schema_flags.test.js +133 -0
- package/src/schema_import.js +413 -0
- package/src/schema_import.test.js +234 -0
- package/src/schema_model.js +512 -0
- package/src/schema_model.test.js +233 -0
- package/src/schema_to_c.js +367 -0
- package/src/schema_to_c.test.js +218 -0
- package/src/schema_validate.js +289 -0
- package/src/schema_validate.test.js +265 -0
- package/src/treedb_node_label.js +15 -9
- package/src/treedb_node_label.test.js +14 -0
package/README.md
CHANGED
|
@@ -434,15 +434,17 @@ Logical DOM classes: `JSON_VIEWER`, `JSON_TOOLBAR`, `JSON_SEARCH`, `JSON_TREE`,
|
|
|
434
434
|
|
|
435
435
|
`C_G6_NODES_TREE` (the record graph inside `C_YUI_TREEDB_GRAPH`) labels a card
|
|
436
436
|
by what NAMES the record, which is not always what KEYS it. A topic whose id
|
|
437
|
-
column is flagged `rowid` or `
|
|
438
|
-
that is the
|
|
437
|
+
column is flagged `rowid`, `uuid` or `qualified` keys its records by something
|
|
438
|
+
that is not the plain name — a counter, a random string, or the name with
|
|
439
|
+
every ancestor in front of it — and the name lives in the secondary key the
|
|
439
440
|
topic declares (`pkey2s`). `treedb_system_schema` is the case that forced it:
|
|
440
|
-
its `topics` and `cols` records are
|
|
441
|
-
|
|
441
|
+
its `topics` and `cols` records are named in `value`, so the graph drew cards
|
|
442
|
+
reading `181`, `225`, `193` while they were keyed by rowid, and would read the
|
|
443
|
+
whole path now that they are qualified.
|
|
442
444
|
|
|
443
445
|
The rule is in **`treedb_node_label.js`** (pure, unit-tested): read the pkey
|
|
444
|
-
column's flags from the desc; if the key is
|
|
445
|
-
field the record actually carries; otherwise keep the id. **The pkey is never
|
|
446
|
+
column's flags from the desc; if the key is not the plain name, take the first
|
|
447
|
+
`pkey2s` field the record actually carries; otherwise keep the id. **The pkey is never
|
|
446
448
|
lost** — it is the card's tooltip, on the chip and on the entity card alike.
|
|
447
449
|
|
|
448
450
|
It needs the descriptor to carry `pkey2s`, which `tranger2_topic_desc()` only
|
|
@@ -535,13 +537,106 @@ schema, so the drawing can be held against the ASCII one in its `.c`.
|
|
|
535
537
|
`system` (include the `__*__` system topics too, default `false`),
|
|
536
538
|
`$container` (mounted by the parent).
|
|
537
539
|
- Events: `EV_SHOW`, `EV_REBUILD`, `EV_THEME` (restyle — it repaints the G6
|
|
538
|
-
graph in place, preserving the user's zoom/pan), plus
|
|
539
|
-
|
|
540
|
+
graph in place, preserving the user's zoom/pan), plus `EV_NODE_CLICK`, which
|
|
541
|
+
a node click sends into the FSM. **With a `node_route` the click IS a
|
|
542
|
+
navigation** and this view makes it; **without one the click is published**
|
|
543
|
+
(`{topic}`) for whoever mounted the view — a host that draws the same picture
|
|
544
|
+
inside its own screens opens the topic in place, with no hash involved. A
|
|
545
|
+
host that subscribes must declare `EV_NODE_CLICK` in its own FSM, as with
|
|
546
|
+
every event a child publishes. Since 6.1.0; before that a click with no route
|
|
547
|
+
was dropped.
|
|
540
548
|
|
|
541
549
|
Barrel-exported and public from 4.0.0. Renders with `@antv/g6`; the cards are
|
|
542
550
|
HTML nodes carrying their own inline colours, so a theme switch repaints them in
|
|
543
551
|
place (no CSS of its own).
|
|
544
552
|
|
|
553
|
+
### C_YUI_SCHEMA_EDITOR — a schema edited as a schema
|
|
554
|
+
|
|
555
|
+
Every schema a yuno holds lives in its `treedb_system_schema`, stored as data
|
|
556
|
+
in three flat topics linked by fkeys: `treedbs` → `topics` → `cols`. That is
|
|
557
|
+
the right **storage** and it is not a **screen**. Opened with the ordinary
|
|
558
|
+
topic editor, adding one column to one topic means finding it in a table
|
|
559
|
+
holding every column of every topic of every treedb the yuno has, composing the
|
|
560
|
+
parent fkey by hand, and remembering to raise a `topic_version` that nothing
|
|
561
|
+
asks about.
|
|
562
|
+
|
|
563
|
+
This view puts the schema back together and edits that: **treedb → topics →
|
|
564
|
+
columns**, each in its declared `order`, with the storage composed underneath —
|
|
565
|
+
the qualified id, the fkey to the parent, the place among the siblings, and the
|
|
566
|
+
versions that publish the change.
|
|
567
|
+
|
|
568
|
+
**The versions are the point, not a detail.** `topic_version` is what publishes
|
|
569
|
+
a change of a topic's columns: leave it and the persisted `topic_cols.json`
|
|
570
|
+
masks the whole edit — the restart succeeds and nothing moved. `schema_version`
|
|
571
|
+
is what publishes the schema as a whole ("the stored one wins on ties, and the
|
|
572
|
+
incoming one has to be strictly newer to take over", `c_treedb.c`), and raising
|
|
573
|
+
it is safe: re-projection from C compares `c_schema_version`, the version of
|
|
574
|
+
the **literal**, precisely so that an edit made here survives every start until
|
|
575
|
+
a newer literal arrives. So **every write carries both** and the operator is
|
|
576
|
+
never asked to remember either. The banner in the column screen is for the case
|
|
577
|
+
where something *else* wrote the topic and left its version alone.
|
|
578
|
+
|
|
579
|
+
What the screens offer:
|
|
580
|
+
|
|
581
|
+
| Screen | What it is for |
|
|
582
|
+
|--------|----------------|
|
|
583
|
+
| treedbs | one card per treedb, with its topic count and its `schema_version` beside the `c_schema_version` it was projected from |
|
|
584
|
+
| topics | the topics of one treedb in schema order: pkey, column count, version, system flag |
|
|
585
|
+
| columns | the heart. Rows in `order`, **draggable** — `order` is a field, so a drop writes the rows whose place actually changed, two or three and not forty |
|
|
586
|
+
| diagram | the treedb **drawn from the records being edited**, through `C_YUI_TREEDB_SCHEMA` |
|
|
587
|
+
|
|
588
|
+
And what the toolbar offers, each answering a question the storage could not:
|
|
589
|
+
|
|
590
|
+
- **check** — what the treedb would refuse, from the records alone: a pkey
|
|
591
|
+
naming no column, a hook whose target is missing or is not a fkey, two hooks
|
|
592
|
+
on one fkey, an `enum` flag with no `enum`. Applying a schema is restarting
|
|
593
|
+
the yuno that owns it, so a schema it refuses costs an outage to discover and
|
|
594
|
+
the message lands in that yuno's log, on the node, minutes later.
|
|
595
|
+
- **export** — the schema as its **C literal**, ready to paste into the source.
|
|
596
|
+
An edit made here works and lives nowhere the next build knows about;
|
|
597
|
+
`diff-schema` says the two halves drifted, and this is the other half of that
|
|
598
|
+
answer. Escaping crosses two layers and the second is not JSON's:
|
|
599
|
+
`helper_quote2doublequote()` rewrites *every* single quote before the parse,
|
|
600
|
+
so a quote inside a value can only survive as `\u0027`.
|
|
601
|
+
- **import** — the writes that make the stored schema equal a pasted one, shown
|
|
602
|
+
as a **plan** before it runs. Import is the one operation here that can delete
|
|
603
|
+
a column, so what is confirmed is what runs.
|
|
604
|
+
|
|
605
|
+
The **flags** of a column are checkboxes that say what they do, grouped the way
|
|
606
|
+
they act and dimmed (never hidden) when they are meaningless on the chosen type:
|
|
607
|
+
a flag already set on a column of another type has to stay visible or the next
|
|
608
|
+
save drops it silently. `hook` and `fkey` turn each other off, because they are
|
|
609
|
+
the two ends of one link.
|
|
610
|
+
|
|
611
|
+
A **name is not editable**: the store keys a column by its qualified id —
|
|
612
|
+
treedb, topic and name — so renaming one is creating another and deleting this
|
|
613
|
+
one. The form says so rather than offering a field that quietly does something
|
|
614
|
+
else.
|
|
615
|
+
|
|
616
|
+
**Contract:**
|
|
617
|
+
|
|
618
|
+
- Attributes: `subscriber`, `gobj_remote_yuno` (the transport — the treedb's
|
|
619
|
+
service, or an adapter that reaches it: this view cannot tell and must not),
|
|
620
|
+
`treedb_name` (the system-schema treedb), `readonly` (this yuno does not
|
|
621
|
+
master the tranger, so it refuses every write), `base_route`, `$container`.
|
|
622
|
+
- In: `EV_SHOW` (`{subpath}` — the tail it owns is `<treedb>[/<topic>]` or
|
|
623
|
+
`<treedb>/diagram`), `EV_HIDE`, `EV_TRANSPORT_STATE`, `EV_REFRESH`,
|
|
624
|
+
`EV_LANGUAGE_CHANGED`, `EV_MT_COMMAND_ANSWER`.
|
|
625
|
+
- Out: `EV_POSITION_CHANGED` (`{subpath}` — the host writes the url; this view
|
|
626
|
+
navigates nothing itself), `EV_RECORD_WRITTEN` (whoever owns the Apply needs
|
|
627
|
+
to know the yuno has not re-read its schema yet), `EV_SCHEMA_CHECKED`
|
|
628
|
+
(`{errors, warnings, first}` — so the confirmation that restarts the yuno can
|
|
629
|
+
say what it is about to restart onto).
|
|
630
|
+
- States, because each is a screen and a set of legal actions: `ST_IDLE`,
|
|
631
|
+
`ST_LOADING`, `ST_EMPTY`, `ST_TREEDBS`, `ST_TOPICS`, `ST_DIAGRAM`,
|
|
632
|
+
`ST_COLUMNS`, `ST_SAVING`.
|
|
633
|
+
|
|
634
|
+
The logic is pure and tested apart from the view: `schema_model.js` (the three
|
|
635
|
+
lists regrouped — grouping follows the **fkey**, not a split of the qualified
|
|
636
|
+
id on `.`, which works right up to the first name that carries one),
|
|
637
|
+
`schema_validate.js`, `schema_descs.js`, `schema_to_c.js`, `schema_import.js`,
|
|
638
|
+
`schema_flags.js`. Since 6.1.0.
|
|
639
|
+
|
|
545
640
|
### Frontend view — `setup_frontend_view`
|
|
546
641
|
|
|
547
642
|
`setup_frontend_view(self)` opens the **gobj tree of the app's own yuno** in a
|