From 828bf1a39a498426129eb4dce74575e1f71454ed Mon Sep 17 00:00:00 2001 From: Jindrich Susen Date: Mon, 15 Jan 2024 14:15:13 +0100 Subject: [PATCH 1/2] It was not possible to change value datetime editor if the editor format was set to "time" --- .../ScreenElements/Editors/DateCompleter.tsx | 6 +++-- .../Editors/DateTimeEditor/DateEditorModel.ts | 4 +-- .../src/plugins/tools/PluginRegistration.ts | 25 +++---------------- .../src/tests/DateTimeCompleter.test.ts | 18 +++++++++++++ 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/frontend-html/src/gui/Components/ScreenElements/Editors/DateCompleter.tsx b/frontend-html/src/gui/Components/ScreenElements/Editors/DateCompleter.tsx index 99934f994a..3c11bb409a 100644 --- a/frontend-html/src/gui/Components/ScreenElements/Editors/DateCompleter.tsx +++ b/frontend-html/src/gui/Components/ScreenElements/Editors/DateCompleter.tsx @@ -50,7 +50,8 @@ export default class DateCompleter { t.match(/^\d\d\d\s+\d\d\d\d$/) || t.match(/^\d\d\d\d?\s+\d\d$/) || t.match(/^\d\d\d\d\d\d\d\d\s+\d\d\d\d\d\d$/) || - t.match(new RegExp("^\\d\\d?" + this.dateSeparator + "\\d?\\d?" + this.dateSeparator + "?\\d?\\d?\\d?\\d? *\\d?\\d?:?\\d?\\d?:?\\d?\\d?$")) + t.match(new RegExp("^\\d\\d?\\" + this.dateSeparator + "\\d?\\d?\\" + this.dateSeparator + "?\\d?\\d?\\d?\\d?")) || + t.match(new RegExp("^\\d\\d?\\" + this.dateSeparator + "\\d?\\d?\\" + this.dateSeparator + "?\\d?\\d?\\d?\\d? +\\d?\\d?:?\\d?\\d?:?\\d?\\d?$")) ); } @@ -64,7 +65,8 @@ export default class DateCompleter { t.match(/^\d\d\d\d\s+\d\d$/) || t.match(/^\d\d\d\d\d\d\d\d \d\d\d\d\d\d$/) || t.match(/^\d\d?$/) || - t.match(new RegExp("^\\d\\d?" + this.dateSeparator + "\\d?\\d?" + this.dateSeparator + "?\\d?\\d?\\d?\\d? *\\d?\\d?:?\\d?\\d?:?\\d?\\d?$")) + t.match(new RegExp("^\\d\\d?\\" + this.dateSeparator + "\\d?\\d?\\" + this.dateSeparator + "?\\d?\\d?\\d?\\d?")) || + t.match(new RegExp("^\\d\\d?\\" + this.dateSeparator + "\\d?\\d?\\" + this.dateSeparator + "?\\d?\\d?\\d?\\d? +\\d?\\d?:?\\d?\\d?:?\\d?\\d?$")) ); } diff --git a/frontend-html/src/gui/Components/ScreenElements/Editors/DateTimeEditor/DateEditorModel.ts b/frontend-html/src/gui/Components/ScreenElements/Editors/DateTimeEditor/DateEditorModel.ts index 59aa19fed2..7540a2246d 100644 --- a/frontend-html/src/gui/Components/ScreenElements/Editors/DateTimeEditor/DateEditorModel.ts +++ b/frontend-html/src/gui/Components/ScreenElements/Editors/DateTimeEditor/DateEditorModel.ts @@ -46,7 +46,7 @@ export class DateEditorModel { await flow(function*() { const dateCompleter = self.getDateCompleter(); const completedMoment = dateCompleter.autoComplete(self.dirtyTextualValue); - if (completedMoment) { + if (completedMoment && completedMoment.isValid()) { yield self.onChange?.(event, toOrigamServerString(completedMoment)); } else if (self.hasValueChanged()) { @@ -120,7 +120,7 @@ export class DateEditorModel { isRefreshShortcut(event) ) { const completedMoment = this.autoCompletedMoment; - if (completedMoment) { + if (completedMoment && completedMoment.isValid()) { this.onChange?.(event, toOrigamServerString(completedMoment)); } else if (this.hasValueChanged()) { diff --git a/frontend-html/src/plugins/tools/PluginRegistration.ts b/frontend-html/src/plugins/tools/PluginRegistration.ts index 270a028677..77ad1961a7 100644 --- a/frontend-html/src/plugins/tools/PluginRegistration.ts +++ b/frontend-html/src/plugins/tools/PluginRegistration.ts @@ -1,23 +1,6 @@ -/* -Copyright 2005 - 2021 Advantage Solutions, s. r. o. - -This file is part of ORIGAM (http://www.origam.org). - -ORIGAM is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -ORIGAM is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with ORIGAM. If not, see . -*/ - +import { registerPlugin } from "plugins/tools/PluginLibrary"; +import { WeighingPlugin } from "plugins/implementations/plugins/src"; export function registerPlugins() { - -} + registerPlugin("WeighingPlugin", () => new WeighingPlugin()); +} \ No newline at end of file diff --git a/frontend-html/src/tests/DateTimeCompleter.test.ts b/frontend-html/src/tests/DateTimeCompleter.test.ts index c4653f7b4b..82a64f45dc 100644 --- a/frontend-html/src/tests/DateTimeCompleter.test.ts +++ b/frontend-html/src/tests/DateTimeCompleter.test.ts @@ -76,4 +76,22 @@ test.each([ ])('Should auto complete %s to: %s using dateCompleterCz', (incompleteDate, expected) => { const momentValue = dateCompleterCz.autoComplete(incompleteDate) expect(format(momentValue!, "DD.MM.YYYY HH:mm:ss")).toBe(expected); +}); + +test.each([ + ["12:30"], + ["12:30:14"], + ["12:30:14.16"], +])('Should not try to complete time alone using dateCompleterCz', (incompleteDate) => { + const momentValue = dateCompleterCz.autoComplete(incompleteDate) + expect(momentValue).toBe(undefined); +}); + +test.each([ + ["12:30"], + ["12:30:14"], + ["12:30:14.16"], +])('Should not try to complete time alone using dateCompleterUs', (incompleteDate) => { + const momentValue = dateCompleterUs.autoComplete(incompleteDate) + expect(momentValue).toBe(undefined); }); \ No newline at end of file From 302d3244a60b577360bb250b36fbfcad8d0ac03c Mon Sep 17 00:00:00 2001 From: Jindrich Susen Date: Mon, 15 Jan 2024 15:10:42 +0100 Subject: [PATCH 2/2] Accidental change reverted --- .../src/plugins/tools/PluginRegistration.ts | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/frontend-html/src/plugins/tools/PluginRegistration.ts b/frontend-html/src/plugins/tools/PluginRegistration.ts index 77ad1961a7..270a028677 100644 --- a/frontend-html/src/plugins/tools/PluginRegistration.ts +++ b/frontend-html/src/plugins/tools/PluginRegistration.ts @@ -1,6 +1,23 @@ -import { registerPlugin } from "plugins/tools/PluginLibrary"; -import { WeighingPlugin } from "plugins/implementations/plugins/src"; +/* +Copyright 2005 - 2021 Advantage Solutions, s. r. o. + +This file is part of ORIGAM (http://www.origam.org). + +ORIGAM is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +ORIGAM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with ORIGAM. If not, see . +*/ + export function registerPlugins() { - registerPlugin("WeighingPlugin", () => new WeighingPlugin()); -} \ No newline at end of file + +}