diff --git a/CHANGELOG.md b/CHANGELOG.md index 705a0032b00c907dd6ba64e15fc2792a5c7a0c53..dcc713b8ae75b1da484df279b98003cbae13df0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,12 +23,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Adapter](https://gitlab.com/caosdb/caosdb-webui-legacy-adapter) has been added. It is disabled by default because it depends not only on the server's GRPC API but also on a proxy translating WebGRPC/HTTP1.1 (browser) requests - to GRPC/HTTP2 (server) and vice versa. + to GRPC/HTTP2 (server) and vice versa. The new map should work as a drop-in for the legacy map with the exact functionality of the old map and the same config files. However, the new map also implements a new behavior for the query button: The query will be executed immediately, see - [caosdb-webui#205](https://gitlab.com/caosdb/caosdb-webui/-/issues/205). + [caosdb-webui#205](https://gitlab.com/caosdb/caosdb-webui/-/issues/205). You can enable the new map by disabling the old one AND placing a valid configuration at `conf/ext/json/ext_map.json`. A suitable proxy is envoy and a suitable envoy.yaml can be found in `misc/envoy.yaml`. Please have a look @@ -50,8 +50,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [caosdb-webui#226](https://gitlab.com/caosdb/caosdb-webui/-/issues/226) * Fixed broken download of referenced files in the export of select statements. https://gitlab.com/linkahead/linkahead-webui/-/issues/238 -* Do not send unpaged queries during Edit Mode usage. Fixes +* Do not send unpaged queries during Edit Mode usage. Fixes [caosdb-webui#217](https://gitlab.com/linkahead/linkahead-webui/-/issues/217) +* Fixed breaking timestamps due to whitespace + [caosdb-webui#239](https://gitlab.com/caosdb/caosdb-webui/-/issues/239) ### Security ### diff --git a/src/core/js/caosdb.js b/src/core/js/caosdb.js index af81a120cf4c4f1e4a42ee709566e4f5d3b01568..e709f2318342fb4f14dc336c11245a4b29126d59 100644 --- a/src/core/js/caosdb.js +++ b/src/core/js/caosdb.js @@ -330,13 +330,19 @@ var getEntityIdVersion = function (entity) { } /** - * Take a date and a time and format it into a LinkAhead compatible representation. + * Take a date, a time and subseconds and format it into a LinkAhead compatible representation. * @param date A date * @param time A time + * @param subsec fractions of a seconds part of the time stamp; Must be empty + * string if not used * @return A LinkAhead compatible representation. */ -function input2caosdbDate(date, time) { - return date + "T" + time; +function input2caosdbDate(date, time, subsec) { + let res = date + "T" + time; + if (subsec!=""){ + res = res +"." + subsec; + } + return res } /** @@ -366,18 +372,22 @@ var getAllEntityPermissions = function (entity) { } /** - * Take a datetime from caosdb and return a date and a time + * Take a datetime from caosdb and return a date, a time and the subseconds * suitable for html inputs. * * If the text contains only a date it is returned. * * @param text The string from LinkAhead. - * @return A new string for the input element. + * @return A list of strings for the input elements. */ function caosdb2InputDate(text) { if (text.includes("T")) { - var spl = text.split("T"); - return [spl[0], spl[1].substring(0, 8)]; + var spl = text.trim().split("T"); + var subsec="" + if (spl[1].includes(".")) { + subsec = spl[1].split('.')[1] + } + return [spl[0], spl[1].substring(0, 8), subsec]; } return [text]; } diff --git a/src/core/js/edit_mode.js b/src/core/js/edit_mode.js index d2b8fbcfa9fb31f9ccdc076c844f944ba0c04834..c85298c1b14f6a082fe3bf79ce62ed355a33785a 100644 --- a/src/core/js/edit_mode.js +++ b/src/core/js/edit_mode.js @@ -513,8 +513,10 @@ var edit_mode = new function () { var _parse_single_datetime = function (field) { let time = $(field).find(":input[type='time']").val() let date = $(field).find(":input[type='date']").val(); + // subseconds are stored in the subsec attribue of the input element + let subsec = $(field).find(":input[type='time']").attr('subsec'); if (time) { - return input2caosdbDate(date, time); + return input2caosdbDate(date, time, subsec); } else { return date; } @@ -975,10 +977,11 @@ var edit_mode = new function () { dateandtime = caosdb2InputDate(property.value); } let date = dateandtime[0]; - if (dateandtime.length == 2) { + if (dateandtime.length > 1) { let time = dateandtime[1]; + // subseconds are stored in the subsec attribue of the input element result = "<span><input type='date' value='" + date + "'/>" + - "<input type='time' value='" + time + "'/></span>"; + "<input type='time' subsec='"+dateandtime[2]+"' value='" + time + "'/></span>"; } else if (property.value && ((property.name || "").toLowerCase() == "year" || (date.match(/-/g) || []).length == 0)) { // Year result = "<input type='number' value='" + date + "'/>"; diff --git a/test/core/js/modules/caosdb.js.js b/test/core/js/modules/caosdb.js.js index d4b4c509b177ee76c50368ded4ecee40caecb4d9..2e98e341240a22b1160587ea2de59dde9ce7660b 100644 --- a/test/core/js/modules/caosdb.js.js +++ b/test/core/js/modules/caosdb.js.js @@ -661,3 +661,19 @@ QUnit.test("getPropertyFromElement", async function(assert) { }); }); + +QUnit.test("input2caosdbDate", function(assert) { + assert.ok(input2caosdbDate); + assert.equal(input2caosdbDate("2023-10-18","10:10:10", "1234"), "2023-10-18T10:10:10.1234") + assert.equal(input2caosdbDate("2023-10-18","10:10:10", ""), "2023-10-18T10:10:10") +}); + +QUnit.test("caosdb2InputDate", function(assert) { + assert.ok(caosdb2InputDate); + arr1 = caosdb2InputDate("2023-10-18T10:10:10.1234") + arr2=["2023-10-18","10:10:10", "1234"] + assert.ok(arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index])) + assert.ok(arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index])) + arr1 = caosdb2InputDate("2023-10-18T10:10:10") + arr2=["2023-10-18","10:10:10", ""] +});