@yuneta/gobj-ui 7.10.2 → 7.10.4

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
@@ -526,6 +526,45 @@ because the link can stay up and an answer still never land. A refresh
526
526
  re-pulls the page the reader is on rather than throwing them back to the
527
527
  first.
528
528
 
529
+ ### What a delete takes with it
530
+
531
+ A treedb delete is not one thing, and these views delete with **`force`**.
532
+ `force` on a node does not only remove it: its children are **UNLINKED** —
533
+ they survive, loose — and it is cleaned off its parents. So "delete this row"
534
+ can mean "detach eleven records from their only parent", and the question that
535
+ used to be asked, `are you sure`, said none of it.
536
+
537
+ The confirmation names what is going (the record's key, or how many) and adds
538
+ a line per thing at stake, **each only when there is something at stake** — a
539
+ loose record must not be dressed up as a dangerous one:
540
+
541
+ - *N children will be UNLINKED, not deleted*
542
+ - *It will be detached from M parents*
543
+
544
+ Counted off the record the table already has (`list_dict` fills the hook and
545
+ fkey columns), so asking costs no round trip. The counting is
546
+ `delete_impact.js`, pure and tested, because the shapes are the fiddly part: a
547
+ hook or fkey value arrives as a list of refs, a dict keyed by id, or a single
548
+ ref string — and a column can be BOTH hook and fkey, which counts on both
549
+ sides, because the delete does both things.
550
+
551
+ In the graph the node-delete popover carries the same two lines, and the
552
+ **unlink** popover carries the reassurance that is its whole point: *neither
553
+ record is deleted*. Next to a delete button painted the same red, that is not
554
+ obvious.
555
+
556
+ Three things this cost, worth knowing before composing any message from keys:
557
+
558
+ - `yui_shell_confirm_*` renders its message **as an i18n key**, so a composed
559
+ sentence can never be one. Pass DOM instead — the helper takes it.
560
+ - `createElement2` **trims text nodes**, so a `["span", {}, " "]` separator
561
+ vanishes and the question reads "BorrarDeveloper". Space with CSS.
562
+ - a **counted** word carries no `i18n` attribute: `yui_shell_show_modal` calls
563
+ `refresh_language()` on the dialog's content, which re-translates from the
564
+ key alone — without the count — and puts the plural back over the singular.
565
+ Nothing is lost, because a dialog with a backdrop never sees a language
566
+ change.
567
+
529
568
  ### Editing a topic table in place
530
569
 
531
570
  A writable scalar is editable in the table, in edition mode
@@ -8873,11 +8873,9 @@ function ac_map_on_load(gobj, event, kw, src) {
8873
8873
  function ac_refresh$6(gobj, event, kw, src) {
8874
8874
  let priv = gobj.priv;
8875
8875
  let devices = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "devices");
8876
- let map = priv.xmap;
8877
- if (map.isStyleLoaded()) {
8878
- const geojson_data = devices2geojson(gobj, devices);
8879
- map.getSource("devices").setData(geojson_data);
8880
- }
8876
+ const source = priv.xmap.getSource("devices");
8877
+ if (!source) return 0;
8878
+ source.setData(devices2geojson(gobj, devices));
8881
8879
  return 0;
8882
8880
  }
8883
8881
  /************************************************************
@@ -18539,7 +18537,7 @@ function build_delete_question(gobj, records) {
18539
18537
  String(impact.children)
18540
18538
  ], [
18541
18539
  "span",
18542
- { i18n: "children will be unlinked, not deleted" },
18540
+ {},
18543
18541
  (0, i18next.t)("children will be unlinked, not deleted", { count: impact.children })
18544
18542
  ]]
18545
18543
  ]);
@@ -18562,7 +18560,7 @@ function build_delete_question(gobj, records) {
18562
18560
  ],
18563
18561
  [
18564
18562
  "span",
18565
- { i18n: "parents" },
18563
+ {},
18566
18564
  (0, i18next.t)("parents", { count: impact.parents })
18567
18565
  ]
18568
18566
  ]
@@ -8868,11 +8868,9 @@ function ac_map_on_load(gobj, event, kw, src) {
8868
8868
  function ac_refresh$6(gobj, event, kw, src) {
8869
8869
  let priv = gobj.priv;
8870
8870
  let devices = gobj_read_attr(gobj, "devices");
8871
- let map = priv.xmap;
8872
- if (map.isStyleLoaded()) {
8873
- const geojson_data = devices2geojson(gobj, devices);
8874
- map.getSource("devices").setData(geojson_data);
8875
- }
8871
+ const source = priv.xmap.getSource("devices");
8872
+ if (!source) return 0;
8873
+ source.setData(devices2geojson(gobj, devices));
8876
8874
  return 0;
8877
8875
  }
8878
8876
  /************************************************************
@@ -18534,7 +18532,7 @@ function build_delete_question(gobj, records) {
18534
18532
  String(impact.children)
18535
18533
  ], [
18536
18534
  "span",
18537
- { i18n: "children will be unlinked, not deleted" },
18535
+ {},
18538
18536
  t("children will be unlinked, not deleted", { count: impact.children })
18539
18537
  ]]
18540
18538
  ]);
@@ -18557,7 +18555,7 @@ function build_delete_question(gobj, records) {
18557
18555
  ],
18558
18556
  [
18559
18557
  "span",
18560
- { i18n: "parents" },
18558
+ {},
18561
18559
  t("parents", { count: impact.parents })
18562
18560
  ]
18563
18561
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.10.2",
3
+ "version": "7.10.4",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
package/src/c_yui_map.js CHANGED
@@ -782,10 +782,24 @@ function ac_refresh(gobj, event, kw, src)
782
782
  let devices = gobj_read_attr(gobj, "devices");
783
783
 
784
784
  let map = priv.xmap;
785
- if (map.isStyleLoaded()) {
786
- const geojson_data = devices2geojson(gobj, devices);
787
- map.getSource('devices').setData(geojson_data);
785
+
786
+ /*
787
+ * Ask for the source, do not infer it from the style. 'devices' is added
788
+ * by load_devices() on the map 'load' event, which is a LATER milestone:
789
+ * isStyleLoaded() is already true one render frame before 'load' fires,
790
+ * and getSource() is undefined in that frame. Nothing is lost by
791
+ * skipping, load_devices() reads the same attr.
792
+ *
793
+ * Testing the style was also wrong the other way: it goes back to false
794
+ * while new tiles load, so every refresh during a pan or a zoom was
795
+ * silently dropped and the devices stopped moving.
796
+ */
797
+ const source = map.getSource('devices');
798
+ if(!source) {
799
+ return 0;
788
800
  }
801
+
802
+ source.setData(devices2geojson(gobj, devices));
789
803
  return 0;
790
804
  }
791
805
 
@@ -3071,11 +3071,16 @@ function build_delete_question(gobj, records)
3071
3071
  style: ROW}, [
3072
3072
  ["strong", {}, String(impact.children)],
3073
3073
  /* `count` picks the singular: i18next looks for the `_one`
3074
- * variant and falls back to the base key for the plural, so
3075
- * the validator still sees a key it can find. Safe against a
3076
- * language switch because this is a MODAL — a dialog with a
3077
- * backdrop never sees one; the language button is behind it. */
3078
- ["span", {i18n: "children will be unlinked, not deleted"},
3074
+ * variant and falls back to the base key for the plural, so the
3075
+ * validator still sees a key it can find.
3076
+ *
3077
+ * And NO `i18n` attribute on a counted word: refresh_language()
3078
+ * re-translates whatever carries one, calling t() WITHOUT the
3079
+ * count — which put the plural straight back over the singular.
3080
+ * A counted word cannot be re-translated from its key alone.
3081
+ * Nothing is lost: this is a MODAL, and a dialog with a backdrop
3082
+ * never sees a language change — the button is behind it. */
3083
+ ["span", {},
3079
3084
  t("children will be unlinked, not deleted", {count: impact.children})]
3080
3085
  ]]);
3081
3086
  }
@@ -3083,7 +3088,7 @@ function build_delete_question(gobj, records)
3083
3088
  lines.push(["p", {class: "DELETE_ASK_PARENTS", style: ROW}, [
3084
3089
  ["span", {i18n: "it will be detached from"}, t("it will be detached from")],
3085
3090
  ["strong", {}, String(impact.parents)],
3086
- ["span", {i18n: "parents"}, t("parents", {count: impact.parents})]
3091
+ ["span", {}, t("parents", {count: impact.parents})]
3087
3092
  ]]);
3088
3093
  }
3089
3094