@yuneta/gobj-ui 7.14.1 → 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
  }
@@ -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
  }
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.2",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -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