Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

use the new helpers in the chronic duration stimulus controller

Klaus Zanders23ef4211d398
diff --git a/frontend/src/stimulus/controllers/dynamic/chronic-duration.controller.ts b/frontend/src/stimulus/controllers/dynamic/chronic-duration.controller.ts
index e3d94ff3d00..3e99460e020 100644
--- a/frontend/src/stimulus/controllers/dynamic/chronic-duration.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/chronic-duration.controller.ts
@@ -30,7 +30,7 @@
*/
import { Controller } from '@hotwired/stimulus';
-import { outputChronicDuration, parseChronicDuration } from 'core-app/shared/helpers/chronic_duration';
+import { durationStringToSeconds, formattedHour } from 'core-stimulus/helpers/chronic-duration-helper';
export default class ChronicDurationController extends Controller<HTMLInputElement> {
private processChangeFn = () => { this.onBlur(); };
@@ -49,15 +49,8 @@ export default class ChronicDurationController extends Controller<HTMLInputEleme
}
private onBlur() {
- const value = this.element.value;
- const hours = parseChronicDuration(
- value,
- {
- defaultUnit: 'hours', ignoreSecondsWhenColonSeperated: true,
- },
- );
-
- this.element.value = outputChronicDuration(hours, { format: 'hours_only' }) ?? '';
+ const parsedSeconds = durationStringToSeconds(this.element.value);
+ this.element.value = formattedHour(parsedSeconds);
}
private onKeyPress(evt:KeyboardEvent) {
diff --git a/frontend/src/stimulus/helpers/chronic-duration-helper.ts b/frontend/src/stimulus/helpers/chronic-duration-helper.ts
index 8f032e7fd05..148a002f5b5 100644
--- a/frontend/src/stimulus/helpers/chronic-duration-helper.ts
+++ b/frontend/src/stimulus/helpers/chronic-duration-helper.ts
@@ -34,7 +34,9 @@ import {
} from 'core-app/shared/helpers/chronic_duration';
export function durationStringToSeconds(value:string):number {
+ // Make sure we also accept german decimal commas
const normalizedValue = value.replace(',', '.');
+
return parseChronicDuration(normalizedValue, {
defaultUnit: 'hours',
ignoreSecondsWhenColonSeperated: true,