@yuneta/gobj-ui 7.11.0 → 7.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/gobj-ui.cjs.js +98 -14
- package/dist/gobj-ui.es.js +64 -14
- package/package.json +1 -1
- package/src/c_yui_treedb_topic_with_form.js +31 -16
- package/src/yui_table_select.js +19 -4
package/README.md
CHANGED
|
@@ -1031,6 +1031,14 @@ from the view's `EV_LANGUAGE_CHANGED` action.
|
|
|
1031
1031
|
table that is not built yet or is already gone. Clear the selection after
|
|
1032
1032
|
acting on it: the rows it names are no longer there.
|
|
1033
1033
|
|
|
1034
|
+
`yui_selection_column({visible: false})` is for a table that reveals the column
|
|
1035
|
+
only in an edit mode — `C_YUI_TREEDB_TOPIC_WITH_FORM` shows it with
|
|
1036
|
+
`showColumn("_check_box_state_")`, and takes its `selectableRows` and every
|
|
1037
|
+
read of its selection from here too. A **radio** column (pick ONE row) is not
|
|
1038
|
+
this facility: it is `formatter: "rowSelection"` with no `titleFormatter` and
|
|
1039
|
+
`selectableRows: 1`, and the header checkbox, the count and the bar all mean
|
|
1040
|
+
nothing there.
|
|
1041
|
+
|
|
1034
1042
|
## Conventions
|
|
1035
1043
|
|
|
1036
1044
|
### i18n: a string must be able to CHANGE language, not just be translated once
|
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -16317,6 +16317,93 @@ function yui_tabulator_relocalize(table, t) {
|
|
|
16317
16317
|
}
|
|
16318
16318
|
}
|
|
16319
16319
|
//#endregion
|
|
16320
|
+
//#region src/yui_table_select.js
|
|
16321
|
+
/***********************************************************************
|
|
16322
|
+
* yui_table_select.js
|
|
16323
|
+
*
|
|
16324
|
+
* SELECT ROWS IN A TABLE, and act on the lot.
|
|
16325
|
+
*
|
|
16326
|
+
* Deleting twenty rows one confirmation at a time is not a
|
|
16327
|
+
* workflow, it is a punishment, and every table that lets you
|
|
16328
|
+
* remove a row will eventually be asked to remove twenty. This
|
|
16329
|
+
* is that facility, once: the checkbox column, the settings
|
|
16330
|
+
* that make selection behave, and the bar that appears while
|
|
16331
|
+
* something is selected and carries what can be done to it.
|
|
16332
|
+
*
|
|
16333
|
+
* Two decisions are baked in, both learned in the treedb
|
|
16334
|
+
* topic table:
|
|
16335
|
+
*
|
|
16336
|
+
* - Selection is driven ONLY by the checkbox, never by
|
|
16337
|
+
* clicking the row (`selectableRows: "highlight"`). A table
|
|
16338
|
+
* row is full of things to click -- an editor, an icon, a
|
|
16339
|
+
* nested table -- and click-to-select ticks a row every time
|
|
16340
|
+
* you reach for one of them.
|
|
16341
|
+
*
|
|
16342
|
+
* - The header checkbox covers the ACTIVE rows, the ones the
|
|
16343
|
+
* filters leave on screen. "Select all" over rows nobody can
|
|
16344
|
+
* see is how a filtered delete takes the whole topic with
|
|
16345
|
+
* it.
|
|
16346
|
+
*
|
|
16347
|
+
* The bar takes its words from the HOST's `t`: this library
|
|
16348
|
+
* translates through the app's i18next, and the app owns the
|
|
16349
|
+
* keys. It needs "{{n}} selected" and "clear selection"; each
|
|
16350
|
+
* action brings its own key.
|
|
16351
|
+
*
|
|
16352
|
+
* Copyright (c) 2026, ArtGins.
|
|
16353
|
+
* All Rights Reserved.
|
|
16354
|
+
***********************************************************************/
|
|
16355
|
+
/***************************************************************
|
|
16356
|
+
* The checkbox column. Put it FIRST in the column list.
|
|
16357
|
+
*
|
|
16358
|
+
* opts:
|
|
16359
|
+
* field the (virtual) field name, default "_select"
|
|
16360
|
+
* width default 44
|
|
16361
|
+
* visible default true; `false` for a table that reveals
|
|
16362
|
+
* the column only in an edit mode (the treedb topic
|
|
16363
|
+
* table shows it with `showColumn(field)`)
|
|
16364
|
+
*
|
|
16365
|
+
* This is the SELECT-MANY widget. A table that lets you pick ONE
|
|
16366
|
+
* row uses a radio column of its own (`formatter: "rowSelection"`
|
|
16367
|
+
* with no `titleFormatter`, `selectableRows: 1`): the header
|
|
16368
|
+
* checkbox, the count and the bar all mean nothing there.
|
|
16369
|
+
***************************************************************/
|
|
16370
|
+
function yui_selection_column(opts) {
|
|
16371
|
+
let o = opts || {};
|
|
16372
|
+
return {
|
|
16373
|
+
title: "",
|
|
16374
|
+
field: o.field || "_select",
|
|
16375
|
+
width: o.width || 44,
|
|
16376
|
+
minWidth: o.width || 44,
|
|
16377
|
+
visible: o.visible !== false,
|
|
16378
|
+
hozAlign: "center",
|
|
16379
|
+
headerHozAlign: "center",
|
|
16380
|
+
headerSort: false,
|
|
16381
|
+
resizable: false,
|
|
16382
|
+
formatter: "rowSelection",
|
|
16383
|
+
titleFormatter: "rowSelection",
|
|
16384
|
+
titleFormatterParams: { rowRange: "active" },
|
|
16385
|
+
cssClass: "TABLE_SELECT_CELL"
|
|
16386
|
+
};
|
|
16387
|
+
}
|
|
16388
|
+
/***************************************************************
|
|
16389
|
+
* What the Tabulator settings need for the column above.
|
|
16390
|
+
* Spread it into the settings object.
|
|
16391
|
+
***************************************************************/
|
|
16392
|
+
function yui_selection_settings() {
|
|
16393
|
+
return { selectableRows: "highlight" };
|
|
16394
|
+
}
|
|
16395
|
+
/***************************************************************
|
|
16396
|
+
* The rows selected right now (never null).
|
|
16397
|
+
***************************************************************/
|
|
16398
|
+
function yui_selected_rows(tabulator) {
|
|
16399
|
+
if (!tabulator || typeof tabulator.getSelectedData !== "function") return [];
|
|
16400
|
+
try {
|
|
16401
|
+
return tabulator.getSelectedData() || [];
|
|
16402
|
+
} catch (e) {
|
|
16403
|
+
return [];
|
|
16404
|
+
}
|
|
16405
|
+
}
|
|
16406
|
+
//#endregion
|
|
16320
16407
|
//#region src/treedb_write_plan.js
|
|
16321
16408
|
/***********************************************************************
|
|
16322
16409
|
* treedb_write_plan.js
|
|
@@ -16996,16 +17083,11 @@ function create_tabulator(gobj) {
|
|
|
16996
17083
|
let columns = [];
|
|
16997
17084
|
let with_checkbox = (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_checkbox");
|
|
16998
17085
|
let with_radio = (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_radio");
|
|
16999
|
-
if (with_checkbox) columns.push({
|
|
17000
|
-
formatter: "rowSelection",
|
|
17001
|
-
titleFormatter: "rowSelection",
|
|
17086
|
+
if (with_checkbox) columns.push(yui_selection_column({
|
|
17002
17087
|
field: "_check_box_state_",
|
|
17003
|
-
hozAlign: "center",
|
|
17004
|
-
headerHozAlign: "center",
|
|
17005
17088
|
width: 40,
|
|
17006
|
-
visible: false
|
|
17007
|
-
|
|
17008
|
-
});
|
|
17089
|
+
visible: false
|
|
17090
|
+
}));
|
|
17009
17091
|
else if (with_radio) columns.push({
|
|
17010
17092
|
formatter: "rowSelection",
|
|
17011
17093
|
field: "_check_box_state_",
|
|
@@ -17234,7 +17316,9 @@ function create_tabulator(gobj) {
|
|
|
17234
17316
|
}
|
|
17235
17317
|
});
|
|
17236
17318
|
let pkey = desc.pkey || "id";
|
|
17237
|
-
let selectable =
|
|
17319
|
+
let selectable = false;
|
|
17320
|
+
if (with_checkbox) selectable = yui_selection_settings().selectableRows;
|
|
17321
|
+
else if (with_radio) selectable = 1;
|
|
17238
17322
|
let tabulator_settings = (0, _yuneta_gobj_js.json_deep_copy)((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator_settings"));
|
|
17239
17323
|
if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_remote_paging")) {
|
|
17240
17324
|
let page_size = (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "page_size") || 200;
|
|
@@ -18216,7 +18300,7 @@ function ac_edition_mode(gobj, event, kw, src) {
|
|
|
18216
18300
|
tabulator.showColumn("_check_box_state_");
|
|
18217
18301
|
$button_new_record.removeAttribute("disabled");
|
|
18218
18302
|
$button_paste_record.removeAttribute("disabled");
|
|
18219
|
-
if (tabulator
|
|
18303
|
+
if (yui_selected_rows(tabulator).length) {
|
|
18220
18304
|
$button_delete_record.removeAttribute("disabled");
|
|
18221
18305
|
$button_copy_record.removeAttribute("disabled");
|
|
18222
18306
|
}
|
|
@@ -18274,7 +18358,7 @@ function ac_delete_rows(gobj, event, kw, src) {
|
|
|
18274
18358
|
if (refuse_if_readonly$2(gobj, event)) return -1;
|
|
18275
18359
|
let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
|
|
18276
18360
|
if ((0, _yuneta_gobj_js.json_size)(kw) === 0) {
|
|
18277
|
-
let rows = tabulator
|
|
18361
|
+
let rows = yui_selected_rows(tabulator);
|
|
18278
18362
|
if (!rows.length) {
|
|
18279
18363
|
yui_shell_confirm_ok(yui_shell_of(gobj), "please select some row", {
|
|
18280
18364
|
t: i18next.t,
|
|
@@ -18310,7 +18394,7 @@ function ac_delete_rows(gobj, event, kw, src) {
|
|
|
18310
18394
|
* From internal
|
|
18311
18395
|
************************************************************/
|
|
18312
18396
|
function ac_copy_rows(gobj, event, kw, src) {
|
|
18313
|
-
let rows = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator")
|
|
18397
|
+
let rows = yui_selected_rows((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator"));
|
|
18314
18398
|
if (!rows.length) {
|
|
18315
18399
|
yui_shell_confirm_ok(yui_shell_of(gobj), "please select some row", {
|
|
18316
18400
|
t: i18next.t,
|
|
@@ -18368,7 +18452,7 @@ function ac_select_rows(gobj, event, kw, src) {
|
|
|
18368
18452
|
let $button_delete_record = $container.querySelector(`.button-delete-record`);
|
|
18369
18453
|
let $button_copy_record = $container.querySelector(`.button-copy-record`);
|
|
18370
18454
|
if ($button_delete_record) {
|
|
18371
|
-
if (tabulator
|
|
18455
|
+
if (yui_selected_rows(tabulator).length && (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "editable")) {
|
|
18372
18456
|
$button_delete_record.removeAttribute("disabled");
|
|
18373
18457
|
$button_copy_record.removeAttribute("disabled");
|
|
18374
18458
|
} else {
|
|
@@ -18388,7 +18472,7 @@ function ac_unselect_rows(gobj, event, kw, src) {
|
|
|
18388
18472
|
let $button_delete_record = $container.querySelector(`.button-delete-record`);
|
|
18389
18473
|
let $button_copy_record = $container.querySelector(`.button-copy-record`);
|
|
18390
18474
|
if ($button_delete_record) {
|
|
18391
|
-
if (tabulator
|
|
18475
|
+
if (yui_selected_rows(tabulator).length && (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "editable")) {
|
|
18392
18476
|
$button_delete_record.removeAttribute("disabled");
|
|
18393
18477
|
$button_copy_record.removeAttribute("disabled");
|
|
18394
18478
|
} else {
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -16312,6 +16312,59 @@ function yui_tabulator_relocalize(table, t) {
|
|
|
16312
16312
|
}
|
|
16313
16313
|
}
|
|
16314
16314
|
//#endregion
|
|
16315
|
+
//#region src/yui_table_select.js
|
|
16316
|
+
/***************************************************************
|
|
16317
|
+
* The checkbox column. Put it FIRST in the column list.
|
|
16318
|
+
*
|
|
16319
|
+
* opts:
|
|
16320
|
+
* field the (virtual) field name, default "_select"
|
|
16321
|
+
* width default 44
|
|
16322
|
+
* visible default true; `false` for a table that reveals
|
|
16323
|
+
* the column only in an edit mode (the treedb topic
|
|
16324
|
+
* table shows it with `showColumn(field)`)
|
|
16325
|
+
*
|
|
16326
|
+
* This is the SELECT-MANY widget. A table that lets you pick ONE
|
|
16327
|
+
* row uses a radio column of its own (`formatter: "rowSelection"`
|
|
16328
|
+
* with no `titleFormatter`, `selectableRows: 1`): the header
|
|
16329
|
+
* checkbox, the count and the bar all mean nothing there.
|
|
16330
|
+
***************************************************************/
|
|
16331
|
+
function yui_selection_column(opts) {
|
|
16332
|
+
let o = opts || {};
|
|
16333
|
+
return {
|
|
16334
|
+
title: "",
|
|
16335
|
+
field: o.field || "_select",
|
|
16336
|
+
width: o.width || 44,
|
|
16337
|
+
minWidth: o.width || 44,
|
|
16338
|
+
visible: o.visible !== false,
|
|
16339
|
+
hozAlign: "center",
|
|
16340
|
+
headerHozAlign: "center",
|
|
16341
|
+
headerSort: false,
|
|
16342
|
+
resizable: false,
|
|
16343
|
+
formatter: "rowSelection",
|
|
16344
|
+
titleFormatter: "rowSelection",
|
|
16345
|
+
titleFormatterParams: { rowRange: "active" },
|
|
16346
|
+
cssClass: "TABLE_SELECT_CELL"
|
|
16347
|
+
};
|
|
16348
|
+
}
|
|
16349
|
+
/***************************************************************
|
|
16350
|
+
* What the Tabulator settings need for the column above.
|
|
16351
|
+
* Spread it into the settings object.
|
|
16352
|
+
***************************************************************/
|
|
16353
|
+
function yui_selection_settings() {
|
|
16354
|
+
return { selectableRows: "highlight" };
|
|
16355
|
+
}
|
|
16356
|
+
/***************************************************************
|
|
16357
|
+
* The rows selected right now (never null).
|
|
16358
|
+
***************************************************************/
|
|
16359
|
+
function yui_selected_rows(tabulator) {
|
|
16360
|
+
if (!tabulator || typeof tabulator.getSelectedData !== "function") return [];
|
|
16361
|
+
try {
|
|
16362
|
+
return tabulator.getSelectedData() || [];
|
|
16363
|
+
} catch (e) {
|
|
16364
|
+
return [];
|
|
16365
|
+
}
|
|
16366
|
+
}
|
|
16367
|
+
//#endregion
|
|
16315
16368
|
//#region src/treedb_write_plan.js
|
|
16316
16369
|
/***********************************************************************
|
|
16317
16370
|
* treedb_write_plan.js
|
|
@@ -16991,16 +17044,11 @@ function create_tabulator(gobj) {
|
|
|
16991
17044
|
let columns = [];
|
|
16992
17045
|
let with_checkbox = gobj_read_bool_attr(gobj, "with_checkbox");
|
|
16993
17046
|
let with_radio = gobj_read_bool_attr(gobj, "with_radio");
|
|
16994
|
-
if (with_checkbox) columns.push({
|
|
16995
|
-
formatter: "rowSelection",
|
|
16996
|
-
titleFormatter: "rowSelection",
|
|
17047
|
+
if (with_checkbox) columns.push(yui_selection_column({
|
|
16997
17048
|
field: "_check_box_state_",
|
|
16998
|
-
hozAlign: "center",
|
|
16999
|
-
headerHozAlign: "center",
|
|
17000
17049
|
width: 40,
|
|
17001
|
-
visible: false
|
|
17002
|
-
|
|
17003
|
-
});
|
|
17050
|
+
visible: false
|
|
17051
|
+
}));
|
|
17004
17052
|
else if (with_radio) columns.push({
|
|
17005
17053
|
formatter: "rowSelection",
|
|
17006
17054
|
field: "_check_box_state_",
|
|
@@ -17229,7 +17277,9 @@ function create_tabulator(gobj) {
|
|
|
17229
17277
|
}
|
|
17230
17278
|
});
|
|
17231
17279
|
let pkey = desc.pkey || "id";
|
|
17232
|
-
let selectable =
|
|
17280
|
+
let selectable = false;
|
|
17281
|
+
if (with_checkbox) selectable = yui_selection_settings().selectableRows;
|
|
17282
|
+
else if (with_radio) selectable = 1;
|
|
17233
17283
|
let tabulator_settings = json_deep_copy(gobj_read_attr(gobj, "tabulator_settings"));
|
|
17234
17284
|
if (gobj_read_bool_attr(gobj, "with_remote_paging")) {
|
|
17235
17285
|
let page_size = gobj_read_integer_attr(gobj, "page_size") || 200;
|
|
@@ -18211,7 +18261,7 @@ function ac_edition_mode(gobj, event, kw, src) {
|
|
|
18211
18261
|
tabulator.showColumn("_check_box_state_");
|
|
18212
18262
|
$button_new_record.removeAttribute("disabled");
|
|
18213
18263
|
$button_paste_record.removeAttribute("disabled");
|
|
18214
|
-
if (tabulator
|
|
18264
|
+
if (yui_selected_rows(tabulator).length) {
|
|
18215
18265
|
$button_delete_record.removeAttribute("disabled");
|
|
18216
18266
|
$button_copy_record.removeAttribute("disabled");
|
|
18217
18267
|
}
|
|
@@ -18269,7 +18319,7 @@ function ac_delete_rows(gobj, event, kw, src) {
|
|
|
18269
18319
|
if (refuse_if_readonly$2(gobj, event)) return -1;
|
|
18270
18320
|
let tabulator = gobj_read_attr(gobj, "tabulator");
|
|
18271
18321
|
if (json_size(kw) === 0) {
|
|
18272
|
-
let rows = tabulator
|
|
18322
|
+
let rows = yui_selected_rows(tabulator);
|
|
18273
18323
|
if (!rows.length) {
|
|
18274
18324
|
yui_shell_confirm_ok(yui_shell_of(gobj), "please select some row", {
|
|
18275
18325
|
t,
|
|
@@ -18305,7 +18355,7 @@ function ac_delete_rows(gobj, event, kw, src) {
|
|
|
18305
18355
|
* From internal
|
|
18306
18356
|
************************************************************/
|
|
18307
18357
|
function ac_copy_rows(gobj, event, kw, src) {
|
|
18308
|
-
let rows = gobj_read_attr(gobj, "tabulator")
|
|
18358
|
+
let rows = yui_selected_rows(gobj_read_attr(gobj, "tabulator"));
|
|
18309
18359
|
if (!rows.length) {
|
|
18310
18360
|
yui_shell_confirm_ok(yui_shell_of(gobj), "please select some row", {
|
|
18311
18361
|
t,
|
|
@@ -18363,7 +18413,7 @@ function ac_select_rows(gobj, event, kw, src) {
|
|
|
18363
18413
|
let $button_delete_record = $container.querySelector(`.button-delete-record`);
|
|
18364
18414
|
let $button_copy_record = $container.querySelector(`.button-copy-record`);
|
|
18365
18415
|
if ($button_delete_record) {
|
|
18366
|
-
if (tabulator
|
|
18416
|
+
if (yui_selected_rows(tabulator).length && gobj_read_bool_attr(gobj, "editable")) {
|
|
18367
18417
|
$button_delete_record.removeAttribute("disabled");
|
|
18368
18418
|
$button_copy_record.removeAttribute("disabled");
|
|
18369
18419
|
} else {
|
|
@@ -18383,7 +18433,7 @@ function ac_unselect_rows(gobj, event, kw, src) {
|
|
|
18383
18433
|
let $button_delete_record = $container.querySelector(`.button-delete-record`);
|
|
18384
18434
|
let $button_copy_record = $container.querySelector(`.button-copy-record`);
|
|
18385
18435
|
if ($button_delete_record) {
|
|
18386
|
-
if (tabulator
|
|
18436
|
+
if (yui_selected_rows(tabulator).length && gobj_read_bool_attr(gobj, "editable")) {
|
|
18387
18437
|
$button_delete_record.removeAttribute("disabled");
|
|
18388
18438
|
$button_copy_record.removeAttribute("disabled");
|
|
18389
18439
|
} else {
|
package/package.json
CHANGED
|
@@ -75,6 +75,12 @@ import {attach_clear} from "./yui_inputs.js";
|
|
|
75
75
|
|
|
76
76
|
import {yui_tabulator_lang, yui_tabulator_relocalize} from "./yui_tabulator_i18n.js";
|
|
77
77
|
|
|
78
|
+
import {
|
|
79
|
+
yui_selection_column,
|
|
80
|
+
yui_selection_settings,
|
|
81
|
+
yui_selected_rows,
|
|
82
|
+
} from "./yui_table_select.js";
|
|
83
|
+
|
|
78
84
|
import {t} from "i18next";
|
|
79
85
|
|
|
80
86
|
import {plan_treedb_writes} from "./treedb_write_plan.js";
|
|
@@ -748,16 +754,20 @@ function create_tabulator(gobj)
|
|
|
748
754
|
let with_checkbox = gobj_read_bool_attr(gobj, "with_checkbox");
|
|
749
755
|
let with_radio = gobj_read_bool_attr(gobj, "with_radio");
|
|
750
756
|
if(with_checkbox) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
757
|
+
/* The SHARED column (yui_table_select.js), not a copy of it: this
|
|
758
|
+
* table is where its two decisions were learned, and it was the one
|
|
759
|
+
* table not applying the second. Its header checkbox took
|
|
760
|
+
* `selectRow(undefined)` -- Tabulator's "every row LOADED", the ones
|
|
761
|
+
* the header filters hide included -- and the button beside it
|
|
762
|
+
* DELETES. It now ticks the active rows, the ones on screen.
|
|
763
|
+
*
|
|
764
|
+
* Still `visible: false` and still 40px wide: this table reveals the
|
|
765
|
+
* column in edit mode (`showColumn`), and the geometry is its own. */
|
|
766
|
+
columns.push(yui_selection_column({
|
|
767
|
+
field: "_check_box_state_", // WARNING _check_box_state_ widely used
|
|
768
|
+
width: 40,
|
|
769
|
+
visible: false
|
|
770
|
+
}));
|
|
761
771
|
} else if(with_radio) {
|
|
762
772
|
columns.push({
|
|
763
773
|
formatter: "rowSelection",
|
|
@@ -1098,7 +1108,12 @@ function create_tabulator(gobj)
|
|
|
1098
1108
|
* (it calls toggleSelect() directly) while disabling click-to-select,
|
|
1099
1109
|
* so opening the edit (yi-pen) form no longer implicitly ticks the
|
|
1100
1110
|
* row. Radio keeps single click-select (its own widget). */
|
|
1101
|
-
let selectable =
|
|
1111
|
+
let selectable = false;
|
|
1112
|
+
if(with_checkbox) {
|
|
1113
|
+
selectable = yui_selection_settings().selectableRows;
|
|
1114
|
+
} else if(with_radio) {
|
|
1115
|
+
selectable = 1; /* pick ONE: the radio's own widget */
|
|
1116
|
+
}
|
|
1102
1117
|
|
|
1103
1118
|
let tabulator_settings = json_deep_copy(gobj_read_attr(gobj, "tabulator_settings"));
|
|
1104
1119
|
|
|
@@ -2623,7 +2638,7 @@ function ac_edition_mode(gobj, event, kw, src)
|
|
|
2623
2638
|
$button_new_record.removeAttribute("disabled");
|
|
2624
2639
|
$button_paste_record.removeAttribute("disabled");
|
|
2625
2640
|
|
|
2626
|
-
let rows = tabulator
|
|
2641
|
+
let rows = yui_selected_rows(tabulator);
|
|
2627
2642
|
if (rows.length) {
|
|
2628
2643
|
$button_delete_record.removeAttribute("disabled");
|
|
2629
2644
|
$button_copy_record.removeAttribute("disabled");
|
|
@@ -2715,7 +2730,7 @@ function ac_delete_rows(gobj, event, kw, src)
|
|
|
2715
2730
|
/*----------------------------*
|
|
2716
2731
|
* Delete selected rows
|
|
2717
2732
|
*----------------------------*/
|
|
2718
|
-
let rows = tabulator
|
|
2733
|
+
let rows = yui_selected_rows(tabulator);
|
|
2719
2734
|
if (!rows.length) {
|
|
2720
2735
|
yui_shell_confirm_ok(
|
|
2721
2736
|
yui_shell_of(gobj), 'please select some row',
|
|
@@ -2778,7 +2793,7 @@ function ac_copy_rows(gobj, event, kw, src)
|
|
|
2778
2793
|
/*----------------------------*
|
|
2779
2794
|
* Copy selected rows
|
|
2780
2795
|
*----------------------------*/
|
|
2781
|
-
let rows = tabulator
|
|
2796
|
+
let rows = yui_selected_rows(tabulator);
|
|
2782
2797
|
if (!rows.length) {
|
|
2783
2798
|
yui_shell_confirm_ok(
|
|
2784
2799
|
yui_shell_of(gobj), 'please select some row',
|
|
@@ -2875,7 +2890,7 @@ function ac_select_rows(gobj, event, kw, src)
|
|
|
2875
2890
|
let $button_delete_record = $container.querySelector(`.button-delete-record`);
|
|
2876
2891
|
let $button_copy_record = $container.querySelector(`.button-copy-record`);
|
|
2877
2892
|
if($button_delete_record) {
|
|
2878
|
-
let selectedRows = tabulator
|
|
2893
|
+
let selectedRows = yui_selected_rows(tabulator);
|
|
2879
2894
|
if (selectedRows.length && gobj_read_bool_attr(gobj, "editable")) {
|
|
2880
2895
|
$button_delete_record.removeAttribute("disabled");
|
|
2881
2896
|
$button_copy_record.removeAttribute("disabled");
|
|
@@ -2906,7 +2921,7 @@ function ac_unselect_rows(gobj, event, kw, src)
|
|
|
2906
2921
|
let $button_delete_record = $container.querySelector(`.button-delete-record`);
|
|
2907
2922
|
let $button_copy_record = $container.querySelector(`.button-copy-record`);
|
|
2908
2923
|
if($button_delete_record) {
|
|
2909
|
-
let selectedRows = tabulator
|
|
2924
|
+
let selectedRows = yui_selected_rows(tabulator);
|
|
2910
2925
|
if (selectedRows.length && gobj_read_bool_attr(gobj, "editable")) {
|
|
2911
2926
|
$button_delete_record.removeAttribute("disabled");
|
|
2912
2927
|
$button_copy_record.removeAttribute("disabled");
|
package/src/yui_table_select.js
CHANGED
|
@@ -38,8 +38,16 @@ import {createElement2, log_error} from "@yuneta/gobj-js";
|
|
|
38
38
|
* The checkbox column. Put it FIRST in the column list.
|
|
39
39
|
*
|
|
40
40
|
* opts:
|
|
41
|
-
* field
|
|
42
|
-
* width
|
|
41
|
+
* field the (virtual) field name, default "_select"
|
|
42
|
+
* width default 44
|
|
43
|
+
* visible default true; `false` for a table that reveals
|
|
44
|
+
* the column only in an edit mode (the treedb topic
|
|
45
|
+
* table shows it with `showColumn(field)`)
|
|
46
|
+
*
|
|
47
|
+
* This is the SELECT-MANY widget. A table that lets you pick ONE
|
|
48
|
+
* row uses a radio column of its own (`formatter: "rowSelection"`
|
|
49
|
+
* with no `titleFormatter`, `selectableRows: 1`): the header
|
|
50
|
+
* checkbox, the count and the bar all mean nothing there.
|
|
43
51
|
***************************************************************/
|
|
44
52
|
function yui_selection_column(opts)
|
|
45
53
|
{
|
|
@@ -49,6 +57,7 @@ function yui_selection_column(opts)
|
|
|
49
57
|
field: o.field || "_select",
|
|
50
58
|
width: o.width || 44,
|
|
51
59
|
minWidth: o.width || 44,
|
|
60
|
+
visible: o.visible !== false,
|
|
52
61
|
hozAlign: "center",
|
|
53
62
|
headerHozAlign: "center",
|
|
54
63
|
headerSort: false,
|
|
@@ -179,10 +188,16 @@ function yui_selection_bar(t, opts)
|
|
|
179
188
|
);
|
|
180
189
|
$clear._yui_label = "clear selection";
|
|
181
190
|
|
|
191
|
+
/* NOT `is-flex` in the class list: Bulma's helpers all carry
|
|
192
|
+
* `!important`, so `is-flex` and `is-hidden` would fight as equals and
|
|
193
|
+
* the stylesheet's order would decide -- `is-flex` wins, and the bar
|
|
194
|
+
* sits there saying "0 selected" for ever. The layout goes inline (a
|
|
195
|
+
* plain declaration, which `is-hidden !important` beats whenever the
|
|
196
|
+
* class is on), and only `is-hidden` toggles. */
|
|
182
197
|
let $el = createElement2(
|
|
183
|
-
["div", {class: `${name}_SELECTION_BAR is-
|
|
198
|
+
["div", {class: `${name}_SELECTION_BAR is-align-items-center `
|
|
184
199
|
+ "is-flex-wrap-wrap mb-2 is-hidden",
|
|
185
|
-
style: "gap:0.5rem;"},
|
|
200
|
+
style: "display:flex; gap:0.5rem;"},
|
|
186
201
|
[$count].concat($buttons, [$clear])]
|
|
187
202
|
);
|
|
188
203
|
|