@yuneta/gobj-ui 7.23.158 → 7.23.160

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 CHANGED
@@ -925,6 +925,30 @@ so it survived that — two light islands over a dark canvas.
925
925
  (all tooltips, so a host that has not defined them shows the key on hover and
926
926
  nothing else breaks).
927
927
 
928
+ ### The wheel over HTML nodes: `yui_graph_forward_wheel`
929
+
930
+ G6's HTML nodes are drawn in a DOM layer **beside** the canvas element, and
931
+ they pass on six pointer events and not the wheel. `scroll-canvas` listens on
932
+ the canvas element and `zoom-canvas` reads G's wheel, which comes from that
933
+ same element. So a wheel over an HTML card reaches neither: the graph does not
934
+ scroll and does not zoom.
935
+
936
+ `yui_graph_forward_wheel(graph, $host)` catches the wheel on the element G6 was
937
+ mounted in and dispatches it again on the canvas element, with its deltas, its
938
+ position and its modifiers. Both behaviors then take it as a wheel over empty
939
+ canvas. It returns the function that removes the listener; call it before the
940
+ graph is destroyed.
941
+
942
+ ```js
943
+ priv.unforward_wheel = yui_graph_forward_wheel(graph, priv.$canvas);
944
+ // ... in the teardown, before graph.destroy():
945
+ priv.unforward_wheel();
946
+ ```
947
+
948
+ An element that must scroll by itself inside the graph (a popover) stops the
949
+ wheel with `stopPropagation()` before it reaches `$host`.
950
+ `C_YUI_TREEDB_SCHEMA` uses it; `C_G6_NODES_TREE` does not yet.
951
+
928
952
  ### The anchor: one element the camera holds
929
953
 
930
954
  The same crosshairs button is in all three graphs' toolbars, drawn once in
@@ -1797,6 +1821,17 @@ schema question; that one answers the data question.
1797
1821
  The demo `test-app/schema.html` mounts it alone against the real yuneta agent
1798
1822
  schema, so the drawing can be held against the ASCII one in its `.c`.
1799
1823
 
1824
+ **Its camera is the family's** (since `7.23.160`). It has a toolbar with the
1825
+ `yui_graph_camera.js` cluster (zoom in, zoom out, the readout, fit, `1:1`), and
1826
+ it takes the wheel the same way as the other graphs: the wheel **scrolls**,
1827
+ Ctrl + wheel zooms, and a pinch zooms on a touch screen. This is true over the
1828
+ cards too, through `yui_graph_forward_wheel()`: the cards cover most of this
1829
+ drawing, and without it the wheel worked only in the gaps. It still never fits
1830
+ itself when it appears; fit is a button. The toolbar buttons fire
1831
+ `EV_ZOOM_IN`, `EV_ZOOM_OUT`, `EV_ZOOM_RESET` and `EV_CENTER` to the view
1832
+ itself, so a host declares nothing. `wide` (default `40px`) sets the button
1833
+ height.
1834
+
1800
1835
  **Contract:**
1801
1836
 
1802
1837
  - Attributes: `subscriber`, `descs` (`{topic_name: desc}`, the schema),
@@ -1952,7 +1987,12 @@ backend** — asking is an action and belongs in the view's own FSM:
1952
1987
  |---|---|
1953
1988
  | `yui_asset_id(ref)` / `yui_asset_ids(ref)` | the id(s) a column names. A link comes back in whichever shape the READER asked for — the stored `"assets^<id>^as_foto"`, the bare `"<id>"` that `fkey_only_id` collapses it to, or an expanded `{id}` — and either alone or in a list, because an unset single-valued fkey is still an empty list. All of them are read; an empty column answers nothing rather than throwing |
1954
1989
  | `yui_asset_src(answer)` | the two shapes into one `src`. `null` when the answer carries neither — never an empty string, because `<img src="">` reloads the page in some browsers |
1955
- | `yui_asset_element(answer, opts)` | the element, picked from the **content type the backend stored**: `<img>`, `<video>` or `<audio>`. Video and audio are assets too, and an `<img>` whose src is a film shows the broken box this exists to remove |
1990
+ | `yui_asset_kind(content_type)` | `"image"`, `"video"`, `"audio"`, `"pdf"` or `"other"`, from the content type the backend stored (a `; charset=…` parameter is ignored) |
1991
+ | `yui_asset_element(answer, opts)` | the element, picked by that kind: `<img>`, `<video>`, `<audio>`, a PDF in an `<iframe>` (the browser's own viewer), or, for any other kind, a card with the content type and an open link. Video and audio are assets too, and an `<img>` whose src is a film shows the broken box this exists to remove |
1992
+ | `yui_asset_open_link(answer)` | an `<a target=_blank>` that opens the asset at full size, named through `open in a new tab`. `null` when there is nothing to open |
1993
+ | `yui_asset_href(answer)` | `{href, blob}`: the url as it comes, or a `blob:` url over inline bytes. Firefox will not NAVIGATE to a `data:` url (a new tab stays blank) and its PDF viewer does not run on one in a frame, so frames and links need a blob |
1994
+ | `yui_asset_file_answer(file)` | the answer a picked `File` would have had: a `url` answer over a `blob:` url of the File itself, so a file not saved yet goes through the same element as a stored one |
1995
+ | `yui_asset_release($root)` | revoke every `blob:` url this module made under `$root`, `$root` included. A blob url keeps its bytes alive until revoked and removing the DOM revokes nothing, so call it on whatever element you drop |
1956
1996
  | `yui_asset_missing(detail, opts)` | the marker, for when there is nothing to show |
1957
1997
 
1958
1998
  **A missing asset is now said out loud.** It used to leave a broken box and
@@ -1979,6 +2019,43 @@ if(id) {
1979
2019
  $box.appendChild(yui_asset_element(answer, {detail: device.foto_name}));
1980
2020
  ```
1981
2021
 
2022
+ #### In the treedb views
2023
+
2024
+ The treedb form and table show the asset a `file` column names, and they ask
2025
+ for it in the same way as a page of rows: the table publishes the request UP
2026
+ and its host owns the transport.
2027
+
2028
+ ```
2029
+ C_YUI_TREEDB_TOPIC_WITH_FORM C_YUI_TREEDB_TOPICS
2030
+ EV_REQUEST_ASSET {topic_name, req_id, asset_id} ──► get-asset asset_id=<id>
2031
+ (service = assets_service)
2032
+ EV_ASSET_LOADED {req_id, answer} ◄── the answer, by req_id
2033
+ EV_ASSET_FAILED {req_id, error} ◄── a refusal, no backend, or 30 s of silence
2034
+ ```
2035
+
2036
+ - **Form:** when the edit dialog opens, one request goes out per `file` column
2037
+ that names an asset. The answer reaches the form as
2038
+ `EV_SET_FILE_PREVIEW {name, id, answer, error}` and is drawn under the
2039
+ control only while the column still names that id. A picked file needs no
2040
+ request: it is previewed from the `File`.
2041
+ - **Table:** a click on a file cell opens a popup with one slot per asset the
2042
+ cell names. Each slot starts as `loading` and is filled by its own answer.
2043
+
2044
+ Set the service on the host. `"assets"` is the default, and it is what a yuno
2045
+ names its `C_ASSETS`; an empty string turns the requests off:
2046
+
2047
+ ```js
2048
+ gobj_create_service("#topics-mydb", "C_YUI_TREEDB_TOPICS", {
2049
+ gobj_remote_yuno: remote,
2050
+ treedb_name: "treedb_mydb",
2051
+ assets_service: "assets"
2052
+ }, gobj);
2053
+ ```
2054
+
2055
+ The user needs the `read` permission of that service. The service is not the
2056
+ one the connection was opened for, so a user who is not root must also hold a
2057
+ role in it, or the ievent gate refuses to route the command there.
2058
+
1982
2059
  ### JSON viewer — `setup_json_pad`
1983
2060
 
1984
2061
  `setup_json_pad(self)` opens a **blank JSON pad** (`C_YUI_JSON_PAD`) in a