@yuneta/gobj-ui 7.14.1 → 7.14.3

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.
@@ -884,7 +884,7 @@ function mt_start$16(gobj) {
884
884
  "C_YUI_SHELL: invalid config — see browser console for details"
885
885
  ]
886
886
  ]));
887
- return;
887
+ return -1;
888
888
  }
889
889
  let shell_cfg = config.shell || {};
890
890
  if (typeof shell_cfg.remember_section_position === "boolean") (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "remember_section_position", shell_cfg.remember_section_position);
@@ -941,7 +941,7 @@ function mt_start$16(gobj) {
941
941
  ***************************************************************/
942
942
  function mt_stop$16(gobj) {
943
943
  let priv = gobj.priv;
944
- if (!priv) return;
944
+ if (!priv) return 0;
945
945
  close_toolbar_dropdown(gobj);
946
946
  if (priv.hash_handler) {
947
947
  window.removeEventListener("hashchange", priv.hash_handler);
@@ -15656,7 +15656,7 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
15656
15656
  data = webix_msg.data;
15657
15657
  } catch (e) {
15658
15658
  (0, _yuneta_gobj_js.log_error)(e);
15659
- return;
15659
+ return -1;
15660
15660
  }
15661
15661
  let __command__ = (0, _yuneta_gobj_js.msg_iev_get_stack)(gobj, kw, "command_stack", true);
15662
15662
  let command = (0, _yuneta_gobj_js.kw_get_str)(gobj, __command__, "command", "", _yuneta_gobj_js.kw_flag_t.KW_REQUIRED);
@@ -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
  }
@@ -20325,7 +20324,7 @@ function ac_mt_command_answer$1(gobj, event, kw, src) {
20325
20324
  data = kw.data;
20326
20325
  } catch (e) {
20327
20326
  (0, _yuneta_gobj_js.log_error)(e);
20328
- return;
20327
+ return -1;
20329
20328
  }
20330
20329
  let __command__ = (0, _yuneta_gobj_js.msg_iev_get_stack)(gobj, kw, "command_stack", true);
20331
20330
  let command = (0, _yuneta_gobj_js.kw_get_str)(gobj, __command__, "command", "", _yuneta_gobj_js.kw_flag_t.KW_REQUIRED);
@@ -879,7 +879,7 @@ function mt_start$16(gobj) {
879
879
  "C_YUI_SHELL: invalid config — see browser console for details"
880
880
  ]
881
881
  ]));
882
- return;
882
+ return -1;
883
883
  }
884
884
  let shell_cfg = config.shell || {};
885
885
  if (typeof shell_cfg.remember_section_position === "boolean") gobj_write_attr(gobj, "remember_section_position", shell_cfg.remember_section_position);
@@ -936,7 +936,7 @@ function mt_start$16(gobj) {
936
936
  ***************************************************************/
937
937
  function mt_stop$16(gobj) {
938
938
  let priv = gobj.priv;
939
- if (!priv) return;
939
+ if (!priv) return 0;
940
940
  close_toolbar_dropdown(gobj);
941
941
  if (priv.hash_handler) {
942
942
  window.removeEventListener("hashchange", priv.hash_handler);
@@ -15651,7 +15651,7 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
15651
15651
  data = webix_msg.data;
15652
15652
  } catch (e) {
15653
15653
  log_error(e);
15654
- return;
15654
+ return -1;
15655
15655
  }
15656
15656
  let __command__ = msg_iev_get_stack(gobj, kw, "command_stack", true);
15657
15657
  let command = kw_get_str(gobj, __command__, "command", "", kw_flag_t.KW_REQUIRED);
@@ -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
  }
@@ -20312,7 +20311,7 @@ function ac_mt_command_answer$1(gobj, event, kw, src) {
20312
20311
  data = kw.data;
20313
20312
  } catch (e) {
20314
20313
  log_error(e);
20315
- return;
20314
+ return -1;
20316
20315
  }
20317
20316
  let __command__ = msg_iev_get_stack(gobj, kw, "command_stack", true);
20318
20317
  let command = kw_get_str(gobj, __command__, "command", "", kw_flag_t.KW_REQUIRED);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.14.1",
3
+ "version": "7.14.3",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
package/src/c_yui_node.js CHANGED
@@ -275,7 +275,7 @@ function mt_start(gobj)
275
275
  }
276
276
 
277
277
  if(!priv.is_root) {
278
- return;
278
+ return 0;
279
279
  }
280
280
 
281
281
  /*
@@ -287,7 +287,7 @@ function mt_start(gobj)
287
287
  let shell = yui_shell_of(gobj);
288
288
  if(!shell) {
289
289
  log_error(`${GCLASS_NAME}: no shell — the tree cannot route`);
290
- return;
290
+ return -1;
291
291
  }
292
292
  gobj_subscribe_event(shell, "EV_ROUTE_CHANGED", {}, gobj);
293
293
  publish_sub_routes(gobj);
@@ -226,7 +226,7 @@ function mt_start(gobj)
226
226
  ]
227
227
  ));
228
228
  }
229
- return;
229
+ return -1;
230
230
  }
231
231
 
232
232
  /* Declarative sugar over the attr, which stays the runtime truth:
@@ -364,7 +364,7 @@ function mt_stop(gobj)
364
364
  {
365
365
  let priv = gobj.priv;
366
366
  if(!priv) {
367
- return;
367
+ return 0;
368
368
  }
369
369
 
370
370
  /* Tear down any toolbar dropdown that was open at stop time so its
@@ -1495,7 +1495,7 @@ function ac_mt_command_answer(gobj, event, kw, src)
1495
1495
  data = kw.data;
1496
1496
  } catch (e) {
1497
1497
  log_error(e);
1498
- return;
1498
+ return -1;
1499
1499
  }
1500
1500
  let __command__ = msg_iev_get_stack(gobj, kw, "command_stack", true);
1501
1501
  let command = kw_get_str(gobj, __command__, "command", "", kw_flag_t.KW_REQUIRED);
@@ -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
 
@@ -1721,7 +1721,7 @@ function ac_mt_command_answer(gobj, event, kw, src)
1721
1721
  data = webix_msg.data;
1722
1722
  } catch (e) {
1723
1723
  log_error(e);
1724
- return;
1724
+ return -1;
1725
1725
  }
1726
1726
  let __command__ = msg_iev_get_stack(gobj, kw, "command_stack", true);
1727
1727
  let command = kw_get_str(gobj, __command__, "command", "", kw_flag_t.KW_REQUIRED);