@yuneta/gobj-ui 7.26.45 → 7.26.47
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 +168 -17
- package/dist/gobj-ui.cjs.js +437 -43
- package/dist/gobj-ui.es.js +438 -44
- package/package.json +1 -1
- package/scripts/validate-locales.mjs +388 -56
- package/src/c_yui_form.css +9 -0
- package/src/c_yui_form.js +225 -36
- package/src/c_yui_shell.js +82 -12
- package/src/c_yui_treedb_topic_with_form.js +8 -2
- package/src/c_yui_window.js +29 -1
- package/src/form_table_rows.wiring.test.js +330 -1
- package/src/form_time_cell_editor.js +160 -0
- package/src/form_time_cell_editor.test.js +154 -0
- package/src/form_time_field.wiring.test.js +118 -0
- package/src/form_time_value.js +59 -1
- package/src/form_time_value.test.js +25 -1
- package/src/i18n_key_functions.test.js +8 -4
- package/src/shell_focus_trap.js +29 -3
- package/src/shell_focus_trap.test.js +139 -0
- package/src/shell_modals.js +2 -2
- package/src/shell_stop_overlays.wiring.test.js +175 -0
- package/src/tabulator_edit_internals.test.js +50 -0
- package/src/treedb_time_cell.wiring.test.js +103 -0
- package/src/window_rect_rounding.wiring.test.js +52 -1
- package/src/yui_tabulator_i18n.js +18 -7
- package/src/yui_tabulator_i18n.test.js +36 -0
package/dist/gobj-ui.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SDATA, SDATA_END, clean_name, createElement2, createOneHtml, create_template_record, data_type_t, debounce, delete_from_list, duplicate_objects, empty_json, empty_string, escapeHtml, event_flag_t, flat_diff, gclass_create, gclass_find_by_name, gclass_flag_t, getPositionRelativeToBody, gobj_bottom_gobj, gobj_change_state, gobj_command, gobj_create, gobj_create_pure_child, gobj_create_service, gobj_current_state, gobj_destroy, gobj_find_child, gobj_find_service, gobj_full_name, gobj_gclass_name, gobj_get_gclass_trace_level2, gobj_global_trace_level, gobj_global_trace_no_level, gobj_has_event, gobj_is_destroying, gobj_is_playing, gobj_is_pure_child, gobj_is_running, gobj_is_service, gobj_is_volatil, gobj_match_children, gobj_name, gobj_parent, gobj_post_event, gobj_publish_event, gobj_read_attr, gobj_read_bool_attr, gobj_read_integer_attr, gobj_read_pointer_attr, gobj_read_str_attr, gobj_save_persistent_attrs, gobj_send_event, gobj_set_trace_machine_format, gobj_short_name, gobj_start, gobj_start_tree, gobj_stop, gobj_stop_children, gobj_subscribe_event, gobj_unsubscribe_event, gobj_write_attr, gobj_write_bool_attr, gobj_write_integer_attr, gobj_write_str_attr, gobj_yuno, gobj_yuno_name, html_markup, is_array, is_boolean, is_date, is_gobj, is_null, is_number, is_object, is_string, json2flat, json_deep_copy, json_is_identical, json_object_size, json_object_update, json_object_update_missing, json_size, kw_clone_by_keys, kw_flag_t, kw_get_dict, kw_get_dict_value, kw_get_int, kw_get_local_storage_value, kw_get_str, kw_has_key, kw_set_dict_value, kw_set_local_storage_value, kwid_find_one_record, kwid_new_dict, log_error, log_warning, msg_iev_get_stack, parseBoolean, parseSVG, refresh_language, safeSrc, sdata_flag_t, set_console_log_enabled, set_log_callback, sprintf, str_in_list, template_get_field_desc, trace_level_t, trace_msg, treedb_decoder_fkey, treedb_encoder_fkey, treedb_get_field_desc, treedb_hook_data_size } from "@yuneta/gobj-js";
|
|
1
|
+
import { SDATA, SDATA_END, clean_name, createElement2, createOneHtml, create_template_record, data_type_t, debounce, delete_from_list, duplicate_objects, empty_json, empty_string, escapeHtml, event_flag_t, flat_diff, gclass_create, gclass_find_by_name, gclass_flag_t, getPositionRelativeToBody, gobj_bottom_gobj, gobj_change_state, gobj_command, gobj_create, gobj_create_pure_child, gobj_create_service, gobj_current_state, gobj_destroy, gobj_find_child, gobj_find_service, gobj_full_name, gobj_gclass_name, gobj_get_gclass_trace_level2, gobj_global_trace_level, gobj_global_trace_no_level, gobj_has_event, gobj_is_destroying, gobj_is_playing, gobj_is_pure_child, gobj_is_running, gobj_is_service, gobj_is_volatil, gobj_match_children, gobj_name, gobj_parent, gobj_post_event, gobj_publish_event, gobj_read_attr, gobj_read_bool_attr, gobj_read_integer_attr, gobj_read_pointer_attr, gobj_read_str_attr, gobj_save_persistent_attrs, gobj_send_event, gobj_set_trace_machine_format, gobj_short_name, gobj_start, gobj_start_tree, gobj_stop, gobj_stop_children, gobj_subscribe_event, gobj_unsubscribe_event, gobj_write_attr, gobj_write_bool_attr, gobj_write_integer_attr, gobj_write_str_attr, gobj_yuno, gobj_yuno_name, html_markup, is_array, is_boolean, is_date, is_gobj, is_null, is_number, is_object, is_string, json2flat, json_deep_copy, json_is_identical, json_object_size, json_object_update, json_object_update_missing, json_size, kw_clone_by_keys, kw_flag_t, kw_get_dict, kw_get_dict_value, kw_get_int, kw_get_local_storage_value, kw_get_str, kw_has_key, kw_remove_local_storage_value, kw_set_dict_value, kw_set_local_storage_value, kwid_find_one_record, kwid_new_dict, log_error, log_warning, msg_iev_get_stack, parseBoolean, parseSVG, refresh_language, safeSrc, sdata_flag_t, set_console_log_enabled, set_log_callback, sprintf, str_in_list, template_get_field_desc, trace_level_t, trace_msg, treedb_decoder_fkey, treedb_encoder_fkey, treedb_get_field_desc, treedb_hook_data_size } from "@yuneta/gobj-js";
|
|
2
2
|
import i18next, { t } from "i18next";
|
|
3
3
|
import TomSelect from "tom-select";
|
|
4
4
|
import { createJSONEditor } from "vanilla-jsoneditor";
|
|
@@ -134,7 +134,17 @@ function yui_tint(colour) {
|
|
|
134
134
|
* that wrapped to it, did nothing and was prevented -- the
|
|
135
135
|
* keyboard never got into the dialog.
|
|
136
136
|
*
|
|
137
|
-
*
|
|
137
|
+
* A trap whose panel is out of the document is not the top:
|
|
138
|
+
* the top is the highest trap whose panel is in it. Up to
|
|
139
|
+
* gobj-ui 7.26.45 a trap left behind by an owner torn down with
|
|
140
|
+
* it stayed the top: every window opened later believed itself
|
|
141
|
+
* under an overlay and took no focus, and a live trap under it
|
|
142
|
+
* no longer heard Tab. 7.26.46 dropped such a trap from the
|
|
143
|
+
* stack, which was for good: a panel that only moved (taken out
|
|
144
|
+
* and put back, its trap never released) lost its trap. It is
|
|
145
|
+
* skipped now, and leaves the stack only by its release().
|
|
146
|
+
*
|
|
147
|
+
* No gobj dependency: only gobj-js's logger. The optional
|
|
138
148
|
* second argument lets callers inject a mock document object
|
|
139
149
|
* for unit tests.
|
|
140
150
|
*
|
|
@@ -143,6 +153,13 @@ function yui_tint(colour) {
|
|
|
143
153
|
***********************************************************************/
|
|
144
154
|
var FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
145
155
|
var __trap_stack__ = [];
|
|
156
|
+
function top_trap() {
|
|
157
|
+
for (let i = __trap_stack__.length - 1; i >= 0; i--) {
|
|
158
|
+
let trap = __trap_stack__[i];
|
|
159
|
+
if (trap.$panel.isConnected !== false) return trap;
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
146
163
|
function is_drawn(el) {
|
|
147
164
|
if (typeof el.checkVisibility === "function") return el.checkVisibility();
|
|
148
165
|
if (typeof el.getClientRects === "function") return el.getClientRects().length > 0;
|
|
@@ -167,7 +184,7 @@ function activate_focus_trap_on($panel, doc) {
|
|
|
167
184
|
let released = false;
|
|
168
185
|
let trap = function(ev) {
|
|
169
186
|
if (ev.key !== "Tab" && ev.keyCode !== 9) return;
|
|
170
|
-
if (
|
|
187
|
+
if (top_trap() !== trap) return;
|
|
171
188
|
let nodes = focusables_of($panel);
|
|
172
189
|
if (nodes.length === 0) return;
|
|
173
190
|
let first = nodes[0];
|
|
@@ -205,7 +222,7 @@ function activate_focus_trap_on($panel, doc) {
|
|
|
205
222
|
* where it cannot be seen, and the next Tab would give it back.
|
|
206
223
|
***************************************************************/
|
|
207
224
|
function focus_trap_panel() {
|
|
208
|
-
let top =
|
|
225
|
+
let top = top_trap();
|
|
209
226
|
return top ? top.$panel : null;
|
|
210
227
|
}
|
|
211
228
|
//#endregion
|
|
@@ -1411,6 +1428,7 @@ function mt_start$21(gobj) {
|
|
|
1411
1428
|
function mt_stop$20(gobj) {
|
|
1412
1429
|
let priv = gobj.priv;
|
|
1413
1430
|
if (!priv) return 0;
|
|
1431
|
+
retire_overlays(gobj);
|
|
1414
1432
|
close_toolbar_dropdown(gobj);
|
|
1415
1433
|
if (priv.hash_handler) {
|
|
1416
1434
|
window.removeEventListener("hashchange", priv.hash_handler);
|
|
@@ -1465,6 +1483,7 @@ function mt_stop$20(gobj) {
|
|
|
1465
1483
|
* Framework Method: Destroy
|
|
1466
1484
|
***************************************************************/
|
|
1467
1485
|
function mt_destroy$22(gobj) {
|
|
1486
|
+
retire_overlays(gobj);
|
|
1468
1487
|
close_toolbar_dropdown(gobj);
|
|
1469
1488
|
let live_idx = __live_shells__.indexOf(gobj);
|
|
1470
1489
|
if (live_idx >= 0) __live_shells__.splice(live_idx, 1);
|
|
@@ -2565,7 +2584,7 @@ function open_toolbar_dropdown(gobj, item, action, $trigger) {
|
|
|
2565
2584
|
$panel.__yui_backdrop_handler__ = backdrop;
|
|
2566
2585
|
$panel.__yui_dismiss_handler__ = dismiss;
|
|
2567
2586
|
$panel.__yui_trigger__ = $trigger || null;
|
|
2568
|
-
push_escape(gobj, "popup", close_fn);
|
|
2587
|
+
push_escape(gobj, "popup", close_fn, close_fn);
|
|
2569
2588
|
$panel.__yui_focus_release__ = activate_focus_trap_on($panel);
|
|
2570
2589
|
if ($trigger) $trigger.setAttribute("aria-expanded", "true");
|
|
2571
2590
|
priv.active_dropdown = $panel;
|
|
@@ -2730,8 +2749,12 @@ function take_back_focus(ev) {
|
|
|
2730
2749
|
* only and consumes the event; LIFO ordering naturally matches
|
|
2731
2750
|
* the z-index layering most apps use (drawer at the bottom,
|
|
2732
2751
|
* modal on top, popup on top of that).
|
|
2752
|
+
*
|
|
2753
|
+
* `teardown` is the overlay's UNCONDITIONAL close, what the shell
|
|
2754
|
+
* runs when it stops with the overlay still up (close_overlays);
|
|
2755
|
+
* `handler` may be a guarded one (a modal's before_close).
|
|
2733
2756
|
************************************************************/
|
|
2734
|
-
function push_escape(gobj, layer, handler) {
|
|
2757
|
+
function push_escape(gobj, layer, handler, teardown) {
|
|
2735
2758
|
let priv = gobj.priv;
|
|
2736
2759
|
if (!priv || !priv.escape_stack) {
|
|
2737
2760
|
log_warning(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
|
|
@@ -2741,9 +2764,53 @@ function push_escape(gobj, layer, handler) {
|
|
|
2741
2764
|
priv.escape_stack.push({
|
|
2742
2765
|
layer,
|
|
2743
2766
|
handler,
|
|
2767
|
+
teardown: typeof teardown === "function" ? teardown : null,
|
|
2744
2768
|
seq: priv.escape_seq
|
|
2745
2769
|
});
|
|
2746
2770
|
}
|
|
2771
|
+
/************************************************************
|
|
2772
|
+
* Close every overlay still up, the top first, as if each had
|
|
2773
|
+
* been dismissed: a shell that stops -- a logout, a session cut
|
|
2774
|
+
* -- with a drawer, a modal or a question open. Up to gobj-ui
|
|
2775
|
+
* 7.26.45 only the toolbar dropdown was closed: the others kept
|
|
2776
|
+
* their focus trap, and every window opened afterwards believed
|
|
2777
|
+
* itself under an overlay and took no focus; a question never
|
|
2778
|
+
* answered. Run before the views stop, so what an overlay's
|
|
2779
|
+
* on_close calls is still alive. An overlay pushed with no
|
|
2780
|
+
* teardown is left to its owner.
|
|
2781
|
+
************************************************************/
|
|
2782
|
+
function close_overlays(gobj) {
|
|
2783
|
+
let priv = gobj.priv;
|
|
2784
|
+
if (!priv || !priv.escape_stack) return;
|
|
2785
|
+
let entries = priv.escape_stack.slice().reverse();
|
|
2786
|
+
for (let entry of entries) {
|
|
2787
|
+
if (!entry.teardown) continue;
|
|
2788
|
+
try {
|
|
2789
|
+
entry.teardown();
|
|
2790
|
+
} catch (e) {
|
|
2791
|
+
log_warning(`C_YUI_SHELL: closing the '${entry.layer}' overlay at stop failed: ${e}`);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
/************************************************************
|
|
2796
|
+
* What a shell that stops does with its overlays: their
|
|
2797
|
+
* history markers are left where they are, and then they are
|
|
2798
|
+
* closed (close_overlays). The overlay stack is emptied FIRST,
|
|
2799
|
+
* so no close -- of an overlay closed here, or of a window
|
|
2800
|
+
* closed later -- retires its marker with a history.back().
|
|
2801
|
+
* Such a back() is asynchronous and a stopped shell no longer
|
|
2802
|
+
* hears where it lands: up to gobj-ui 7.26.46 a logout followed
|
|
2803
|
+
* by a new shell in the same turn had it taken by the new
|
|
2804
|
+
* shell's first window (Chromium stepped back off that window's
|
|
2805
|
+
* marker, Firefox dropped the back()), and the next Back left
|
|
2806
|
+
* the page. A marker left in place is inert, as a drained one
|
|
2807
|
+
* is: a later Back lands on it and is absorbed.
|
|
2808
|
+
************************************************************/
|
|
2809
|
+
function retire_overlays(gobj) {
|
|
2810
|
+
let priv = gobj.priv;
|
|
2811
|
+
if (priv && priv.overlay_stack) priv.overlay_stack.splice(0);
|
|
2812
|
+
close_overlays(gobj);
|
|
2813
|
+
}
|
|
2747
2814
|
function pop_escape(gobj, handler) {
|
|
2748
2815
|
let priv = gobj.priv;
|
|
2749
2816
|
if (!priv || !priv.escape_stack) return;
|
|
@@ -2953,7 +3020,7 @@ function open_drawer_one(gobj, $c) {
|
|
|
2953
3020
|
if ($c.classList.contains("is-active")) return;
|
|
2954
3021
|
let close_fn = () => close_drawer_one(gobj, $c);
|
|
2955
3022
|
$c.__yui_close_handler__ = close_fn;
|
|
2956
|
-
push_escape(gobj, "overlay", close_fn);
|
|
3023
|
+
push_escape(gobj, "overlay", close_fn, close_fn);
|
|
2957
3024
|
$c.classList.add("is-active");
|
|
2958
3025
|
$c.__yui_focus_release__ = activate_focus_trap_on($c.querySelector(".yui-drawer-panel") || $c);
|
|
2959
3026
|
}
|
|
@@ -3655,8 +3722,8 @@ function yui_shell_close_drawer(shell_gobj, menu_id) {
|
|
|
3655
3722
|
function yui_shell_toggle_drawer(shell_gobj, menu_id) {
|
|
3656
3723
|
toggle_drawer(shell_gobj, menu_id);
|
|
3657
3724
|
}
|
|
3658
|
-
function yui_shell_push_escape(shell_gobj, layer, handler) {
|
|
3659
|
-
push_escape(shell_gobj, layer, handler);
|
|
3725
|
+
function yui_shell_push_escape(shell_gobj, layer, handler, teardown) {
|
|
3726
|
+
push_escape(shell_gobj, layer, handler, teardown);
|
|
3660
3727
|
}
|
|
3661
3728
|
function yui_shell_pop_escape(shell_gobj, handler) {
|
|
3662
3729
|
pop_escape(shell_gobj, handler);
|
|
@@ -4265,7 +4332,7 @@ function yui_shell_show_modal(shell, content, opts) {
|
|
|
4265
4332
|
});
|
|
4266
4333
|
};
|
|
4267
4334
|
escape_handler = request_close;
|
|
4268
|
-
yui_shell_push_escape(shell, "modal", request_close);
|
|
4335
|
+
yui_shell_push_escape(shell, "modal", request_close, do_close);
|
|
4269
4336
|
overlay = yui_shell_register_overlay(shell, on_back);
|
|
4270
4337
|
release_focus = activate_focus_trap_on($modal);
|
|
4271
4338
|
if (opts == null || opts.dismiss_on_background !== false) $modal.querySelector(".modal-background").addEventListener("click", request_close);
|
|
@@ -4420,7 +4487,7 @@ function build_dialog(shell, message, buttons, opts) {
|
|
|
4420
4487
|
resolve(value);
|
|
4421
4488
|
};
|
|
4422
4489
|
close_fn = () => close(dismiss_value);
|
|
4423
|
-
yui_shell_push_escape(shell, "modal", close_fn);
|
|
4490
|
+
yui_shell_push_escape(shell, "modal", close_fn, close_fn);
|
|
4424
4491
|
overlay = yui_shell_register_overlay(shell, close_fn);
|
|
4425
4492
|
release_focus = activate_focus_trap_on($modal.querySelector(".modal-card"));
|
|
4426
4493
|
$modal.querySelector(".modal-background").addEventListener("click", () => close(dismiss_value));
|
|
@@ -5032,9 +5099,15 @@ function build_ui$18(gobj) {
|
|
|
5032
5099
|
if (gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
|
|
5033
5100
|
if (gobj_is_service(gobj)) {
|
|
5034
5101
|
let key = `${gobj_name(gobj)}-rect`;
|
|
5035
|
-
let
|
|
5036
|
-
|
|
5037
|
-
|
|
5102
|
+
let rect = whole_rect(kw_get_local_storage_value(key));
|
|
5103
|
+
if (!rect && local_storage_holds(key)) {
|
|
5104
|
+
log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
|
|
5105
|
+
kw_remove_local_storage_value(key);
|
|
5106
|
+
} else if (rect && (rect.width <= 0 || rect.height <= 0)) {
|
|
5107
|
+
log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' has no size (${rect.width} x ${rect.height}): ignored`);
|
|
5108
|
+
kw_remove_local_storage_value(key);
|
|
5109
|
+
rect = null;
|
|
5110
|
+
}
|
|
5038
5111
|
if (rect) {
|
|
5039
5112
|
rect.x = rect.x < 0 ? 0 : rect.x;
|
|
5040
5113
|
rect.y = rect.y < 0 ? 0 : rect.y;
|
|
@@ -5474,6 +5547,17 @@ function min$1(gobj) {
|
|
|
5474
5547
|
return rect;
|
|
5475
5548
|
}
|
|
5476
5549
|
/************************************************************
|
|
5550
|
+
* Whether localStorage holds anything under `key`, readable
|
|
5551
|
+
* or not.
|
|
5552
|
+
************************************************************/
|
|
5553
|
+
function local_storage_holds(key) {
|
|
5554
|
+
try {
|
|
5555
|
+
return window.localStorage.getItem(key) !== null;
|
|
5556
|
+
} catch (e) {
|
|
5557
|
+
return false;
|
|
5558
|
+
}
|
|
5559
|
+
}
|
|
5560
|
+
/************************************************************
|
|
5477
5561
|
* The rect of a window in whole pixels: x, y, width and height
|
|
5478
5562
|
* are DTP_INTEGER, and getBoundingClientRect() answers fractions
|
|
5479
5563
|
* under a zoom or a device pixel ratio (an integer attr refuses
|
|
@@ -7802,8 +7886,14 @@ function yui_tabulator_name_filters(table, t) {
|
|
|
7802
7886
|
* from `yui_tabulator_relocalize()` so a language change
|
|
7803
7887
|
* reaches them.
|
|
7804
7888
|
*
|
|
7805
|
-
* It matches Tabulator's OWN literal and
|
|
7806
|
-
* view named itself is
|
|
7889
|
+
* It matches Tabulator's OWN literal, and the boxes it named itself
|
|
7890
|
+
* (they carry `data-yui-row-select`), so a box a view named itself is
|
|
7891
|
+
* left alone. Up to 7.26.46 it matched only the literal: a box named
|
|
7892
|
+
* once was never found again, and a language change through
|
|
7893
|
+
* yui_tabulator_relocalize() left it in the old language.
|
|
7894
|
+
*
|
|
7895
|
+
* The box in the HEADER selects every row, and is named so
|
|
7896
|
+
* ("select all rows"); up to 7.26.46 it was "select row" too.
|
|
7807
7897
|
***************************************************************/
|
|
7808
7898
|
var TABULATOR_ROW_SELECT_ARIA = "Select Row";
|
|
7809
7899
|
function yui_tabulator_name_row_selects(table, t) {
|
|
@@ -7814,12 +7904,16 @@ function yui_tabulator_name_row_selects(table, t) {
|
|
|
7814
7904
|
log_warning("yui_tabulator_name_row_selects: table has no element: its row-selection boxes keep Tabulator's English name");
|
|
7815
7905
|
return;
|
|
7816
7906
|
}
|
|
7817
|
-
let boxes = $el.querySelectorAll(`input[type=checkbox][aria-label="${TABULATOR_ROW_SELECT_ARIA}"]`);
|
|
7907
|
+
let boxes = $el.querySelectorAll(`input[type=checkbox][aria-label="${TABULATOR_ROW_SELECT_ARIA}"], input[type=checkbox][data-yui-row-select]`);
|
|
7818
7908
|
for (let $box of boxes) {
|
|
7819
|
-
$box.
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
$box.setAttribute("
|
|
7909
|
+
let all = typeof $box.closest === "function" && !!$box.closest(".tabulator-header");
|
|
7910
|
+
let name = all ? t("select all rows") : t("select row");
|
|
7911
|
+
let key = all ? "select all rows" : "select row";
|
|
7912
|
+
$box.setAttribute("aria-label", name);
|
|
7913
|
+
$box.setAttribute("data-i18n-aria-label", key);
|
|
7914
|
+
$box.setAttribute("title", name);
|
|
7915
|
+
$box.setAttribute("data-i18n-title", key);
|
|
7916
|
+
$box.setAttribute("data-yui-row-select", "");
|
|
7823
7917
|
}
|
|
7824
7918
|
} catch (e) {}
|
|
7825
7919
|
}
|
|
@@ -9672,6 +9766,170 @@ function datetime_local_to_epoch(value) {
|
|
|
9672
9766
|
if (isNaN(date.getTime())) return null;
|
|
9673
9767
|
return Math.floor(date.getTime() / 1e3);
|
|
9674
9768
|
}
|
|
9769
|
+
/************************************************************
|
|
9770
|
+
* The value of a time column -> a Date, or null when it holds
|
|
9771
|
+
* none. A `string` column holds an ISO text, any other an epoch
|
|
9772
|
+
* in SECONDS. The form's time field and the cell editor of a
|
|
9773
|
+
* table read it here, so the two agree: up to gobj-ui 7.26.46 the
|
|
9774
|
+
* field read every column with parseInt -- an ISO text as the
|
|
9775
|
+
* year 2026 in SECONDS, in January 1970 -- and showed an empty
|
|
9776
|
+
* one as January 1970 too, which a save then wrote back as 0.
|
|
9777
|
+
************************************************************/
|
|
9778
|
+
function time_value_to_date(value, real_type) {
|
|
9779
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
9780
|
+
let date = real_type === "string" ? new Date(String(value)) : /* @__PURE__ */ new Date(Number(value) * 1e3);
|
|
9781
|
+
return isNaN(date.getTime()) ? null : date;
|
|
9782
|
+
}
|
|
9783
|
+
/************************************************************
|
|
9784
|
+
* An epoch in seconds (null: no time) -> the value of a time
|
|
9785
|
+
* column: an ISO text for a `string` column, the epoch for any
|
|
9786
|
+
* other. Up to gobj-ui 7.26.46 the field wrote the epoch into a
|
|
9787
|
+
* `string` column too.
|
|
9788
|
+
************************************************************/
|
|
9789
|
+
function epoch_to_time_value(epoch, real_type) {
|
|
9790
|
+
if (epoch === null || epoch === void 0) return null;
|
|
9791
|
+
if (typeof epoch !== "number" || !Number.isFinite(epoch)) return epoch;
|
|
9792
|
+
if (real_type === "string") return (/* @__PURE__ */ new Date(epoch * 1e3)).toISOString();
|
|
9793
|
+
return epoch;
|
|
9794
|
+
}
|
|
9795
|
+
/************************************************************
|
|
9796
|
+
* The value of a time column as a table cell shows it: the
|
|
9797
|
+
* local clock the editor opens on, "YYYY-MM-DD HH:mm:ss", as
|
|
9798
|
+
* fmt_epoch() of yui_time.js writes a timestamp in a table. ""
|
|
9799
|
+
* for no time; a value that is not one is shown as it is, so the
|
|
9800
|
+
* reader sees what the column holds.
|
|
9801
|
+
************************************************************/
|
|
9802
|
+
function time_value_to_text(value, real_type) {
|
|
9803
|
+
let date = time_value_to_date(value, real_type);
|
|
9804
|
+
if (!date) return value === null || value === void 0 ? "" : String(value);
|
|
9805
|
+
return date_to_datetime_local(date).replace("T", " ");
|
|
9806
|
+
}
|
|
9807
|
+
//#endregion
|
|
9808
|
+
//#region src/form_time_cell_editor.js
|
|
9809
|
+
/****************************************************************************
|
|
9810
|
+
* form_time_cell_editor.js
|
|
9811
|
+
*
|
|
9812
|
+
* The cell editor of a `time` / `now` column in a table of
|
|
9813
|
+
* C_YUI_FORM: a `datetime-local` box, as the form's own time
|
|
9814
|
+
* field, converting with the same helpers (form_time_value.js)
|
|
9815
|
+
* -- an epoch in SECONDS for an integer column, an ISO text
|
|
9816
|
+
* for a string one -- and to the second (`step` 1).
|
|
9817
|
+
*
|
|
9818
|
+
* Up to gobj-ui 7.26.45 the column used Tabulator's `datetime`
|
|
9819
|
+
* editor with a `format`, which needs luxon, and nothing gives
|
|
9820
|
+
* gobj-ui luxon: the editor said "'date' editor 'format' param
|
|
9821
|
+
* is dependant on luxon.js" in the console, opened empty, and
|
|
9822
|
+
* threw when it was committed. Its format ("dd/MM/yyyy hh:mm",
|
|
9823
|
+
* 12-hour) could not have read an epoch either. Luxon is not
|
|
9824
|
+
* taken in for it: one editor is not worth a dependency every
|
|
9825
|
+
* app would have to dedupe, and the conversion it needs is the
|
|
9826
|
+
* one the form already makes.
|
|
9827
|
+
*
|
|
9828
|
+
* It behaves as Tabulator's own: `elementAttributes` are
|
|
9829
|
+
* written on the box (the column's name, see
|
|
9830
|
+
* yui_tabulator_name_editor), a true blur or Enter commits,
|
|
9831
|
+
* Escape cancels, `verticalNavigation: "editor"` keeps the
|
|
9832
|
+
* arrows, and a value that did not change is a cancel.
|
|
9833
|
+
*
|
|
9834
|
+
* A date with a part cleared is NOT a value: the box answers
|
|
9835
|
+
* `value ""` for it, as for an empty box, and only
|
|
9836
|
+
* `validity.badInput` tells them apart. Enter leaves the
|
|
9837
|
+
* editor open with `aria-invalid` until the date is whole
|
|
9838
|
+
* again (or Escape); a blur cancels, and the cell keeps what
|
|
9839
|
+
* it had. Up to gobj-ui 7.26.46 both committed null: one
|
|
9840
|
+
* Backspace and Enter erased the stored time. To clear a time
|
|
9841
|
+
* on purpose, clear EVERY part of the box: an empty box
|
|
9842
|
+
* commits null. (Inside the box Tab moves between its parts,
|
|
9843
|
+
* as the browser does: it does not leave the cell.)
|
|
9844
|
+
*
|
|
9845
|
+
* Copyright (c) 2026, ArtGins.
|
|
9846
|
+
* All Rights Reserved.
|
|
9847
|
+
****************************************************************************/
|
|
9848
|
+
/************************************************************
|
|
9849
|
+
* A cell's value -> the text of the box ("" when empty).
|
|
9850
|
+
************************************************************/
|
|
9851
|
+
function time_to_datetime_local(value, real_type) {
|
|
9852
|
+
return date_to_datetime_local(time_value_to_date(value, real_type));
|
|
9853
|
+
}
|
|
9854
|
+
/************************************************************
|
|
9855
|
+
* The text of the box -> the cell's value (null when empty).
|
|
9856
|
+
************************************************************/
|
|
9857
|
+
function datetime_local_to_time(text, real_type) {
|
|
9858
|
+
return epoch_to_time_value(datetime_local_to_epoch(text), real_type);
|
|
9859
|
+
}
|
|
9860
|
+
/************************************************************
|
|
9861
|
+
* The editor of a time column whose values are `real_type`
|
|
9862
|
+
* ("integer": epoch seconds; "string": ISO text).
|
|
9863
|
+
************************************************************/
|
|
9864
|
+
function form_time_cell_editor(real_type) {
|
|
9865
|
+
return function(cell, onRendered, success, cancel, editorParams) {
|
|
9866
|
+
let params = editorParams || {};
|
|
9867
|
+
let vertical = params.verticalNavigation || "editor";
|
|
9868
|
+
let original = cell.getValue();
|
|
9869
|
+
let original_text = time_to_datetime_local(original, real_type);
|
|
9870
|
+
let input = document.createElement("input");
|
|
9871
|
+
input.type = "datetime-local";
|
|
9872
|
+
input.setAttribute("step", "1");
|
|
9873
|
+
input.style.padding = "4px";
|
|
9874
|
+
input.style.width = "100%";
|
|
9875
|
+
input.style.boxSizing = "border-box";
|
|
9876
|
+
let attrs = params.elementAttributes;
|
|
9877
|
+
if (attrs && typeof attrs === "object") for (let key of Object.keys(attrs)) input.setAttribute(key, attrs[key]);
|
|
9878
|
+
input.value = original_text;
|
|
9879
|
+
onRendered(function() {
|
|
9880
|
+
if (cell.getType() === "cell") {
|
|
9881
|
+
input.focus({ preventScroll: true });
|
|
9882
|
+
input.style.height = "100%";
|
|
9883
|
+
}
|
|
9884
|
+
});
|
|
9885
|
+
let incomplete = function() {
|
|
9886
|
+
return !!(input.validity && input.validity.badInput);
|
|
9887
|
+
};
|
|
9888
|
+
let commit = function(from_blur) {
|
|
9889
|
+
if (incomplete()) {
|
|
9890
|
+
if (from_blur) cancel();
|
|
9891
|
+
else input.setAttribute("aria-invalid", "true");
|
|
9892
|
+
return;
|
|
9893
|
+
}
|
|
9894
|
+
if (input.value === original_text) {
|
|
9895
|
+
cancel();
|
|
9896
|
+
return;
|
|
9897
|
+
}
|
|
9898
|
+
let value = datetime_local_to_time(input.value, real_type);
|
|
9899
|
+
if (value === original || value === null && original_text === "") {
|
|
9900
|
+
cancel();
|
|
9901
|
+
return;
|
|
9902
|
+
}
|
|
9903
|
+
success(value);
|
|
9904
|
+
};
|
|
9905
|
+
input.addEventListener("blur", function(e) {
|
|
9906
|
+
if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit(true);
|
|
9907
|
+
});
|
|
9908
|
+
input.addEventListener("input", function() {
|
|
9909
|
+
if (!incomplete()) input.removeAttribute("aria-invalid");
|
|
9910
|
+
});
|
|
9911
|
+
input.addEventListener("keydown", function(e) {
|
|
9912
|
+
switch (e.key) {
|
|
9913
|
+
case "Enter":
|
|
9914
|
+
commit(false);
|
|
9915
|
+
break;
|
|
9916
|
+
case "Escape":
|
|
9917
|
+
cancel();
|
|
9918
|
+
break;
|
|
9919
|
+
case "End":
|
|
9920
|
+
case "Home":
|
|
9921
|
+
e.stopPropagation();
|
|
9922
|
+
break;
|
|
9923
|
+
case "ArrowUp":
|
|
9924
|
+
case "ArrowDown": if (vertical === "editor") {
|
|
9925
|
+
e.stopImmediatePropagation();
|
|
9926
|
+
e.stopPropagation();
|
|
9927
|
+
}
|
|
9928
|
+
}
|
|
9929
|
+
});
|
|
9930
|
+
return input;
|
|
9931
|
+
};
|
|
9932
|
+
}
|
|
9675
9933
|
//#endregion
|
|
9676
9934
|
//#region src/form_json_field.js
|
|
9677
9935
|
/***********************************************************************
|
|
@@ -10098,7 +10356,7 @@ var attrs_table$17 = [
|
|
|
10098
10356
|
SDATA(data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
|
|
10099
10357
|
SDATA(data_type_t.DTP_BOOLEAN, "readonly", 0, false, "Show EVERY field read-only, whatever its schema says: a record being LOOKED at, not edited. Independent of `editable`, which drives the TABLE rendering; this one drives the FORM"),
|
|
10100
10358
|
SDATA(data_type_t.DTP_BOOLEAN, "selectable", 0, true, "A click selects a row, when tabulator_settings selects rows (selectableRows)"),
|
|
10101
|
-
SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows"),
|
|
10359
|
+
SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows (hidden while the form is not `selectable`)"),
|
|
10102
10360
|
SDATA(data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
|
|
10103
10361
|
SDATA(data_type_t.DTP_BOOLEAN, "with_delete_row_btn", 0, false, "Print last column with delete row button"),
|
|
10104
10362
|
SDATA(data_type_t.DTP_JSON, "toolbar", 0, DEFAULT_TOOLBAR.slice(), "Toolbar buttons to show. The order inside each group is the order given here; which side each group takes is form_toolbar_plan.js. [] hides the toolbar"),
|
|
@@ -10120,7 +10378,9 @@ var PRIVATE_DATA$17 = {
|
|
|
10120
10378
|
tables: null,
|
|
10121
10379
|
table_seq: 0,
|
|
10122
10380
|
json_names_posted: false,
|
|
10123
|
-
lang_shell: null
|
|
10381
|
+
lang_shell: null,
|
|
10382
|
+
change_seq: 0,
|
|
10383
|
+
cell_edit: null
|
|
10124
10384
|
};
|
|
10125
10385
|
var __gclass__$17 = null;
|
|
10126
10386
|
/***************************
|
|
@@ -10139,6 +10399,16 @@ function mt_create$17(gobj) {
|
|
|
10139
10399
|
build_ui$15(gobj);
|
|
10140
10400
|
}
|
|
10141
10401
|
/************************************************************
|
|
10402
|
+
* Framework Method writing
|
|
10403
|
+
************************************************************/
|
|
10404
|
+
function mt_writing$2(gobj, path) {
|
|
10405
|
+
if (path === "selectable") {
|
|
10406
|
+
let $container = gobj_read_attr(gobj, "$container");
|
|
10407
|
+
if (!$container) return;
|
|
10408
|
+
for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) if ($table.tabulator) show_row_selection(gobj, $table.tabulator);
|
|
10409
|
+
}
|
|
10410
|
+
}
|
|
10411
|
+
/************************************************************
|
|
10142
10412
|
* Framework Method destroy
|
|
10143
10413
|
* In this point, all children
|
|
10144
10414
|
* and subscriptions are already deleted.
|
|
@@ -10176,6 +10446,7 @@ function mt_stop$17(gobj) {
|
|
|
10176
10446
|
* not switched here: they always say it (create_tabulator).
|
|
10177
10447
|
************************************************************/
|
|
10178
10448
|
function set_changed_stated(gobj, changed) {
|
|
10449
|
+
gobj.priv.change_seq += 1;
|
|
10179
10450
|
let $container = gobj_read_attr(gobj, "$container");
|
|
10180
10451
|
$container.querySelector("form");
|
|
10181
10452
|
const enable = ($btn, on, color) => {
|
|
@@ -10515,10 +10786,28 @@ function destroy_widget(gobj, what, widget) {
|
|
|
10515
10786
|
* walks the rows already wiped: a reload, a Clear or a destroy
|
|
10516
10787
|
* with an editor open in any row but the first threw, and left
|
|
10517
10788
|
* the table half wiped.
|
|
10789
|
+
*
|
|
10790
|
+
* Tabulator has no public way to ask which cell is edited: this
|
|
10791
|
+
* reads its edit module (`modules.edit`, `currentCell`,
|
|
10792
|
+
* `cancelEdit()`), names pinned against the installed Tabulator
|
|
10793
|
+
* by tabulator_edit_internals.test.js. A Tabulator without them
|
|
10794
|
+
* is said: the guard would do nothing, and the crash come back.
|
|
10518
10795
|
************************************************************/
|
|
10519
|
-
function close_table_editor(tabulator) {
|
|
10796
|
+
function close_table_editor(gobj, tabulator) {
|
|
10520
10797
|
let edit = tabulator.modules ? tabulator.modules.edit : null;
|
|
10521
|
-
if (edit
|
|
10798
|
+
if (!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
|
|
10799
|
+
log_warning(`${gobj_short_name(gobj)}: this Tabulator has no modules.edit.currentCell/cancelEdit(): an open cell editor is not closed before its table is wiped`);
|
|
10800
|
+
return;
|
|
10801
|
+
}
|
|
10802
|
+
if (edit.currentCell) edit.cancelEdit();
|
|
10803
|
+
}
|
|
10804
|
+
/************************************************************
|
|
10805
|
+
* The element of the table (`.tabulator` kept on it) that holds
|
|
10806
|
+
* $el, the innermost one.
|
|
10807
|
+
************************************************************/
|
|
10808
|
+
function table_element_of($el) {
|
|
10809
|
+
for (let $n = $el; $n; $n = $n.parentNode) if ($n.tabulator) return $n;
|
|
10810
|
+
return null;
|
|
10522
10811
|
}
|
|
10523
10812
|
/************************************************************
|
|
10524
10813
|
* A table element that is gone: its identity is no table now,
|
|
@@ -10541,7 +10830,7 @@ function destroy_row_tables(gobj, $row) {
|
|
|
10541
10830
|
$row.yui_nested = null;
|
|
10542
10831
|
for (let $nested of nested) {
|
|
10543
10832
|
if ($nested.tabulator) {
|
|
10544
|
-
close_table_editor($nested.tabulator);
|
|
10833
|
+
close_table_editor(gobj, $nested.tabulator);
|
|
10545
10834
|
destroy_rows_tables(gobj, $nested.tabulator);
|
|
10546
10835
|
destroy_widget(gobj, "nested table", $nested.tabulator);
|
|
10547
10836
|
$nested.tabulator = null;
|
|
@@ -10574,7 +10863,7 @@ function destroy_widgets(gobj, $container) {
|
|
|
10574
10863
|
$el.jsoneditor = null;
|
|
10575
10864
|
}
|
|
10576
10865
|
if ($el.tabulator) {
|
|
10577
|
-
close_table_editor($el.tabulator);
|
|
10866
|
+
close_table_editor(gobj, $el.tabulator);
|
|
10578
10867
|
destroy_rows_tables(gobj, $el.tabulator);
|
|
10579
10868
|
destroy_widget(gobj, "table", $el.tabulator);
|
|
10580
10869
|
$el.tabulator = null;
|
|
@@ -10722,6 +11011,9 @@ function build_form(gobj) {
|
|
|
10722
11011
|
id: form_id,
|
|
10723
11012
|
class: "yui-form"
|
|
10724
11013
|
}]);
|
|
11014
|
+
$form.addEventListener("submit", function(ev) {
|
|
11015
|
+
ev.preventDefault();
|
|
11016
|
+
});
|
|
10725
11017
|
let template = gobj_read_attr(gobj, "template");
|
|
10726
11018
|
if (!is_object(template) && !is_array(template)) {
|
|
10727
11019
|
$form.appendChild(createOneHtml(template));
|
|
@@ -11233,6 +11525,7 @@ function create_form_field(gobj, $form, prefix, field_desc, { tag, inputType, na
|
|
|
11233
11525
|
"button",
|
|
11234
11526
|
{
|
|
11235
11527
|
class: "button p-1",
|
|
11528
|
+
type: "button",
|
|
11236
11529
|
title: t("add"),
|
|
11237
11530
|
"data-i18n-title": "add",
|
|
11238
11531
|
"aria-label": t("add"),
|
|
@@ -11812,6 +12105,22 @@ function create_coordinates(gobj, attrs) {
|
|
|
11812
12105
|
return $extend;
|
|
11813
12106
|
}
|
|
11814
12107
|
/******************************************************************
|
|
12108
|
+
* Show the checkbox column of a table while the form is
|
|
12109
|
+
* `selectable`, hide it while it is not. The column is the table's
|
|
12110
|
+
* row header, the first of its structured columns. A table not
|
|
12111
|
+
* built yet does it when it is (tableBuilt).
|
|
12112
|
+
******************************************************************/
|
|
12113
|
+
function show_row_selection(gobj, tabulator) {
|
|
12114
|
+
if (!gobj_read_bool_attr(gobj, "with_checkbox") || !tabulator.initialized) return;
|
|
12115
|
+
let column = tabulator.getColumns(true).find((c) => c.getDefinition().formatter === "rowSelection");
|
|
12116
|
+
if (!column) {
|
|
12117
|
+
log_error(`${gobj_short_name(gobj)}: the table has no checkbox column to show or hide`);
|
|
12118
|
+
return;
|
|
12119
|
+
}
|
|
12120
|
+
if (gobj_read_bool_attr(gobj, "selectable")) column.show();
|
|
12121
|
+
else column.hide();
|
|
12122
|
+
}
|
|
12123
|
+
/******************************************************************
|
|
11815
12124
|
* Create tabulator
|
|
11816
12125
|
*
|
|
11817
12126
|
* A row builds its nested tables the first time it is drawn, each
|
|
@@ -11839,13 +12148,27 @@ function create_coordinates(gobj, attrs) {
|
|
|
11839
12148
|
* the form's `selectable` -- first. Up to 7.26.44 the form toggled
|
|
11840
12149
|
* the row again in `rowClick`, which undid every click. The default
|
|
11841
12150
|
* `"highlight"` is left as it is, hover and all.
|
|
12151
|
+
*
|
|
12152
|
+
* The checkbox column (`with_checkbox`) asks `selectable` too, and is
|
|
12153
|
+
* not shown while the form is not selectable: Tabulator's row box
|
|
12154
|
+
* ticks before its toggle is refused (a ticked box over a row not
|
|
12155
|
+
* selected), and its header box selects every row asking nothing. Up
|
|
12156
|
+
* to 7.26.45 the boxes were drawn and lied; with the default
|
|
12157
|
+
* `selectableRows` they selected whatever `selectable` said. Up to
|
|
12158
|
+
* 7.26.46 `selectable` was read when the table was built; the column
|
|
12159
|
+
* now follows every write of it (mt_writing, show_row_selection).
|
|
12160
|
+
*
|
|
12161
|
+
* A click in a nested table stays there: it bubbled to the row that
|
|
12162
|
+
* holds the table, whose own click listener (SelectRow's) toggled
|
|
12163
|
+
* that row too.
|
|
11842
12164
|
******************************************************************/
|
|
11843
12165
|
function create_tabulator$1(gobj, $extend, name, template, rows) {
|
|
11844
12166
|
$extend.template = template;
|
|
11845
12167
|
let tabulator_settings = json_deep_copy(gobj_read_attr(gobj, "tabulator_settings"));
|
|
11846
12168
|
if (is_array(rows) && rows.length > 0) tabulator_settings.data = json_deep_copy(rows);
|
|
12169
|
+
let with_checkbox = gobj_read_bool_attr(gobj, "with_checkbox");
|
|
11847
12170
|
let selectable_rows = tabulator_settings.selectableRows;
|
|
11848
|
-
if (selectable_rows === true || typeof selectable_rows === "number") tabulator_settings.selectableRowsCheck = function() {
|
|
12171
|
+
if (selectable_rows === true || typeof selectable_rows === "number" || with_checkbox) tabulator_settings.selectableRowsCheck = function() {
|
|
11849
12172
|
return gobj_read_bool_attr(gobj, "selectable");
|
|
11850
12173
|
};
|
|
11851
12174
|
let columns = [];
|
|
@@ -11872,6 +12195,12 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
|
|
|
11872
12195
|
"name": sub_element.name
|
|
11873
12196
|
}];
|
|
11874
12197
|
let $extend = createElement2(extend);
|
|
12198
|
+
$extend.addEventListener("click", function(ev) {
|
|
12199
|
+
ev.stopPropagation();
|
|
12200
|
+
});
|
|
12201
|
+
$extend.addEventListener("mousedown", function(ev) {
|
|
12202
|
+
if (ev.shiftKey) ev.stopPropagation();
|
|
12203
|
+
});
|
|
11875
12204
|
let rows = data[sub_element.name];
|
|
11876
12205
|
$extend.tabulator = create_tabulator$1(gobj, $extend, sub_element.name, sub_element.template, rows);
|
|
11877
12206
|
$row.appendChild($extend);
|
|
@@ -11893,22 +12222,37 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
|
|
|
11893
12222
|
cell.getRow().delete();
|
|
11894
12223
|
}
|
|
11895
12224
|
});
|
|
11896
|
-
if (
|
|
12225
|
+
if (with_checkbox) tabulator_settings.rowHeader = {
|
|
11897
12226
|
formatter: "rowSelection",
|
|
11898
12227
|
titleFormatter: "rowSelection",
|
|
11899
12228
|
headerSort: false,
|
|
11900
12229
|
resizable: false,
|
|
11901
12230
|
frozen: true,
|
|
11902
12231
|
headerHozAlign: "center",
|
|
11903
|
-
hozAlign: "center"
|
|
12232
|
+
hozAlign: "center",
|
|
12233
|
+
visible: gobj_read_bool_attr(gobj, "selectable")
|
|
11904
12234
|
};
|
|
11905
12235
|
let tabulator = new TabulatorFull($extend, tabulator_settings);
|
|
11906
12236
|
tabulator.on("dataChanged", function() {
|
|
11907
12237
|
if (gobj.priv.loading_rows > 0) return;
|
|
11908
12238
|
gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
11909
12239
|
});
|
|
12240
|
+
$extend.addEventListener("input", function(ev) {
|
|
12241
|
+
let $target = ev.target;
|
|
12242
|
+
if (!$target || typeof $target.closest !== "function" || !$target.closest(".tabulator-cell.tabulator-editing") || table_element_of($target) !== $extend) return;
|
|
12243
|
+
gobj_send_event(gobj, "EV_RECORD_CHANGED", { typed_in: table_identity(gobj, $extend) }, gobj);
|
|
12244
|
+
});
|
|
12245
|
+
tabulator.on("cellEditing", function() {
|
|
12246
|
+
if (gobj_is_destroying(gobj)) return;
|
|
12247
|
+
gobj_send_event(gobj, "EV_CELL_EDIT_OPENED", { table_id: table_identity(gobj, $extend) }, gobj);
|
|
12248
|
+
});
|
|
12249
|
+
tabulator.on("cellEditCancelled", function() {
|
|
12250
|
+
if (gobj_is_destroying(gobj)) return;
|
|
12251
|
+
gobj_send_event(gobj, "EV_CELL_EDIT_CANCELLED", { table_id: table_identity(gobj, $extend) }, gobj);
|
|
12252
|
+
});
|
|
11910
12253
|
$extend.yui_pending_rows = null;
|
|
11911
12254
|
tabulator.on("tableBuilt", function() {
|
|
12255
|
+
show_row_selection(gobj, tabulator);
|
|
11912
12256
|
let rows = $extend.yui_pending_rows;
|
|
11913
12257
|
$extend.yui_pending_rows = null;
|
|
11914
12258
|
if (rows && !gobj_is_destroying(gobj)) gobj_send_event(gobj, "EV_LOAD_TABLE_ROWS", {
|
|
@@ -12061,13 +12405,11 @@ function template2columns(gobj, columns, template, sub_elements) {
|
|
|
12061
12405
|
break;
|
|
12062
12406
|
case "now":
|
|
12063
12407
|
case "time":
|
|
12064
|
-
column.editor =
|
|
12065
|
-
column.editorParams = {
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
elementAttributes: { title: t("slide bar to choose option") }
|
|
12408
|
+
column.editor = form_time_cell_editor(field_desc.real_type);
|
|
12409
|
+
column.editorParams = { verticalNavigation: "table" };
|
|
12410
|
+
column.formatter = function(cell) {
|
|
12411
|
+
return text_node(time_value_to_text(cell.getValue(), field_desc.real_type));
|
|
12069
12412
|
};
|
|
12070
|
-
field_desc.real_type;
|
|
12071
12413
|
break;
|
|
12072
12414
|
case "color":
|
|
12073
12415
|
column.editor = "input";
|
|
@@ -12358,7 +12700,7 @@ function clear_data(gobj, $form) {
|
|
|
12358
12700
|
$form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
|
|
12359
12701
|
$table.yui_pending_rows = null;
|
|
12360
12702
|
if ($table.tabulator.initialized) {
|
|
12361
|
-
close_table_editor($table.tabulator);
|
|
12703
|
+
close_table_editor(gobj, $table.tabulator);
|
|
12362
12704
|
destroy_rows_tables(gobj, $table.tabulator);
|
|
12363
12705
|
$table.tabulator.clearData();
|
|
12364
12706
|
}
|
|
@@ -12555,7 +12897,7 @@ function treedb_value_2_form_value(gobj, field_desc, value) {
|
|
|
12555
12897
|
case "url": break;
|
|
12556
12898
|
case "now":
|
|
12557
12899
|
case "time":
|
|
12558
|
-
value =
|
|
12900
|
+
value = time_value_to_date(value, field_desc.real_type);
|
|
12559
12901
|
break;
|
|
12560
12902
|
case "date":
|
|
12561
12903
|
case "color":
|
|
@@ -12649,10 +12991,9 @@ function form_value_2_treedb_value(gobj, field_desc, value) {
|
|
|
12649
12991
|
case "time":
|
|
12650
12992
|
switch (real_type) {
|
|
12651
12993
|
case "string":
|
|
12652
|
-
if (value && is_date(value)) value = value.toISOString();
|
|
12653
|
-
break;
|
|
12654
12994
|
case "integer":
|
|
12655
|
-
if (
|
|
12995
|
+
if (is_date(value)) value = Math.floor(value.getTime() / 1e3);
|
|
12996
|
+
value = epoch_to_time_value(value, real_type);
|
|
12656
12997
|
break;
|
|
12657
12998
|
default: log_error("incompatible type for time: " + real_type);
|
|
12658
12999
|
}
|
|
@@ -12900,7 +13241,44 @@ function ac_load_table_rows(gobj, event, kw, src) {
|
|
|
12900
13241
|
* Internal event
|
|
12901
13242
|
************************************************************/
|
|
12902
13243
|
function ac_record_changed(gobj, event, kw, src) {
|
|
12903
|
-
if (gobj_read_bool_attr(gobj, "initialized"))
|
|
13244
|
+
if (gobj_read_bool_attr(gobj, "initialized")) {
|
|
13245
|
+
let priv = gobj.priv;
|
|
13246
|
+
let open = priv.cell_edit;
|
|
13247
|
+
let own = !!(open && kw && kw.typed_in === open.table_id && open.seq === priv.change_seq);
|
|
13248
|
+
set_edited_by_reader(gobj);
|
|
13249
|
+
if (own) open.seq = priv.change_seq;
|
|
13250
|
+
}
|
|
13251
|
+
return 0;
|
|
13252
|
+
}
|
|
13253
|
+
/************************************************************
|
|
13254
|
+
* A cell editor opened, in the table `table_id`: what the form
|
|
13255
|
+
* says now is what a cancel of it gives back.
|
|
13256
|
+
************************************************************/
|
|
13257
|
+
function ac_cell_edit_opened(gobj, event, kw, src) {
|
|
13258
|
+
let priv = gobj.priv;
|
|
13259
|
+
priv.cell_edit = {
|
|
13260
|
+
table_id: kw.table_id,
|
|
13261
|
+
edited: gobj_read_bool_attr(gobj, "edited"),
|
|
13262
|
+
changes: gobj_read_bool_attr(gobj, "changes"),
|
|
13263
|
+
seq: priv.change_seq
|
|
13264
|
+
};
|
|
13265
|
+
return 0;
|
|
13266
|
+
}
|
|
13267
|
+
/************************************************************
|
|
13268
|
+
* A cell editor cancelled -- Escape, or a box left as it was:
|
|
13269
|
+
* the value comes back, and so do the `edited` and `changes` the
|
|
13270
|
+
* form had when it opened. Up to gobj-ui 7.26.46 what was typed
|
|
13271
|
+
* in it still counted, and closing asked about a change that was
|
|
13272
|
+
* gone. Nothing is given back when anything but that editor's
|
|
13273
|
+
* own typing changed the form meanwhile: that change is real.
|
|
13274
|
+
************************************************************/
|
|
13275
|
+
function ac_cell_edit_cancelled(gobj, event, kw, src) {
|
|
13276
|
+
let priv = gobj.priv;
|
|
13277
|
+
let open = priv.cell_edit;
|
|
13278
|
+
priv.cell_edit = null;
|
|
13279
|
+
if (!open || open.table_id !== kw.table_id || open.seq !== priv.change_seq) return 0;
|
|
13280
|
+
if (gobj_read_bool_attr(gobj, "changes") !== open.changes) set_changed_stated(gobj, open.changes);
|
|
13281
|
+
gobj_write_bool_attr(gobj, "edited", open.edited);
|
|
12904
13282
|
return 0;
|
|
12905
13283
|
}
|
|
12906
13284
|
/************************************************************
|
|
@@ -13044,6 +13422,7 @@ function cmd_get_picked_files(gobj, cmd, kw, src) {
|
|
|
13044
13422
|
}
|
|
13045
13423
|
var gmt$17 = {
|
|
13046
13424
|
mt_create: mt_create$17,
|
|
13425
|
+
mt_writing: mt_writing$2,
|
|
13047
13426
|
mt_start: mt_start$17,
|
|
13048
13427
|
mt_stop: mt_stop$17,
|
|
13049
13428
|
mt_destroy: mt_destroy$17,
|
|
@@ -13093,6 +13472,16 @@ function create_gclass$17(gclass_name) {
|
|
|
13093
13472
|
ac_record_changed,
|
|
13094
13473
|
null
|
|
13095
13474
|
],
|
|
13475
|
+
[
|
|
13476
|
+
"EV_CELL_EDIT_OPENED",
|
|
13477
|
+
ac_cell_edit_opened,
|
|
13478
|
+
null
|
|
13479
|
+
],
|
|
13480
|
+
[
|
|
13481
|
+
"EV_CELL_EDIT_CANCELLED",
|
|
13482
|
+
ac_cell_edit_cancelled,
|
|
13483
|
+
null
|
|
13484
|
+
],
|
|
13096
13485
|
[
|
|
13097
13486
|
"EV_COPY_RECORD",
|
|
13098
13487
|
ac_copy_record,
|
|
@@ -13162,6 +13551,8 @@ function create_gclass$17(gclass_name) {
|
|
|
13162
13551
|
["EV_ADD_TABLE_ROW", 0],
|
|
13163
13552
|
["EV_LOAD_TABLE_ROWS", 0],
|
|
13164
13553
|
["EV_RECORD_CHANGED", 0],
|
|
13554
|
+
["EV_CELL_EDIT_OPENED", 0],
|
|
13555
|
+
["EV_CELL_EDIT_CANCELLED", 0],
|
|
13165
13556
|
["EV_COPY_RECORD", 0],
|
|
13166
13557
|
["EV_PASTE_RECORD", 0],
|
|
13167
13558
|
["EV_SET_FILE_PREVIEW", 0],
|
|
@@ -32271,8 +32662,11 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
|
|
|
32271
32662
|
switch (field_desc.real_type) {
|
|
32272
32663
|
case "string":
|
|
32273
32664
|
case "integer":
|
|
32274
|
-
value =
|
|
32275
|
-
|
|
32665
|
+
value = time_value_to_date(value, field_desc.real_type);
|
|
32666
|
+
if (!value) {
|
|
32667
|
+
value = "";
|
|
32668
|
+
break;
|
|
32669
|
+
}
|
|
32276
32670
|
const rawLocale = navigator.language;
|
|
32277
32671
|
const userLocale = typeof rawLocale === "string" && rawLocale && rawLocale !== "undefined" ? rawLocale : void 0;
|
|
32278
32672
|
const formatter = new Intl.DateTimeFormat(userLocale, {
|