@yuneta/gobj-ui 7.23.158 → 7.23.159
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 +43 -1
- package/dist/gobj-ui.cjs.js +773 -125
- package/dist/gobj-ui.es.js +773 -125
- package/package.json +1 -1
- package/src/c_yui_form.js +52 -1
- package/src/c_yui_treedb_topic_with_form.css +67 -0
- package/src/c_yui_treedb_topic_with_form.js +401 -9
- package/src/c_yui_treedb_topics.js +80 -0
- package/src/yui_asset.css +51 -0
- package/src/yui_asset.js +223 -3
- package/src/yui_asset.test.js +18 -0
- package/src/yui_file_field.css +28 -0
- package/src/yui_file_field.js +45 -1
package/README.md
CHANGED
|
@@ -1952,7 +1952,12 @@ backend** — asking is an action and belongs in the view's own FSM:
|
|
|
1952
1952
|
|---|---|
|
|
1953
1953
|
| `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
1954
|
| `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
|
-
| `
|
|
1955
|
+
| `yui_asset_kind(content_type)` | `"image"`, `"video"`, `"audio"`, `"pdf"` or `"other"`, from the content type the backend stored (a `; charset=…` parameter is ignored) |
|
|
1956
|
+
| `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 |
|
|
1957
|
+
| `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 |
|
|
1958
|
+
| `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 |
|
|
1959
|
+
| `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 |
|
|
1960
|
+
| `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
1961
|
| `yui_asset_missing(detail, opts)` | the marker, for when there is nothing to show |
|
|
1957
1962
|
|
|
1958
1963
|
**A missing asset is now said out loud.** It used to leave a broken box and
|
|
@@ -1979,6 +1984,43 @@ if(id) {
|
|
|
1979
1984
|
$box.appendChild(yui_asset_element(answer, {detail: device.foto_name}));
|
|
1980
1985
|
```
|
|
1981
1986
|
|
|
1987
|
+
#### In the treedb views
|
|
1988
|
+
|
|
1989
|
+
The treedb form and table show the asset a `file` column names, and they ask
|
|
1990
|
+
for it in the same way as a page of rows: the table publishes the request UP
|
|
1991
|
+
and its host owns the transport.
|
|
1992
|
+
|
|
1993
|
+
```
|
|
1994
|
+
C_YUI_TREEDB_TOPIC_WITH_FORM C_YUI_TREEDB_TOPICS
|
|
1995
|
+
EV_REQUEST_ASSET {topic_name, req_id, asset_id} ──► get-asset asset_id=<id>
|
|
1996
|
+
(service = assets_service)
|
|
1997
|
+
EV_ASSET_LOADED {req_id, answer} ◄── the answer, by req_id
|
|
1998
|
+
EV_ASSET_FAILED {req_id, error} ◄── a refusal, no backend, or 30 s of silence
|
|
1999
|
+
```
|
|
2000
|
+
|
|
2001
|
+
- **Form:** when the edit dialog opens, one request goes out per `file` column
|
|
2002
|
+
that names an asset. The answer reaches the form as
|
|
2003
|
+
`EV_SET_FILE_PREVIEW {name, id, answer, error}` and is drawn under the
|
|
2004
|
+
control only while the column still names that id. A picked file needs no
|
|
2005
|
+
request: it is previewed from the `File`.
|
|
2006
|
+
- **Table:** a click on a file cell opens a popup with one slot per asset the
|
|
2007
|
+
cell names. Each slot starts as `loading` and is filled by its own answer.
|
|
2008
|
+
|
|
2009
|
+
Set the service on the host. `"assets"` is the default, and it is what a yuno
|
|
2010
|
+
names its `C_ASSETS`; an empty string turns the requests off:
|
|
2011
|
+
|
|
2012
|
+
```js
|
|
2013
|
+
gobj_create_service("#topics-mydb", "C_YUI_TREEDB_TOPICS", {
|
|
2014
|
+
gobj_remote_yuno: remote,
|
|
2015
|
+
treedb_name: "treedb_mydb",
|
|
2016
|
+
assets_service: "assets"
|
|
2017
|
+
}, gobj);
|
|
2018
|
+
```
|
|
2019
|
+
|
|
2020
|
+
The user needs the `read` permission of that service. The service is not the
|
|
2021
|
+
one the connection was opened for, so a user who is not root must also hold a
|
|
2022
|
+
role in it, or the ievent gate refuses to route the command there.
|
|
2023
|
+
|
|
1982
2024
|
### JSON viewer — `setup_json_pad`
|
|
1983
2025
|
|
|
1984
2026
|
`setup_json_pad(self)` opens a **blank JSON pad** (`C_YUI_JSON_PAD`) in a
|