Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Time editor value could not be changed 2024.1 #2390

Merged
merged 2 commits into from Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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?$"))
);
}

Expand All @@ -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?$"))
);
}

Expand Down
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down
18 changes: 18 additions & 0 deletions frontend-html/src/tests/DateTimeCompleter.test.ts
Expand Up @@ -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);
});