@yuneta/gobj-ui 7.23.43 → 7.23.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.43",
3
+ "version": "7.23.44",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
package/src/c_yui_form.js CHANGED
@@ -71,6 +71,7 @@ import "tabulator-tables/dist/css/tabulator.min.css"; // Import Tabulator CSS
71
71
  import "tabulator-tables/dist/css/tabulator_bulma.css";
72
72
 
73
73
  import "./tabulator.css";
74
+ import {is_time_field} from "./json_view_helpers.js";
74
75
  import { TabulatorFull as Tabulator } from "tabulator-tables"; // Import Full Tabulator JS
75
76
  // import { Tabulator } from "tabulator-tables"; // Import light Tabulator JS
76
77
 
@@ -1365,12 +1366,12 @@ function create_form_field(
1365
1366
  onChange: function() {
1366
1367
  gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
1367
1368
  },
1369
+ /* La lista vive en json_view_helpers.js: el visor de
1370
+ * JSON y este editor tienen que reconocer los MISMOS
1371
+ * campos, y tener cada uno su copia es como dejaron de
1372
+ * hacerlo. */
1368
1373
  timestampTag: function({field, value, path}) {
1369
- return field === '__t__' || field === '__tm__' ||
1370
- field === 'tm' || field === 't' || field === 'time' ||
1371
- field === 'from_t' || field === 'to_t' ||
1372
- field === 't_input' || field === 't_output' ||
1373
- field === 'from_tm' || field === 'to_tm';
1374
+ return is_time_field(field);
1374
1375
  },
1375
1376
  }
1376
1377
  });
@@ -183,18 +183,34 @@ export function subtree_matches(value, term)
183
183
 
184
184
  /************************************************************
185
185
  * Fields whose numeric value is an epoch timestamp.
186
- * Mirrors the timestampTag list wired into C_YUI_FORM's
187
- * jsoneditor control, so the two viewers agree.
186
+ *
187
+ * THE ONE LIST. C_YUI_FORM's jsoneditor takes its
188
+ * `timestampTag` from here: it used to carry its own copy,
189
+ * and a copy is how the two stopped agreeing.
190
+ *
191
+ * TWO SPELLINGS, AND LAS DOS SON DEL BACKEND. timeranger2
192
+ * writes `from_t`/`from_tm` in the match_cond of a query and
193
+ * `fr_t`/`fr_tm` in the metadata of a topic and of a file --
194
+ * which is what a Raw JSON of a treedb actually shows. With
195
+ * only the long pair listed, `to_t` got its date and the
196
+ * `fr_t` right above it did not, which reads as a broken
197
+ * annotator rather than a missing name.
188
198
  ************************************************************/
199
+ const TIME_FIELDS = [
200
+ "__t__", "__tm__",
201
+ "t", "tm", "time",
202
+ "from_t", "to_t", "from_tm", "to_tm",
203
+ "fr_t", "fr_tm",
204
+ "t_input", "t_output"
205
+ ];
206
+
189
207
  export function is_time_field(field)
190
208
  {
191
- return field === "__t__" || field === "__tm__" ||
192
- field === "tm" || field === "t" || field === "time" ||
193
- field === "from_t" || field === "to_t" ||
194
- field === "t_input" || field === "t_output" ||
195
- field === "from_tm" || field === "to_tm";
209
+ return TIME_FIELDS.indexOf(field) >= 0;
196
210
  }
197
211
 
212
+ export {TIME_FIELDS};
213
+
198
214
  /************************************************************
199
215
  * Format an epoch value as a local wall-clock string.
200
216
  * Accepts seconds or milliseconds; returns null when the
@@ -310,3 +310,36 @@ test("is_pure_collection: the schema this came from", () => {
310
310
  /* A column has content, so it keeps its card. */
311
311
  expect(is_pure_collection(col)).toBe(false);
312
312
  });
313
+
314
+
315
+ /*
316
+ * DOS ORTOGRAFIAS, Y LAS DOS SON DEL BACKEND.
317
+ *
318
+ * timeranger2 escribe `from_t`/`from_tm` en el match_cond de una consulta y
319
+ * `fr_t`/`fr_tm` en los metadatos de un topic y de un fichero -- que es lo
320
+ * que enseña el Raw JSON de un treedb. Con solo la larga en la lista,
321
+ * `to_t` salia fechado y el `fr_t` de encima no: se lee como un anotador
322
+ * roto y es un nombre que falta.
323
+ */
324
+ test("is_time_field reconoce la abreviada, la que sale en un Raw JSON", () => {
325
+ expect(is_time_field("fr_t")).toBe(true);
326
+ expect(is_time_field("fr_tm")).toBe(true);
327
+ });
328
+
329
+ test("is_time_field sigue reconociendo la larga, la de las consultas", () => {
330
+ expect(is_time_field("from_t")).toBe(true);
331
+ expect(is_time_field("from_tm")).toBe(true);
332
+ });
333
+
334
+ test("is_time_field: las dos mitades de cada par, o la fila queda a medias", () => {
335
+ [["fr_t", "to_t"], ["fr_tm", "to_tm"],
336
+ ["from_t", "to_t"], ["from_tm", "to_tm"]].forEach((pair) => {
337
+ expect(is_time_field(pair[0])).toBe(is_time_field(pair[1]));
338
+ });
339
+ });
340
+
341
+ test("is_time_field no fecha lo que no es una fecha", () => {
342
+ ["rows", "id", "", undefined, null].forEach((f) => {
343
+ expect(is_time_field(f)).toBe(false);
344
+ });
345
+ });