@yuneta/gobj-ui 7.14.0 → 7.14.2

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.
@@ -17139,6 +17139,30 @@ function build_ui$5(gobj) {
17139
17139
  (0, _yuneta_gobj_js.refresh_language)($container, i18next.t);
17140
17140
  }
17141
17141
  /************************************************************
17142
+ * What the SELECTION drives: the two toolbar buttons that act
17143
+ * on it, and the bar that counts it.
17144
+ *
17145
+ * Read from the table every time, never from a running tally:
17146
+ * rows leave the selection by routes that do not announce it
17147
+ * (deleting a selected row deselects it SILENTLY, see
17148
+ * ac_node_deleted).
17149
+ ************************************************************/
17150
+ function render_selection_state(gobj) {
17151
+ let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
17152
+ let $delete = $container ? $container.querySelector(`.button-delete-record`) : null;
17153
+ let $copy = $container ? $container.querySelector(`.button-copy-record`) : null;
17154
+ if ($delete && $copy) {
17155
+ if (yui_selected_rows((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator")).length > 0 && (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "editable")) {
17156
+ $delete.removeAttribute("disabled");
17157
+ $copy.removeAttribute("disabled");
17158
+ } else {
17159
+ $delete.setAttribute("disabled", true);
17160
+ $copy.setAttribute("disabled", true);
17161
+ }
17162
+ }
17163
+ render_selection_bar(gobj);
17164
+ }
17165
+ /************************************************************
17142
17166
  * How many rows are ticked, on the bar.
17143
17167
  *
17144
17168
  * Only while the table is EDITABLE: outside edition its checkbox
@@ -18418,6 +18442,7 @@ function ac_node_deleted$1(gobj, event, kw, src) {
18418
18442
  let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
18419
18443
  if (tabulator) for (let record of data) if (tabulator.getRow(record.id)) tabulator.deleteRow(record.id);
18420
18444
  else (0, _yuneta_gobj_js.log_error)("delete_data: record not found: " + record.id);
18445
+ render_selection_state(gobj);
18421
18446
  return 0;
18422
18447
  }
18423
18448
  /************************************************************
@@ -18594,20 +18619,7 @@ function ac_form_save_record(gobj, event, kw, src) {
18594
18619
  * { rows: [row] }
18595
18620
  ************************************************************/
18596
18621
  function ac_select_rows(gobj, event, kw, src) {
18597
- let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
18598
- let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
18599
- let $button_delete_record = $container.querySelector(`.button-delete-record`);
18600
- let $button_copy_record = $container.querySelector(`.button-copy-record`);
18601
- if ($button_delete_record) {
18602
- if (yui_selected_rows(tabulator).length && (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "editable")) {
18603
- $button_delete_record.removeAttribute("disabled");
18604
- $button_copy_record.removeAttribute("disabled");
18605
- } else {
18606
- $button_delete_record.setAttribute("disabled", true);
18607
- $button_copy_record.setAttribute("disabled", true);
18608
- }
18609
- }
18610
- render_selection_bar(gobj);
18622
+ render_selection_state(gobj);
18611
18623
  if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "broadcast_select_rows_event")) (0, _yuneta_gobj_js.gobj_publish_event)(gobj, event, kw);
18612
18624
  return 0;
18613
18625
  }
@@ -18615,20 +18627,7 @@ function ac_select_rows(gobj, event, kw, src) {
18615
18627
  * { rows: [row] }
18616
18628
  ************************************************************/
18617
18629
  function ac_unselect_rows(gobj, event, kw, src) {
18618
- let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
18619
- let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
18620
- let $button_delete_record = $container.querySelector(`.button-delete-record`);
18621
- let $button_copy_record = $container.querySelector(`.button-copy-record`);
18622
- if ($button_delete_record) {
18623
- if (yui_selected_rows(tabulator).length && (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "editable")) {
18624
- $button_delete_record.removeAttribute("disabled");
18625
- $button_copy_record.removeAttribute("disabled");
18626
- } else {
18627
- $button_delete_record.setAttribute("disabled", true);
18628
- $button_copy_record.setAttribute("disabled", true);
18629
- }
18630
- }
18631
- render_selection_bar(gobj);
18630
+ render_selection_state(gobj);
18632
18631
  if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "broadcast_select_rows_event")) (0, _yuneta_gobj_js.gobj_publish_event)(gobj, event, kw);
18633
18632
  return 0;
18634
18633
  }
@@ -23752,7 +23751,6 @@ function remote_command(gobj, command, kw) {
23752
23751
  function build_model(gobj) {
23753
23752
  let priv = gobj.priv;
23754
23753
  priv.model = build_schema_model(priv.records);
23755
- priv.order_undo = {};
23756
23754
  priv.baseline = {};
23757
23755
  for (let treedb of priv.model.treedbs) for (let topic of treedb.topics) priv.baseline[topic.id] = topic.topic_version;
23758
23756
  }
@@ -25837,7 +25835,8 @@ function version_writes(gobj, topic) {
25837
25835
  ***************************************************************/
25838
25836
  function remember_order(gobj, topic) {
25839
25837
  let priv = gobj.priv;
25840
- if (!topic || !priv.order_undo || priv.order_undo[topic.id]) return;
25838
+ if (!priv.order_undo) priv.order_undo = {};
25839
+ if (!topic || priv.order_undo[topic.id]) return;
25841
25840
  priv.order_undo[topic.id] = topic.cols.map((col) => {
25842
25841
  return {
25843
25842
  id: col.id,
@@ -26069,6 +26068,7 @@ function ac_mt_command_answer(gobj, event, kw, src) {
26069
26068
  render(gobj);
26070
26069
  return 0;
26071
26070
  }
26071
+ priv.order_undo = {};
26072
26072
  build_model(gobj);
26073
26073
  return go(gobj, priv.treedb_id, priv.topic_name, priv.diagram, false);
26074
26074
  }
@@ -17134,6 +17134,30 @@ function build_ui$5(gobj) {
17134
17134
  refresh_language($container, t);
17135
17135
  }
17136
17136
  /************************************************************
17137
+ * What the SELECTION drives: the two toolbar buttons that act
17138
+ * on it, and the bar that counts it.
17139
+ *
17140
+ * Read from the table every time, never from a running tally:
17141
+ * rows leave the selection by routes that do not announce it
17142
+ * (deleting a selected row deselects it SILENTLY, see
17143
+ * ac_node_deleted).
17144
+ ************************************************************/
17145
+ function render_selection_state(gobj) {
17146
+ let $container = gobj_read_attr(gobj, "$container");
17147
+ let $delete = $container ? $container.querySelector(`.button-delete-record`) : null;
17148
+ let $copy = $container ? $container.querySelector(`.button-copy-record`) : null;
17149
+ if ($delete && $copy) {
17150
+ if (yui_selected_rows(gobj_read_attr(gobj, "tabulator")).length > 0 && gobj_read_bool_attr(gobj, "editable")) {
17151
+ $delete.removeAttribute("disabled");
17152
+ $copy.removeAttribute("disabled");
17153
+ } else {
17154
+ $delete.setAttribute("disabled", true);
17155
+ $copy.setAttribute("disabled", true);
17156
+ }
17157
+ }
17158
+ render_selection_bar(gobj);
17159
+ }
17160
+ /************************************************************
17137
17161
  * How many rows are ticked, on the bar.
17138
17162
  *
17139
17163
  * Only while the table is EDITABLE: outside edition its checkbox
@@ -18413,6 +18437,7 @@ function ac_node_deleted$1(gobj, event, kw, src) {
18413
18437
  let tabulator = gobj_read_attr(gobj, "tabulator");
18414
18438
  if (tabulator) for (let record of data) if (tabulator.getRow(record.id)) tabulator.deleteRow(record.id);
18415
18439
  else log_error("delete_data: record not found: " + record.id);
18440
+ render_selection_state(gobj);
18416
18441
  return 0;
18417
18442
  }
18418
18443
  /************************************************************
@@ -18589,20 +18614,7 @@ function ac_form_save_record(gobj, event, kw, src) {
18589
18614
  * { rows: [row] }
18590
18615
  ************************************************************/
18591
18616
  function ac_select_rows(gobj, event, kw, src) {
18592
- let tabulator = gobj_read_attr(gobj, "tabulator");
18593
- let $container = gobj_read_attr(gobj, "$container");
18594
- let $button_delete_record = $container.querySelector(`.button-delete-record`);
18595
- let $button_copy_record = $container.querySelector(`.button-copy-record`);
18596
- if ($button_delete_record) {
18597
- if (yui_selected_rows(tabulator).length && gobj_read_bool_attr(gobj, "editable")) {
18598
- $button_delete_record.removeAttribute("disabled");
18599
- $button_copy_record.removeAttribute("disabled");
18600
- } else {
18601
- $button_delete_record.setAttribute("disabled", true);
18602
- $button_copy_record.setAttribute("disabled", true);
18603
- }
18604
- }
18605
- render_selection_bar(gobj);
18617
+ render_selection_state(gobj);
18606
18618
  if (gobj_read_bool_attr(gobj, "broadcast_select_rows_event")) gobj_publish_event(gobj, event, kw);
18607
18619
  return 0;
18608
18620
  }
@@ -18610,20 +18622,7 @@ function ac_select_rows(gobj, event, kw, src) {
18610
18622
  * { rows: [row] }
18611
18623
  ************************************************************/
18612
18624
  function ac_unselect_rows(gobj, event, kw, src) {
18613
- let tabulator = gobj_read_attr(gobj, "tabulator");
18614
- let $container = gobj_read_attr(gobj, "$container");
18615
- let $button_delete_record = $container.querySelector(`.button-delete-record`);
18616
- let $button_copy_record = $container.querySelector(`.button-copy-record`);
18617
- if ($button_delete_record) {
18618
- if (yui_selected_rows(tabulator).length && gobj_read_bool_attr(gobj, "editable")) {
18619
- $button_delete_record.removeAttribute("disabled");
18620
- $button_copy_record.removeAttribute("disabled");
18621
- } else {
18622
- $button_delete_record.setAttribute("disabled", true);
18623
- $button_copy_record.setAttribute("disabled", true);
18624
- }
18625
- }
18626
- render_selection_bar(gobj);
18625
+ render_selection_state(gobj);
18627
18626
  if (gobj_read_bool_attr(gobj, "broadcast_select_rows_event")) gobj_publish_event(gobj, event, kw);
18628
18627
  return 0;
18629
18628
  }
@@ -23739,7 +23738,6 @@ function remote_command(gobj, command, kw) {
23739
23738
  function build_model(gobj) {
23740
23739
  let priv = gobj.priv;
23741
23740
  priv.model = build_schema_model(priv.records);
23742
- priv.order_undo = {};
23743
23741
  priv.baseline = {};
23744
23742
  for (let treedb of priv.model.treedbs) for (let topic of treedb.topics) priv.baseline[topic.id] = topic.topic_version;
23745
23743
  }
@@ -25824,7 +25822,8 @@ function version_writes(gobj, topic) {
25824
25822
  ***************************************************************/
25825
25823
  function remember_order(gobj, topic) {
25826
25824
  let priv = gobj.priv;
25827
- if (!topic || !priv.order_undo || priv.order_undo[topic.id]) return;
25825
+ if (!priv.order_undo) priv.order_undo = {};
25826
+ if (!topic || priv.order_undo[topic.id]) return;
25828
25827
  priv.order_undo[topic.id] = topic.cols.map((col) => {
25829
25828
  return {
25830
25829
  id: col.id,
@@ -26056,6 +26055,7 @@ function ac_mt_command_answer(gobj, event, kw, src) {
26056
26055
  render(gobj);
26057
26056
  return 0;
26058
26057
  }
26058
+ priv.order_undo = {};
26059
26059
  build_model(gobj);
26060
26060
  return go(gobj, priv.treedb_id, priv.topic_name, priv.diagram, false);
26061
26061
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.14.0",
3
+ "version": "7.14.2",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -528,9 +528,6 @@ function build_model(gobj)
528
528
  let priv = gobj.priv;
529
529
 
530
530
  priv.model = build_schema_model(priv.records);
531
- /* The order to go back to is the one that was on screen; a reload
532
- * brings the stored one, so what was on screen is gone. */
533
- priv.order_undo = {};
534
531
  priv.baseline = {};
535
532
  for(let treedb of priv.model.treedbs) {
536
533
  for(let topic of treedb.topics) {
@@ -2166,7 +2163,10 @@ function remember_order(gobj, topic)
2166
2163
  {
2167
2164
  let priv = gobj.priv;
2168
2165
 
2169
- if(!topic || !priv.order_undo || priv.order_undo[topic.id]) {
2166
+ if(!priv.order_undo) {
2167
+ priv.order_undo = {};
2168
+ }
2169
+ if(!topic || priv.order_undo[topic.id]) {
2170
2170
  return; /* the first drag already said where we started */
2171
2171
  }
2172
2172
  priv.order_undo[topic.id] = topic.cols.map((col) => {
@@ -2528,6 +2528,11 @@ function ac_mt_command_answer(gobj, event, kw, src)
2528
2528
  render(gobj);
2529
2529
  return 0;
2530
2530
  }
2531
+ /* Records straight from the store: what an undo would name is the
2532
+ * order that was ON SCREEN, and this is the stored one arriving.
2533
+ * (NOT in build_model(): that also runs on the patch after every
2534
+ * write, which is exactly when the undo has to survive.) */
2535
+ priv.order_undo = {};
2531
2536
  build_model(gobj);
2532
2537
  /* Back to where the operator was: the load may be a refresh, or
2533
2538
  * the answer to a deep link that arrived before the model. */
@@ -679,6 +679,35 @@ function build_ui(gobj)
679
679
  refresh_language($container, t);
680
680
  }
681
681
 
682
+ /************************************************************
683
+ * What the SELECTION drives: the two toolbar buttons that act
684
+ * on it, and the bar that counts it.
685
+ *
686
+ * Read from the table every time, never from a running tally:
687
+ * rows leave the selection by routes that do not announce it
688
+ * (deleting a selected row deselects it SILENTLY, see
689
+ * ac_node_deleted).
690
+ ************************************************************/
691
+ function render_selection_state(gobj)
692
+ {
693
+ let $container = gobj_read_attr(gobj, "$container");
694
+ let $delete = $container ? $container.querySelector(`.button-delete-record`) : null;
695
+ let $copy = $container ? $container.querySelector(`.button-copy-record`) : null;
696
+
697
+ if($delete && $copy) {
698
+ let some = yui_selected_rows(gobj_read_attr(gobj, "tabulator")).length > 0;
699
+ if(some && gobj_read_bool_attr(gobj, "editable")) {
700
+ $delete.removeAttribute("disabled");
701
+ $copy.removeAttribute("disabled");
702
+ } else {
703
+ $delete.setAttribute("disabled", true);
704
+ $copy.setAttribute("disabled", true);
705
+ }
706
+ }
707
+
708
+ render_selection_bar(gobj);
709
+ }
710
+
682
711
  /************************************************************
683
712
  * How many rows are ticked, on the bar.
684
713
  *
@@ -2625,7 +2654,6 @@ function ac_node_deleted(gobj, event, kw, src)
2625
2654
  }
2626
2655
 
2627
2656
  let tabulator = gobj_read_attr(gobj, "tabulator");
2628
- //tabulator.deselectRow(); // unselectAll TODO ??? is necessary?
2629
2657
 
2630
2658
  if(tabulator) {
2631
2659
  for(let record of data) {
@@ -2639,6 +2667,18 @@ function ac_node_deleted(gobj, event, kw, src)
2639
2667
  }
2640
2668
  }
2641
2669
 
2670
+ /* There WAS a commented-out `deselectRow()` here, asking whether it was
2671
+ * needed. It is not: Tabulator's own SelectRow module subscribes to
2672
+ * `row-deleting` and deselects the row it is about to remove, so a
2673
+ * deleted row cannot stay in the selection.
2674
+ *
2675
+ * What IS needed is this line. That deselect is SILENT
2676
+ * (`_deselectRow(row, true)`), so no `rowDeselected` arrives, no
2677
+ * EV_UNSELECT_ROWS is sent, and everything the selection drives would
2678
+ * keep describing rows that are gone: the bar saying "3 selected" over a
2679
+ * table with none, and Delete and Copy still enabled. */
2680
+ render_selection_state(gobj);
2681
+
2642
2682
  return 0;
2643
2683
  }
2644
2684
 
@@ -2928,26 +2968,7 @@ function ac_form_save_record(gobj, event, kw, src)
2928
2968
  ************************************************************/
2929
2969
  function ac_select_rows(gobj, event, kw, src)
2930
2970
  {
2931
- let tabulator = gobj_read_attr(gobj, "tabulator");
2932
- let $container = gobj_read_attr(gobj, "$container");
2933
-
2934
- /*
2935
- * Update button DELETE, only enable if some row is selected
2936
- */
2937
- let $button_delete_record = $container.querySelector(`.button-delete-record`);
2938
- let $button_copy_record = $container.querySelector(`.button-copy-record`);
2939
- if($button_delete_record) {
2940
- let selectedRows = yui_selected_rows(tabulator);
2941
- if (selectedRows.length && gobj_read_bool_attr(gobj, "editable")) {
2942
- $button_delete_record.removeAttribute("disabled");
2943
- $button_copy_record.removeAttribute("disabled");
2944
- } else {
2945
- $button_delete_record.setAttribute("disabled", true);
2946
- $button_copy_record.setAttribute("disabled", true);
2947
- }
2948
- }
2949
-
2950
- render_selection_bar(gobj);
2971
+ render_selection_state(gobj);
2951
2972
 
2952
2973
  if(gobj_read_bool_attr(gobj, "broadcast_select_rows_event")) {
2953
2974
  gobj_publish_event(gobj, event, kw);
@@ -2961,26 +2982,7 @@ function ac_select_rows(gobj, event, kw, src)
2961
2982
  ************************************************************/
2962
2983
  function ac_unselect_rows(gobj, event, kw, src)
2963
2984
  {
2964
- let tabulator = gobj_read_attr(gobj, "tabulator");
2965
- let $container = gobj_read_attr(gobj, "$container");
2966
-
2967
- /*
2968
- * Update button DELETE, only enable if some row is selected
2969
- */
2970
- let $button_delete_record = $container.querySelector(`.button-delete-record`);
2971
- let $button_copy_record = $container.querySelector(`.button-copy-record`);
2972
- if($button_delete_record) {
2973
- let selectedRows = yui_selected_rows(tabulator);
2974
- if (selectedRows.length && gobj_read_bool_attr(gobj, "editable")) {
2975
- $button_delete_record.removeAttribute("disabled");
2976
- $button_copy_record.removeAttribute("disabled");
2977
- } else {
2978
- $button_delete_record.setAttribute("disabled", true);
2979
- $button_copy_record.setAttribute("disabled", true);
2980
- }
2981
- }
2982
-
2983
- render_selection_bar(gobj);
2985
+ render_selection_state(gobj);
2984
2986
 
2985
2987
  // WARNING with radio, there is no unselect event.
2986
2988