@yuneta/gobj-ui 7.26.43 → 7.26.44
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/dist/gobj-ui.cjs.js +2 -1
- package/dist/gobj-ui.es.js +2 -1
- package/package.json +2 -2
- package/src/c_yui_form.js +7 -1
- package/src/form_table_rows.wiring.test.js +48 -4
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -11766,7 +11766,8 @@ function create_coordinates(gobj, attrs) {
|
|
|
11766
11766
|
******************************************************************/
|
|
11767
11767
|
function create_tabulator$1(gobj, $extend, name, template) {
|
|
11768
11768
|
function get_selectable_state(row) {
|
|
11769
|
-
|
|
11769
|
+
let selectable_rows = tabulator.options.selectableRows;
|
|
11770
|
+
return (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "selectable") && (selectable_rows === true || typeof selectable_rows === "number");
|
|
11770
11771
|
}
|
|
11771
11772
|
$extend.template = template;
|
|
11772
11773
|
let tabulator_settings = (0, _yuneta_gobj_js.json_deep_copy)((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator_settings"));
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -11761,7 +11761,8 @@ function create_coordinates(gobj, attrs) {
|
|
|
11761
11761
|
******************************************************************/
|
|
11762
11762
|
function create_tabulator$1(gobj, $extend, name, template) {
|
|
11763
11763
|
function get_selectable_state(row) {
|
|
11764
|
-
|
|
11764
|
+
let selectable_rows = tabulator.options.selectableRows;
|
|
11765
|
+
return gobj_read_bool_attr(gobj, "selectable") && (selectable_rows === true || typeof selectable_rows === "number");
|
|
11765
11766
|
}
|
|
11766
11767
|
$extend.template = template;
|
|
11767
11768
|
let tabulator_settings = json_deep_copy(gobj_read_attr(gobj, "tabulator_settings"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuneta/gobj-ui",
|
|
3
|
-
"version": "7.26.
|
|
3
|
+
"version": "7.26.44",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/gobj-ui.cjs.js",
|
|
6
6
|
"module": "dist/gobj-ui.es.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@rollup/plugin-terser": "^1.0.0",
|
|
41
41
|
"@vitest/coverage-v8": "^4.1.10",
|
|
42
|
-
"@yuneta/gobj-js": "^7.26.
|
|
42
|
+
"@yuneta/gobj-js": "^7.26.22",
|
|
43
43
|
"vite": "^8.3.3",
|
|
44
44
|
"vitest": "^4.1.10"
|
|
45
45
|
},
|
package/src/c_yui_form.js
CHANGED
|
@@ -2236,8 +2236,14 @@ function create_coordinates(gobj, attrs)
|
|
|
2236
2236
|
******************************************************************/
|
|
2237
2237
|
function create_tabulator(gobj, $extend, name, template)
|
|
2238
2238
|
{
|
|
2239
|
+
/* A click selects a row only when the form is `selectable` AND its
|
|
2240
|
+
* table selects rows (`selectableRows`, off unless a host sets it in
|
|
2241
|
+
* `tabulator_settings`): toggleSelect() on a table that does not
|
|
2242
|
+
* select throws. */
|
|
2239
2243
|
function get_selectable_state(row) {
|
|
2240
|
-
|
|
2244
|
+
let selectable_rows = tabulator.options.selectableRows;
|
|
2245
|
+
return gobj_read_bool_attr(gobj, "selectable") &&
|
|
2246
|
+
(selectable_rows === true || typeof selectable_rows === "number");
|
|
2241
2247
|
}
|
|
2242
2248
|
|
|
2243
2249
|
$extend.template = template;
|
|
@@ -52,7 +52,7 @@ vi.mock("tabulator-tables", () => {
|
|
|
52
52
|
constructor($el, settings) {
|
|
53
53
|
this.element = $el;
|
|
54
54
|
this.settings = settings;
|
|
55
|
-
this.options = {};
|
|
55
|
+
this.options = Object.assign({}, settings);
|
|
56
56
|
this.handlers = {};
|
|
57
57
|
this.initialized = false;
|
|
58
58
|
this.destroyed = false;
|
|
@@ -104,6 +104,9 @@ vi.mock("tabulator-tables", () => {
|
|
|
104
104
|
row.component = {
|
|
105
105
|
getElement: () => row.$row,
|
|
106
106
|
getData: () => row.data,
|
|
107
|
+
toggleSelect: () => {
|
|
108
|
+
row.selected = !row.selected;
|
|
109
|
+
},
|
|
107
110
|
delete: () => {
|
|
108
111
|
this.delete_row(this.rows.indexOf(row));
|
|
109
112
|
},
|
|
@@ -274,16 +277,16 @@ let seq = 0;
|
|
|
274
277
|
|
|
275
278
|
/* `then(form)` runs in the same turn as the start, before any table
|
|
276
279
|
* is built. */
|
|
277
|
-
function build(rec, then)
|
|
280
|
+
function build(rec, then, extra)
|
|
278
281
|
{
|
|
279
282
|
const first = tables.length;
|
|
280
283
|
const app = gobj_create_pure_child(`trapp${++seq}`, "C_TEST_TR_APP", {}, yuno);
|
|
281
284
|
gobj_start(app);
|
|
282
|
-
const form = gobj_create_pure_child(`trform${seq}`, "C_YUI_FORM", {
|
|
285
|
+
const form = gobj_create_pure_child(`trform${seq}`, "C_YUI_FORM", Object.assign({
|
|
283
286
|
template: TEMPLATE,
|
|
284
287
|
record: rec,
|
|
285
288
|
editable: true,
|
|
286
|
-
}, app);
|
|
289
|
+
}, extra || {}), app);
|
|
287
290
|
gobj_start(form);
|
|
288
291
|
if(then) {
|
|
289
292
|
then(form);
|
|
@@ -487,3 +490,44 @@ describe("a table is loaded in one call", () => {
|
|
|
487
490
|
expect(errors()).toEqual([]);
|
|
488
491
|
});
|
|
489
492
|
});
|
|
493
|
+
|
|
494
|
+
describe("a click on a row", () => {
|
|
495
|
+
function click(alarms, index)
|
|
496
|
+
{
|
|
497
|
+
alarms.emit("rowClick", {
|
|
498
|
+
preventDefault: () => {
|
|
499
|
+
}
|
|
500
|
+
}, alarms.rows[index].component);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
test("does not WRITE the `selectable` attribute, and selects nothing when Tabulator selects no rows", async () => {
|
|
504
|
+
const {form, first} = build(record());
|
|
505
|
+
await settle();
|
|
506
|
+
const alarms = alarms_of(first);
|
|
507
|
+
click(alarms, 0);
|
|
508
|
+
expect(gobj_read_attr(form, "selectable")).toBe(true);
|
|
509
|
+
expect(alarms.rows[0].selected).toBeFalsy();
|
|
510
|
+
expect(errors()).toEqual([]);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
test("selects the row when the form is selectable and its table selects rows", async () => {
|
|
514
|
+
const {first} = build(record(), null, {tabulator_settings: {selectableRows: true}});
|
|
515
|
+
await settle();
|
|
516
|
+
const alarms = alarms_of(first);
|
|
517
|
+
click(alarms, 1);
|
|
518
|
+
expect(alarms.rows[1].selected).toBe(true);
|
|
519
|
+
expect(errors()).toEqual([]);
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
test("selects nothing when the form is not selectable", async () => {
|
|
523
|
+
const {first} = build(record(), null, {
|
|
524
|
+
selectable: false,
|
|
525
|
+
tabulator_settings: {selectableRows: true}
|
|
526
|
+
});
|
|
527
|
+
await settle();
|
|
528
|
+
const alarms = alarms_of(first);
|
|
529
|
+
click(alarms, 1);
|
|
530
|
+
expect(alarms.rows[1].selected).toBeFalsy();
|
|
531
|
+
expect(errors()).toEqual([]);
|
|
532
|
+
});
|
|
533
|
+
});
|