@yuneta/gobj-ui 7.23.66 → 7.23.68

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.
@@ -1,5 +1,5 @@
1
1
  import * as gobj_js from "@yuneta/gobj-js";
2
- import { SDATA, SDATA_END, clean_name, createElement2, createOneHtml, create_template_record, data_type_t, debounce, duplicate_objects, empty_string, escapeHtml, event_flag_t, gclass_create, gclass_find_by_name, gclass_flag_t, getPositionRelativeToBody, gobj_bottom_gobj, gobj_change_state, gobj_command, gobj_create, gobj_create_pure_child, gobj_create_service, gobj_current_state, gobj_destroy, gobj_find_child, gobj_find_service, gobj_full_name, gobj_gclass_name, gobj_is_destroying, gobj_is_playing, gobj_is_pure_child, gobj_is_running, gobj_is_service, gobj_is_volatil, gobj_match_children, gobj_name, gobj_parent, gobj_post_event, gobj_publish_event, gobj_read_attr, gobj_read_bool_attr, gobj_read_integer_attr, gobj_read_pointer_attr, gobj_read_str_attr, gobj_save_persistent_attrs, gobj_send_event, gobj_set_trace_machine_format, gobj_short_name, gobj_start, gobj_start_tree, gobj_stop, gobj_stop_children, gobj_subscribe_event, gobj_unsubscribe_event, gobj_write_attr, gobj_write_bool_attr, gobj_write_integer_attr, gobj_write_str_attr, gobj_yuno, gobj_yuno_name, is_array, is_boolean, is_date, is_gobj, is_null, is_number, is_object, is_string, json_deep_copy, json_object_size, json_object_update, json_object_update_missing, json_size, kw_clone_by_keys, kw_flag_t, kw_get_dict, kw_get_dict_value, kw_get_int, kw_get_local_storage_value, kw_get_str, kw_has_key, kw_set_dict_value, kw_set_local_storage_value, kwid_find_one_record, kwid_get_ids, kwid_new_dict, log_error, log_warning, msg_iev_get_stack, parseBoolean, parseSVG, refresh_language, safeSrc, sdata_flag_t, set_console_log_enabled, set_log_callback, sprintf, str_in_list, template_get_field_desc, trace_msg, treedb_decoder_fkey, treedb_encoder_fkey, treedb_get_field_desc, treedb_hook_data_size } from "@yuneta/gobj-js";
2
+ import { SDATA, SDATA_END, clean_name, createElement2, createOneHtml, create_template_record, data_type_t, debounce, delete_from_list, duplicate_objects, empty_string, escapeHtml, event_flag_t, gclass_create, gclass_find_by_name, gclass_flag_t, getPositionRelativeToBody, gobj_bottom_gobj, gobj_change_state, gobj_command, gobj_create, gobj_create_pure_child, gobj_create_service, gobj_current_state, gobj_destroy, gobj_find_child, gobj_find_service, gobj_full_name, gobj_gclass_name, gobj_is_destroying, gobj_is_playing, gobj_is_pure_child, gobj_is_running, gobj_is_service, gobj_is_volatil, gobj_match_children, gobj_name, gobj_parent, gobj_post_event, gobj_publish_event, gobj_read_attr, gobj_read_bool_attr, gobj_read_integer_attr, gobj_read_pointer_attr, gobj_read_str_attr, gobj_save_persistent_attrs, gobj_send_event, gobj_set_trace_machine_format, gobj_short_name, gobj_start, gobj_start_tree, gobj_stop, gobj_stop_children, gobj_subscribe_event, gobj_unsubscribe_event, gobj_write_attr, gobj_write_bool_attr, gobj_write_integer_attr, gobj_write_str_attr, gobj_yuno, gobj_yuno_name, is_array, is_boolean, is_date, is_gobj, is_null, is_number, is_object, is_string, json_deep_copy, json_object_size, json_object_update, json_object_update_missing, json_size, kw_clone_by_keys, kw_flag_t, kw_get_dict, kw_get_dict_value, kw_get_int, kw_get_local_storage_value, kw_get_str, kw_has_key, kw_set_dict_value, kw_set_local_storage_value, kwid_find_one_record, kwid_get_ids, kwid_new_dict, log_error, log_warning, msg_iev_get_stack, parseBoolean, parseSVG, refresh_language, safeSrc, sdata_flag_t, set_console_log_enabled, set_log_callback, sprintf, str_in_list, template_get_field_desc, trace_msg, treedb_decoder_fkey, treedb_encoder_fkey, treedb_get_field_desc, treedb_hook_data_size } from "@yuneta/gobj-js";
3
3
  import i18next, { t } from "i18next";
4
4
  import TomSelect from "tom-select";
5
5
  import { createJSONEditor } from "vanilla-jsoneditor";
@@ -26909,17 +26909,26 @@ function parents_of(descs, desc, record) {
26909
26909
  * topics: [topic_name, ...] topics with records, in desc order
26910
26910
  * }
26911
26911
  ************************************************************/
26912
- function fold_build_model(descs, records) {
26912
+ function fold_build_model(descs, records, opts) {
26913
26913
  let nodes = /* @__PURE__ */ new Map();
26914
26914
  let groups = /* @__PURE__ */ new Map();
26915
26915
  let topics = [];
26916
26916
  descs = is_object(descs) ? descs : {};
26917
26917
  records = is_object(records) ? records : {};
26918
+ opts = is_object(opts) ? opts : {};
26919
+ let hidden = new Set(is_array(opts.hidden_topics) ? opts.hidden_topics : []);
26920
+ let loose_shown = new Set(is_array(opts.loose_topics) ? opts.loose_topics : []);
26921
+ let main_topic = opts.main_topic || fold_main_topic(descs);
26922
+ if (main_topic && (!descs[main_topic] || hidden.has(main_topic))) main_topic = "";
26923
+ let linked = fold_linked_topics(descs, main_topic);
26924
+ let totals = {};
26918
26925
  for (let topic_name of Object.keys(descs)) {
26919
26926
  if (topic_name.substring(0, 2) === "__") continue;
26920
26927
  descs[topic_name];
26921
26928
  let list = records[topic_name];
26922
26929
  if (!is_array(list)) continue;
26930
+ totals[topic_name] = list.length;
26931
+ if (hidden.has(topic_name)) continue;
26923
26932
  topics.push(topic_name);
26924
26933
  for (let i = 0; i < list.length; i++) {
26925
26934
  let record = list[i];
@@ -26948,21 +26957,100 @@ function fold_build_model(descs, records) {
26948
26957
  }
26949
26958
  for (let node of nodes.values()) for (let hook of Object.keys(node.hooks)) groups.set(fold_group_key(node.key, hook), node.hooks[hook]);
26950
26959
  let roots = {};
26951
- for (let topic_name of topics) roots[topic_name] = [];
26952
- for (let node of nodes.values()) if (node.parents.length === 0) roots[node.topic_name].push(node.key);
26960
+ let loose = {};
26961
+ for (let topic_name of topics) {
26962
+ roots[topic_name] = [];
26963
+ loose[topic_name] = [];
26964
+ }
26965
+ for (let node of nodes.values()) {
26966
+ if (node.parents.length > 0) continue;
26967
+ let t = node.topic_name;
26968
+ if (main_topic && t !== main_topic && linked.has(t)) {
26969
+ loose[t].push(node.key);
26970
+ if (loose_shown.has(t)) roots[t].push(node.key);
26971
+ } else roots[t].push(node.key);
26972
+ }
26953
26973
  let reached = reach_from(nodes, [].concat(...Object.values(roots)));
26954
- for (let node of nodes.values()) if (!reached.has(node.key)) {
26955
- roots[node.topic_name].push(node.key);
26974
+ for (let node of nodes.values()) {
26975
+ if (reached.has(node.key)) continue;
26976
+ let t = node.topic_name;
26977
+ if (main_topic && t !== main_topic && linked.has(t)) {
26978
+ if (node.parents.length > 0) loose[t].push(node.key);
26979
+ if (!loose_shown.has(t)) continue;
26980
+ }
26981
+ roots[t].push(node.key);
26956
26982
  for (let k of reach_from(nodes, [node.key])) reached.add(k);
26957
26983
  }
26958
26984
  for (let topic_name of topics) if (roots[topic_name].length > 0) groups.set(fold_root_group_key(topic_name), roots[topic_name]);
26959
26985
  return {
26960
26986
  nodes,
26961
26987
  groups,
26962
- topics
26988
+ topics,
26989
+ totals,
26990
+ hidden,
26991
+ main_topic,
26992
+ linked,
26993
+ loose,
26994
+ loose_shown
26963
26995
  };
26964
26996
  }
26965
26997
  /************************************************************
26998
+ * The topic the schema hangs the others from: the one whose hooks
26999
+ * reach the most OTHER topics, a self-referent hook breaking a tie
27000
+ * (a tree of places over a flat list of groups), schema order
27001
+ * breaking the rest. "" when no topic reaches another -- a treedb of
27002
+ * unrelated lists has no trunk, and every topic is a tree of its own.
27003
+ ************************************************************/
27004
+ function fold_main_topic(descs) {
27005
+ descs = is_object(descs) ? descs : {};
27006
+ let best = "";
27007
+ let best_score = 0;
27008
+ let best_self = false;
27009
+ for (let topic_name of Object.keys(descs)) {
27010
+ if (topic_name.substring(0, 2) === "__") continue;
27011
+ let reach = hook_targets(descs, topic_name);
27012
+ let self = reach.has(topic_name);
27013
+ reach.delete(topic_name);
27014
+ let score = reach.size;
27015
+ if (score === 0) continue;
27016
+ if (score > best_score || score === best_score && self && !best_self) {
27017
+ best = topic_name;
27018
+ best_score = score;
27019
+ best_self = self;
27020
+ }
27021
+ }
27022
+ return best;
27023
+ }
27024
+ function hook_targets(descs, topic_name) {
27025
+ let out = /* @__PURE__ */ new Set();
27026
+ let desc = descs[topic_name];
27027
+ if (!desc || desc.node_treedb_type === "extended") return out;
27028
+ let cols = is_array(desc.cols) ? desc.cols : [];
27029
+ for (let col of cols) {
27030
+ if (!is_object(col.hook) || !is_array(col.flag) || col.flag.indexOf("hook") < 0) continue;
27031
+ for (let child of Object.keys(col.hook)) if (child.substring(0, 2) !== "__" && descs[child]) out.add(child);
27032
+ }
27033
+ return out;
27034
+ }
27035
+ /************************************************************
27036
+ * The topics the schema hangs from `main_topic`, main included:
27037
+ * reached by following hooks from it. A record of one of these
27038
+ * with no parent is LOOSE; a topic outside the set is its own tree.
27039
+ * Empty when there is no main topic.
27040
+ ************************************************************/
27041
+ function fold_linked_topics(descs, main_topic) {
27042
+ let linked = /* @__PURE__ */ new Set();
27043
+ if (!main_topic || !is_object(descs) || !descs[main_topic]) return linked;
27044
+ let queue = [main_topic];
27045
+ while (queue.length) {
27046
+ let t = queue.shift();
27047
+ if (linked.has(t)) continue;
27048
+ linked.add(t);
27049
+ for (let child of hook_targets(descs, t)) if (!linked.has(child)) queue.push(child);
27050
+ }
27051
+ return linked;
27052
+ }
27053
+ /************************************************************
26966
27054
  * Everything reachable downwards from `start`, cycles included.
26967
27055
  ************************************************************/
26968
27056
  function reach_from(nodes, start) {
@@ -26993,7 +27081,10 @@ function fold_group_total(model, group_key) {
26993
27081
  }
26994
27082
  function fold_group_shown(model, state, group_key) {
26995
27083
  let total = fold_group_total(model, group_key);
26996
- let n = state.shown.get(group_key) || 0;
27084
+ let n;
27085
+ if (state.shown.has(group_key)) n = state.shown.get(group_key);
27086
+ else if (group_key.charAt(0) === "|") n = state.page_size;
27087
+ else n = 0;
26997
27088
  return Math.min(n, total);
26998
27089
  }
26999
27090
  function fold_is_open(state, group_key) {
@@ -54099,6 +54190,9 @@ var attrs_table$4 = [
54099
54190
  SDATA(data_type_t.DTP_STRING, "fkey_port_position", 0, "top", "Fkey port position"),
54100
54191
  SDATA(data_type_t.DTP_INTEGER, "expand_depth", 0, 2, "Levels open when a treedb loads: 1 = the roots alone, 2 = the roots and their children. Every open hook shows its first page"),
54101
54192
  SDATA(data_type_t.DTP_INTEGER, "fold_page_size", 0, 24, "Children of one hook shown per page; the `+N` chip after the page opens the next one"),
54193
+ SDATA(data_type_t.DTP_LIST, "hidden_topics", 0, "[]", "Topics left out of the tree: no card, no pill counts them, no edge reaches them"),
54194
+ SDATA(data_type_t.DTP_STRING, "main_topic", 0, "", "The topic the tree hangs from; empty = deduced (the one whose hooks reach the most others). Its parentless records are the roots; a parentless record of a topic linked to it is LOOSE and shown only on request"),
54195
+ SDATA(data_type_t.DTP_LIST, "loose_topics", 0, "[]", "Topics whose loose records (no parent, in a topic the schema hangs from the main one) are shown as roots"),
54102
54196
  SDATA(data_type_t.DTP_BOOLEAN, "confirm_delete_node", 0, true, "Ask confirmation before deleting a node"),
54103
54197
  SDATA(data_type_t.DTP_BOOLEAN, "confirm_unlink_edge", 0, true, "Ask confirmation before unlinking an edge"),
54104
54198
  SDATA(data_type_t.DTP_STRING, "wide", 0, "40px", "Height of header"),
@@ -54167,12 +54261,17 @@ var PRIVATE_DATA$4 = {
54167
54261
  selection_mode: false,
54168
54262
  _selected_paint_ids: [],
54169
54263
  _pending_focus_topic: null,
54264
+ _pending_focus_all: false,
54265
+ _find_hidden_matches: 0,
54170
54266
  _pending_find: null,
54171
54267
  _layout_asked: "",
54172
54268
  _nodes_total: 0,
54173
54269
  _nodes_placed: 0,
54174
54270
  expand_depth: 2,
54175
54271
  fold_page_size: 24,
54272
+ hidden_topics: null,
54273
+ main_topic: "",
54274
+ loose_topics: null,
54176
54275
  _fold_model: null,
54177
54276
  _fold_state: null,
54178
54277
  _fold_listener: null,
@@ -55656,10 +55755,11 @@ async function graph_fit_selection(gobj, ids) {
55656
55755
  * once the data loads (see ac_load_data). Guarded end-to-end — a
55657
55756
  * missing G6 API or an unknown topic logs and no-ops, never throws.
55658
55757
  ************************************************************/
55659
- function graph_focus_topic(gobj, topic) {
55758
+ function graph_focus_topic(gobj, topic, reveal_all) {
55660
55759
  let priv = gobj.priv;
55661
55760
  if (!priv.graph || !priv.graph_rendered || !priv._fold_model) {
55662
55761
  priv._pending_focus_topic = topic;
55762
+ priv._pending_focus_all = !!reveal_all;
55663
55763
  return;
55664
55764
  }
55665
55765
  let model = priv._fold_model;
@@ -55672,7 +55772,7 @@ function graph_focus_topic(gobj, topic) {
55672
55772
  let revealed = 0;
55673
55773
  for (let key of keys) {
55674
55774
  if (visible.has(key)) continue;
55675
- if (revealed >= state.page_size) break;
55775
+ if (!reveal_all && revealed >= state.page_size) break;
55676
55776
  fold_reveal(model, state, key);
55677
55777
  revealed++;
55678
55778
  }
@@ -55747,23 +55847,26 @@ function graph_find_nodes(gobj, term) {
55747
55847
  let model = priv._fold_model;
55748
55848
  let state = priv._fold_state;
55749
55849
  let keys = [];
55850
+ let hidden_matches = 0;
55750
55851
  if (!empty_string(term)) {
55751
55852
  let needle = String(term).toLowerCase();
55752
- for (let node of model.nodes.values()) {
55753
- let record = node.record || {};
55853
+ let matches = (topic_name, record) => {
55754
55854
  let label = "";
55755
55855
  try {
55756
- label = node_label(priv.descs[node.topic_name] || {}, record) || "";
55856
+ label = node_label(priv.descs[topic_name] || {}, record) || "";
55757
55857
  } catch (e) {
55758
55858
  label = "";
55759
55859
  }
55760
- if ([
55860
+ return [
55761
55861
  label,
55762
55862
  record.id,
55763
- node.topic_name
55764
- ].filter((v) => typeof v === "string").join(" ").toLowerCase().includes(needle)) keys.push(node.key);
55765
- }
55863
+ topic_name
55864
+ ].filter((v) => typeof v === "string").join(" ").toLowerCase().includes(needle);
55865
+ };
55866
+ for (let node of model.nodes.values()) if (matches(node.topic_name, node.record || {})) keys.push(node.key);
55867
+ for (let topic_name of model.hidden) for (let record of priv.records[topic_name] || []) if (is_object(record) && matches(topic_name, record)) hidden_matches++;
55766
55868
  }
55869
+ priv._find_hidden_matches = hidden_matches;
55767
55870
  let visible = fold_visible_set(model, state);
55768
55871
  let revealed = 0;
55769
55872
  for (let key of keys) {
@@ -58694,7 +58797,11 @@ function uninstall_fold_listener(gobj) {
58694
58797
  ************************************************************/
58695
58798
  function rebuild_fold_model(gobj) {
58696
58799
  let priv = gobj.priv;
58697
- priv._fold_model = fold_build_model(priv.descs || {}, priv.records || {});
58800
+ priv._fold_model = fold_build_model(priv.descs || {}, priv.records || {}, {
58801
+ hidden_topics: gobj_read_attr(gobj, "hidden_topics") || [],
58802
+ main_topic: gobj_read_str_attr(gobj, "main_topic") || "",
58803
+ loose_topics: gobj_read_attr(gobj, "loose_topics") || []
58804
+ });
58698
58805
  if (!priv._fold_state) priv._fold_state = fold_new_state(gobj_read_integer_attr(gobj, "fold_page_size"));
58699
58806
  if (!priv._pill_sig) priv._pill_sig = /* @__PURE__ */ new Map();
58700
58807
  }
@@ -58756,8 +58863,47 @@ async function reconcile_fold_now(gobj, opts) {
58756
58863
  } finally {
58757
58864
  history_resume(gobj);
58758
58865
  }
58866
+ publish_legend_state(gobj, visible);
58759
58867
  return changed;
58760
58868
  }
58869
+ /************************************************************
58870
+ * What the legend has to say, published after every reconcile:
58871
+ * one entry per topic of the treedb, hidden ones included, with
58872
+ * its colour, how many records it has, how many are on screen,
58873
+ * how many are LOOSE, and the flags -- plus which topic is the
58874
+ * main one and whether it was deduced or chosen. The host draws
58875
+ * the strip from this and nothing else; the engine is the truth.
58876
+ ************************************************************/
58877
+ function publish_legend_state(gobj, visible) {
58878
+ let priv = gobj.priv;
58879
+ let model = priv._fold_model;
58880
+ if (!model || !priv.descs) return;
58881
+ let on_screen = {};
58882
+ for (let key of visible) {
58883
+ let node = model.nodes.get(key);
58884
+ if (node) on_screen[node.topic_name] = (on_screen[node.topic_name] || 0) + 1;
58885
+ }
58886
+ let topics = [];
58887
+ for (const [topic_name, desc] of Object.entries(priv.descs)) {
58888
+ if (topic_name.substring(0, 2) === "__" || !desc) continue;
58889
+ let loose = model.loose[topic_name] || [];
58890
+ topics.push({
58891
+ topic: topic_name,
58892
+ color: desc.color || "",
58893
+ total: model.totals[topic_name] || 0,
58894
+ visible: on_screen[topic_name] || 0,
58895
+ loose: loose.length,
58896
+ loose_shown: model.loose_shown.has(topic_name),
58897
+ hidden: model.hidden.has(topic_name),
58898
+ linked: model.linked.has(topic_name)
58899
+ });
58900
+ }
58901
+ gobj_publish_event(gobj, "EV_LEGEND_STATE", {
58902
+ main_topic: model.main_topic,
58903
+ main_chosen: !!gobj_read_str_attr(gobj, "main_topic"),
58904
+ topics
58905
+ });
58906
+ }
58761
58907
  async function reconcile_fold_apply(gobj, opts, visible) {
58762
58908
  let priv = gobj.priv;
58763
58909
  let graph = priv.graph;
@@ -59031,8 +59177,10 @@ function ac_load_data(gobj, event, kw, src) {
59031
59177
  sync_history_plugin(gobj);
59032
59178
  if (priv._pending_focus_topic !== null) {
59033
59179
  let ft = priv._pending_focus_topic;
59180
+ let all = priv._pending_focus_all;
59034
59181
  priv._pending_focus_topic = null;
59035
- graph_focus_topic(gobj, ft);
59182
+ priv._pending_focus_all = false;
59183
+ graph_focus_topic(gobj, ft, all);
59036
59184
  }
59037
59185
  if (priv._pending_find !== null) {
59038
59186
  let term = priv._pending_find;
@@ -59348,7 +59496,7 @@ function ac_zoom_selection(gobj, event, kw, src) {
59348
59496
  return 0;
59349
59497
  }
59350
59498
  function ac_focus_topic(gobj, event, kw, src) {
59351
- graph_focus_topic(gobj, kw && kw.topic);
59499
+ graph_focus_topic(gobj, kw && kw.topic, !!(kw && kw.reveal === "all"));
59352
59500
  return 0;
59353
59501
  }
59354
59502
  /************************************************************
@@ -59431,6 +59579,43 @@ function ac_collapse_all$1(gobj, event, kw, src) {
59431
59579
  return 0;
59432
59580
  }
59433
59581
  /************************************************************
59582
+ * The legend's three settings, from the host, which persists
59583
+ * them. Each rebuilds the tree; the fold state is kept -- it is
59584
+ * keyed by group, and a group that is gone is never read -- except
59585
+ * for a new MAIN topic, whose roots are other roots: the tree
59586
+ * opens again at `expand_depth`.
59587
+ ************************************************************/
59588
+ function ac_set_hidden_topics(gobj, event, kw, src) {
59589
+ let priv = gobj.priv;
59590
+ let topics = kw && is_array(kw.topics) ? kw.topics : [];
59591
+ gobj_write_attr(gobj, "hidden_topics", topics);
59592
+ if (!priv._fold_model) return 0;
59593
+ rebuild_fold_model(gobj);
59594
+ reconcile_fold(gobj, {});
59595
+ return 0;
59596
+ }
59597
+ function ac_set_main_topic(gobj, event, kw, src) {
59598
+ let priv = gobj.priv;
59599
+ gobj_write_str_attr(gobj, "main_topic", kw && kw.topic || "");
59600
+ if (!priv._fold_model) return 0;
59601
+ rebuild_fold_model(gobj);
59602
+ fold_expand_to_depth(priv._fold_model, priv._fold_state, gobj_read_integer_attr(gobj, "expand_depth"));
59603
+ reconcile_fold(gobj, {
59604
+ relayout: true,
59605
+ fit: true
59606
+ });
59607
+ return 0;
59608
+ }
59609
+ function ac_set_loose_topics(gobj, event, kw, src) {
59610
+ let priv = gobj.priv;
59611
+ let topics = kw && is_array(kw.topics) ? kw.topics : [];
59612
+ gobj_write_attr(gobj, "loose_topics", topics);
59613
+ if (!priv._fold_model) return 0;
59614
+ rebuild_fold_model(gobj);
59615
+ reconcile_fold(gobj, {});
59616
+ return 0;
59617
+ }
59618
+ /************************************************************
59434
59619
  * Tell whoever asked how many nodes the term matched. The count is
59435
59620
  * the answer to the question the box asks; without it "nothing moved"
59436
59621
  * and "nothing matched" look the same.
@@ -59438,7 +59623,8 @@ function ac_collapse_all$1(gobj, event, kw, src) {
59438
59623
  function publish_find_result(gobj, term, matches) {
59439
59624
  gobj_publish_event(gobj, "EV_FIND_RESULT", {
59440
59625
  term,
59441
- matches
59626
+ matches,
59627
+ hidden_matches: gobj.priv._find_hidden_matches || 0
59442
59628
  });
59443
59629
  }
59444
59630
  /************************************************************
@@ -59904,6 +60090,21 @@ function create_gclass$4(gclass_name) {
59904
60090
  ac_collapse_all$1,
59905
60091
  null
59906
60092
  ],
60093
+ [
60094
+ "EV_SET_HIDDEN_TOPICS",
60095
+ ac_set_hidden_topics,
60096
+ null
60097
+ ],
60098
+ [
60099
+ "EV_SET_MAIN_TOPIC",
60100
+ ac_set_main_topic,
60101
+ null
60102
+ ],
60103
+ [
60104
+ "EV_SET_LOOSE_TOPICS",
60105
+ ac_set_loose_topics,
60106
+ null
60107
+ ],
59907
60108
  [
59908
60109
  "EV_CENTER",
59909
60110
  ac_center,
@@ -60005,6 +60206,10 @@ function create_gclass$4(gclass_name) {
60005
60206
  ["EV_SHOW_MORE", 0],
60006
60207
  ["EV_EXPAND_ALL", 0],
60007
60208
  ["EV_COLLAPSE_ALL", 0],
60209
+ ["EV_SET_HIDDEN_TOPICS", 0],
60210
+ ["EV_SET_MAIN_TOPIC", 0],
60211
+ ["EV_SET_LOOSE_TOPICS", 0],
60212
+ ["EV_LEGEND_STATE", event_flag_t.EVF_OUTPUT_EVENT],
60008
60213
  ["EV_CENTER", 0],
60009
60214
  ["EV_FULLSCREEN", 0],
60010
60215
  ["EV_SET_LAYOUT", 0],
@@ -60066,6 +60271,9 @@ var attrs_table$3 = [
60066
60271
  SDATA(data_type_t.DTP_INTEGER, "fold_page_size", 0, 24, "Children of one hook shown per page in the graph; a `+N` chip opens the next page. Forwarded to the G6 child"),
60067
60272
  SDATA(data_type_t.DTP_STRING, "operation_mode", sdata_flag_t.SDF_PERSIST, "reading", "Current operation mode (internal behaviour or role). Changed by the user trough the gui."),
60068
60273
  SDATA(data_type_t.DTP_STRING, "layout", sdata_flag_t.SDF_PERSIST, "", "Current graph layout. User preference. Changed by the user through the gui."),
60274
+ SDATA(data_type_t.DTP_LIST, "hidden_topics", sdata_flag_t.SDF_PERSIST, "[]", "Topics hidden from the graph (legend). User preference, per treedb"),
60275
+ SDATA(data_type_t.DTP_STRING, "main_topic", sdata_flag_t.SDF_PERSIST, "", "The topic the tree hangs from; empty = deduced by the graph. User preference, per treedb"),
60276
+ SDATA(data_type_t.DTP_LIST, "loose_topics", sdata_flag_t.SDF_PERSIST, "[]", "Topics whose LOOSE records (no parent) are shown. User preference, per treedb"),
60069
60277
  SDATA(data_type_t.DTP_POINTER, "gobj_remote_yuno", 0, null, "Remote Yuno to request data"),
60070
60278
  SDATA(data_type_t.DTP_STRING, "treedb_name", 0, null, "Remote service treedb name"),
60071
60279
  SDATA(data_type_t.DTP_DICT, "descs", 0, null, "Descriptions of topics obtained"),
@@ -60107,6 +60315,7 @@ var PRIVATE_DATA$3 = {
60107
60315
  operation_mode: null,
60108
60316
  layout: null,
60109
60317
  _topics_subscribed: {},
60318
+ _legend_state: null,
60110
60319
  _links_subscribed: false,
60111
60320
  is_pinhold_window: false
60112
60321
  };
@@ -60139,7 +60348,10 @@ function mt_create$3(gobj) {
60139
60348
  hook_port_position: "bottom",
60140
60349
  fkey_port_position: "top",
60141
60350
  expand_depth: gobj_read_integer_attr(gobj, "expand_depth"),
60142
- fold_page_size: gobj_read_integer_attr(gobj, "fold_page_size")
60351
+ fold_page_size: gobj_read_integer_attr(gobj, "fold_page_size"),
60352
+ hidden_topics: gobj_read_attr(gobj, "hidden_topics") || [],
60353
+ main_topic: gobj_read_str_attr(gobj, "main_topic") || "",
60354
+ loose_topics: gobj_read_attr(gobj, "loose_topics") || []
60143
60355
  }, gobj);
60144
60356
  populate_nodes_tree_options(gobj);
60145
60357
  if (priv.with_treedb_tables) {}
@@ -60206,8 +60418,8 @@ function build_ui$3(gobj) {
60206
60418
  [
60207
60419
  "div",
60208
60420
  {
60209
- class: "GRAPH_LEGEND is-hidden is-flex-grow-0",
60210
- style: "display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; padding:.35rem .5rem;"
60421
+ class: "GRAPH_LEGEND is-flex-grow-0",
60422
+ style: "display:flex; flex-wrap:nowrap; align-items:center; gap:.35rem; padding:.3rem .5rem; overflow-x:auto; min-height:2.2rem;"
60211
60423
  },
60212
60424
  []
60213
60425
  ],
@@ -60398,29 +60610,6 @@ function make_toolbar(gobj) {
60398
60610
  } }
60399
60611
  ],
60400
60612
  ...yui_graph_fold_items(gobj, gobj_read_str_attr(gobj, "wide")),
60401
- [
60402
- "button",
60403
- {
60404
- class: "GRAPH_LEGEND_BTN button ml-2",
60405
- title: t("legend"),
60406
- "aria-label": t("legend"),
60407
- "data-i18n-title": "legend",
60408
- "data-i18n-aria-label": "legend"
60409
- },
60410
- [["i", { class: "yi-square" }], [
60411
- "span",
60412
- {
60413
- class: "is-hidden-mobile",
60414
- style: "padding-left:5px;",
60415
- i18n: "legend"
60416
- },
60417
- "legend"
60418
- ]],
60419
- { click: (evt) => {
60420
- evt.stopPropagation();
60421
- gobj_send_event(gobj, "EV_TOGGLE_LEGEND", {}, gobj);
60422
- } }
60423
- ],
60424
60613
  [
60425
60614
  "button",
60426
60615
  {
@@ -61450,55 +61639,185 @@ function refresh_legend(gobj) {
61450
61639
  if (!$container) return;
61451
61640
  let $legend = $container.querySelector(".GRAPH_LEGEND");
61452
61641
  if (!$legend) return;
61453
- let descs = priv.gobj_nodes_tree ? gobj_read_attr(priv.gobj_nodes_tree, "descs") : null;
61642
+ let state = priv._legend_state;
61454
61643
  $legend.textContent = "";
61455
- if (!descs) return;
61456
- for (const [topic_name, desc] of Object.entries(descs)) {
61457
- if (topic_name.substring(0, 2) === "__") continue;
61458
- if (!desc || !desc.color) continue;
61644
+ if (!state || !is_array(state.topics)) return;
61645
+ let topics = state.topics.slice().sort((a, b) => {
61646
+ return (a.topic === state.main_topic ? 0 : 1) - (b.topic === state.main_topic ? 0 : 1);
61647
+ });
61648
+ for (let entry of topics) {
61649
+ let topic_name = entry.topic;
61650
+ let is_main = topic_name === state.main_topic;
61459
61651
  let focused = priv.focus_topic === topic_name;
61460
- let $item = createElement2([
61652
+ let hidden = !!entry.hidden;
61653
+ let controls = [];
61654
+ controls.push(["span", {
61655
+ class: "GRAPH_LEGEND_SWATCH",
61656
+ style: `display:inline-block; width:.8rem; height:.8rem; border-radius:3px; margin-right:.35rem; flex:0 0 auto; background:${entry.color || "#94a3b8"}; border:1px solid rgba(0,0,0,.25);` + (hidden ? "opacity:.35;" : "")
61657
+ }], [
61658
+ "span",
61659
+ {
61660
+ class: "GRAPH_LEGEND_NAME",
61661
+ style: hidden ? "text-decoration:line-through; opacity:.6;" : ""
61662
+ },
61663
+ topic_name
61664
+ ], [
61665
+ "span",
61666
+ {
61667
+ class: "GRAPH_LEGEND_COUNT has-text-grey",
61668
+ style: "margin-left:.35rem; font-size:.8em;"
61669
+ },
61670
+ hidden ? `${entry.total}` : `${entry.visible}/${entry.total}`
61671
+ ]);
61672
+ let body_attrs = {
61673
+ class: "GRAPH_LEGEND_ITEM button is-small" + (focused ? " is-primary is-light" : "") + (is_main ? " GRAPH_LEGEND_MAIN" : ""),
61674
+ type: "button",
61675
+ style: "gap:0; flex:0 0 auto;",
61676
+ title: is_main ? t("main topic") : hidden ? t("show topic") : t("hide topic"),
61677
+ "aria-label": topic_name,
61678
+ "aria-pressed": hidden ? "false" : "true"
61679
+ };
61680
+ if (is_main) body_attrs.disabled = "disabled";
61681
+ let $body = createElement2([
61682
+ "button",
61683
+ body_attrs,
61684
+ controls,
61685
+ { click: (evt) => {
61686
+ evt.stopPropagation();
61687
+ gobj_send_event(gobj, "EV_LEGEND_TOPIC", {
61688
+ topic: topic_name,
61689
+ action: "toggle"
61690
+ }, gobj);
61691
+ } }
61692
+ ]);
61693
+ let extras = [];
61694
+ if (is_main && state.main_chosen) extras.push([
61695
+ "button",
61696
+ {
61697
+ class: "GRAPH_LEGEND_STAR button is-small is-warning is-light",
61698
+ type: "button",
61699
+ style: "padding:0 .4rem;",
61700
+ title: t("main topic"),
61701
+ "data-i18n-title": "main topic",
61702
+ "aria-label": t("main topic"),
61703
+ "aria-pressed": "true"
61704
+ },
61705
+ "★",
61706
+ { click: (evt) => {
61707
+ evt.stopPropagation();
61708
+ gobj_send_event(gobj, "EV_LEGEND_TOPIC", {
61709
+ topic: "",
61710
+ action: "main"
61711
+ }, gobj);
61712
+ } }
61713
+ ]);
61714
+ else if (is_main) extras.push([
61715
+ "span",
61716
+ {
61717
+ class: "GRAPH_LEGEND_STAR button is-small is-static",
61718
+ style: "padding:0 .4rem;",
61719
+ title: t("main topic"),
61720
+ "data-i18n-title": "main topic"
61721
+ },
61722
+ "★"
61723
+ ]);
61724
+ else if (!hidden) extras.push([
61461
61725
  "button",
61462
61726
  {
61463
- class: "GRAPH_LEGEND_ITEM button is-small" + (focused ? " is-primary is-light" : ""),
61464
- title: topic_name,
61465
- "aria-label": topic_name,
61727
+ class: "GRAPH_LEGEND_STAR button is-small",
61728
+ type: "button",
61729
+ style: "padding:0 .4rem;",
61730
+ title: t("main topic"),
61731
+ "data-i18n-title": "main topic",
61732
+ "aria-label": t("main topic")
61733
+ },
61734
+ "☆",
61735
+ { click: (evt) => {
61736
+ evt.stopPropagation();
61737
+ gobj_send_event(gobj, "EV_LEGEND_TOPIC", {
61738
+ topic: topic_name,
61739
+ action: "main"
61740
+ }, gobj);
61741
+ } }
61742
+ ]);
61743
+ if (!hidden && entry.linked && entry.loose > 0) extras.push([
61744
+ "button",
61745
+ {
61746
+ class: "GRAPH_LEGEND_LOOSE button is-small" + (entry.loose_shown ? " is-warning is-light" : ""),
61747
+ type: "button",
61748
+ style: "padding:0 .45rem;",
61749
+ title: t("loose records"),
61750
+ "data-i18n-title": "loose records",
61751
+ "aria-label": t("loose records"),
61752
+ "aria-pressed": entry.loose_shown ? "true" : "false"
61753
+ },
61754
+ `+${entry.loose}`,
61755
+ { click: (evt) => {
61756
+ evt.stopPropagation();
61757
+ gobj_send_event(gobj, "EV_LEGEND_TOPIC", {
61758
+ topic: topic_name,
61759
+ action: "loose"
61760
+ }, gobj);
61761
+ } }
61762
+ ]);
61763
+ if (!hidden) extras.push([
61764
+ "button",
61765
+ {
61766
+ class: "GRAPH_LEGEND_FOCUS button is-small" + (focused ? " is-primary is-light" : ""),
61767
+ type: "button",
61768
+ style: "padding:0 .4rem;",
61769
+ title: t("highlight topic"),
61770
+ "data-i18n-title": "highlight topic",
61771
+ "aria-label": t("highlight topic"),
61466
61772
  "aria-pressed": focused ? "true" : "false"
61467
61773
  },
61468
- [["span", {
61469
- class: "GRAPH_LEGEND_SWATCH",
61470
- style: `display:inline-block; width:.8rem; height:.8rem; border-radius:3px; margin-right:.4rem; background:${desc.color}; border:1px solid rgba(0,0,0,.25);`
61471
- }], [
61472
- "span",
61473
- {},
61474
- topic_name
61475
- ]],
61774
+ [["i", { class: "yi-location-crosshairs" }]],
61476
61775
  { click: (evt) => {
61477
61776
  evt.stopPropagation();
61478
- gobj_send_event(gobj, "EV_LEGEND_TOPIC", { topic: topic_name }, gobj);
61777
+ gobj_send_event(gobj, "EV_LEGEND_TOPIC", {
61778
+ topic: topic_name,
61779
+ action: "focus"
61780
+ }, gobj);
61479
61781
  } }
61480
61782
  ]);
61481
- $legend.appendChild($item);
61783
+ let $chip = createElement2([
61784
+ "div",
61785
+ {
61786
+ class: "GRAPH_LEGEND_CHIP buttons has-addons",
61787
+ style: "margin:0; flex:0 0 auto; flex-wrap:nowrap;"
61788
+ },
61789
+ [$body].concat(extras.map((spec) => createElement2(spec)))
61790
+ ]);
61791
+ $legend.appendChild($chip);
61482
61792
  }
61483
61793
  }
61484
61794
  /************************************************************
61485
- *
61795
+ * The engine said what is drawn: repaint the strip.
61486
61796
  ************************************************************/
61487
- function ac_toggle_legend(gobj, event, kw, src) {
61488
- let $container = gobj_read_attr(gobj, "$container");
61489
- if (!$container) return 0;
61490
- let $legend = $container.querySelector(".GRAPH_LEGEND");
61491
- if (!$legend) {
61492
- log_error(`${gobj_short_name(gobj)}: no legend strip to toggle`);
61493
- return -1;
61494
- }
61495
- if ($legend.classList.contains("is-hidden")) {
61496
- refresh_legend(gobj);
61497
- $legend.classList.remove("is-hidden");
61498
- } else $legend.classList.add("is-hidden");
61797
+ function ac_legend_state(gobj, event, kw, src) {
61798
+ let priv = gobj.priv;
61799
+ priv._legend_state = kw || null;
61800
+ refresh_legend(gobj);
61499
61801
  return 0;
61500
61802
  }
61501
61803
  /************************************************************
61804
+ *
61805
+ ************************************************************/
61806
+ /************************************************************
61807
+ * One of the legend's settings changed: write it, SAVE it (they
61808
+ * are the reader's, per treedb) and tell the engine.
61809
+ ************************************************************/
61810
+ function set_legend_list_attr(gobj, name, event_name, topics) {
61811
+ let priv = gobj.priv;
61812
+ gobj_write_attr(gobj, name, topics);
61813
+ gobj_save_persistent_attrs(gobj, name);
61814
+ if (priv.gobj_nodes_tree) gobj_send_event(priv.gobj_nodes_tree, event_name, { topics }, gobj);
61815
+ }
61816
+ function legend_list_attr(gobj, name) {
61817
+ let list = gobj_read_attr(gobj, name);
61818
+ return is_array(list) ? list.slice() : [];
61819
+ }
61820
+ /************************************************************
61502
61821
  * A legend entry was clicked: focus that topic, or clear the focus if
61503
61822
  * it was already the focused one. Published UP rather than applied
61504
61823
  * here, so the URL follows — the host owns the route.
@@ -61506,12 +61825,46 @@ function ac_toggle_legend(gobj, event, kw, src) {
61506
61825
  function ac_legend_topic(gobj, event, kw, src) {
61507
61826
  let priv = gobj.priv;
61508
61827
  let topic = kw && kw.topic || "";
61509
- if (!topic) {
61828
+ let action = kw && kw.action || "focus";
61829
+ if (!topic && action !== "main") {
61510
61830
  log_error(`${gobj_short_name(gobj)}: legend click with no topic`);
61511
61831
  return -1;
61512
61832
  }
61833
+ let state = priv._legend_state || {};
61834
+ switch (action) {
61835
+ case "toggle": {
61836
+ if (topic === state.main_topic) {
61837
+ log_error(`${gobj_short_name(gobj)}: the main topic '${topic}' cannot be hidden`);
61838
+ return -1;
61839
+ }
61840
+ let hidden = legend_list_attr(gobj, "hidden_topics");
61841
+ if (str_in_list(hidden, topic)) delete_from_list(hidden, topic);
61842
+ else hidden.push(topic);
61843
+ set_legend_list_attr(gobj, "hidden_topics", "EV_SET_HIDDEN_TOPICS", hidden);
61844
+ return 0;
61845
+ }
61846
+ case "loose": {
61847
+ let loose = legend_list_attr(gobj, "loose_topics");
61848
+ if (str_in_list(loose, topic)) delete_from_list(loose, topic);
61849
+ else loose.push(topic);
61850
+ set_legend_list_attr(gobj, "loose_topics", "EV_SET_LOOSE_TOPICS", loose);
61851
+ return 0;
61852
+ }
61853
+ case "main":
61854
+ gobj_write_str_attr(gobj, "main_topic", topic);
61855
+ gobj_save_persistent_attrs(gobj, "main_topic");
61856
+ if (priv.gobj_nodes_tree) gobj_send_event(priv.gobj_nodes_tree, "EV_SET_MAIN_TOPIC", { topic }, gobj);
61857
+ return 0;
61858
+ case "focus": break;
61859
+ default:
61860
+ log_error(`${gobj_short_name(gobj)}: legend action unknown: ${action}`);
61861
+ return -1;
61862
+ }
61513
61863
  let next = priv.focus_topic === topic ? "" : topic;
61514
- gobj_send_event(gobj, "EV_SET_FOCUS_TOPIC", { topic: next }, gobj);
61864
+ gobj_send_event(gobj, "EV_SET_FOCUS_TOPIC", {
61865
+ topic: next,
61866
+ reveal: "all"
61867
+ }, gobj);
61515
61868
  gobj_publish_event(gobj, "EV_TOPIC_SELECTED", { topic: next });
61516
61869
  return 0;
61517
61870
  }
@@ -61567,17 +61920,28 @@ function ac_find_result(gobj, event, kw, src) {
61567
61920
  $count.textContent = "";
61568
61921
  return 0;
61569
61922
  }
61570
- $count.textContent = t("matches", { count: kw && kw.matches || 0 });
61923
+ let text = t("matches", { count: kw && kw.matches || 0 });
61924
+ let hidden = kw && kw.hidden_matches || 0;
61925
+ if (hidden > 0) text += ` (+${hidden} ${t("hidden topics")})`;
61926
+ $count.textContent = text;
61571
61927
  $result.classList.remove("is-hidden");
61572
61928
  return 0;
61573
61929
  }
61574
61930
  function ac_set_focus_topic(gobj, event, kw, src) {
61575
61931
  let priv = gobj.priv;
61576
61932
  priv.focus_topic = kw && kw.topic || "";
61577
- if (priv.gobj_nodes_tree) gobj_send_event(priv.gobj_nodes_tree, "EV_FOCUS_TOPIC", { topic: priv.focus_topic }, gobj);
61578
- let $container = gobj_read_attr(gobj, "$container");
61579
- let $legend = $container ? $container.querySelector(".GRAPH_LEGEND") : null;
61580
- if ($legend && !$legend.classList.contains("is-hidden")) refresh_legend(gobj);
61933
+ if (priv.focus_topic) {
61934
+ let hidden = legend_list_attr(gobj, "hidden_topics");
61935
+ if (str_in_list(hidden, priv.focus_topic)) {
61936
+ delete_from_list(hidden, priv.focus_topic);
61937
+ set_legend_list_attr(gobj, "hidden_topics", "EV_SET_HIDDEN_TOPICS", hidden);
61938
+ }
61939
+ }
61940
+ if (priv.gobj_nodes_tree) gobj_send_event(priv.gobj_nodes_tree, "EV_FOCUS_TOPIC", {
61941
+ topic: priv.focus_topic,
61942
+ reveal: kw && kw.reveal || "page"
61943
+ }, gobj);
61944
+ refresh_legend(gobj);
61581
61945
  return 0;
61582
61946
  }
61583
61947
  /************************************************************
@@ -61761,13 +62125,13 @@ function create_gclass$3(gclass_name) {
61761
62125
  null
61762
62126
  ],
61763
62127
  [
61764
- "EV_TOGGLE_LEGEND",
61765
- ac_toggle_legend,
62128
+ "EV_LEGEND_TOPIC",
62129
+ ac_legend_topic,
61766
62130
  null
61767
62131
  ],
61768
62132
  [
61769
- "EV_LEGEND_TOPIC",
61770
- ac_legend_topic,
62133
+ "EV_LEGEND_STATE",
62134
+ ac_legend_state,
61771
62135
  null
61772
62136
  ],
61773
62137
  [
@@ -61821,8 +62185,8 @@ function create_gclass$3(gclass_name) {
61821
62185
  ["EV_COLLAPSE_ALL", 0],
61822
62186
  ["EV_FIND_RESULT", 0],
61823
62187
  ["EV_LAYOUT_AUTOSET", 0],
61824
- ["EV_TOGGLE_LEGEND", 0],
61825
62188
  ["EV_LEGEND_TOPIC", 0],
62189
+ ["EV_LEGEND_STATE", 0],
61826
62190
  ["EV_TOPIC_SELECTED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
61827
62191
  ["EV_OPERATION_MODE_CHANGED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
61828
62192
  ["EV_RECORD_WRITTEN", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],