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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix issues with multi day running timers
Klaus Zandersd8cd5358a536
diff --git a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.tsindex eafce24f0f1..f1d9f5302ac 100644--- a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts@@ -110,11 +110,20 @@ export default class TimeEntryController extends Controller {// - We have start & end time and no hours// - We have start & end time and we have triggered the change from the end time fieldif (startTimeInMinutes && endTimeInMinutes && (hoursInMinutes === 0 || initiatedBy === this.endTimeInputTarget)) {+ let exisitingDayGap = 0;++ // when we already had hours set, and they were above 24 hours, we would most likely want to stay on that end date+ if (hoursInMinutes >= 24 * 60) {+ exisitingDayGap = Math.floor(hoursInMinutes / (24 * 60)) * (60 * 24);+ }+hoursInMinutes = endTimeInMinutes - startTimeInMinutes;if (hoursInMinutes <= 0) {hoursInMinutes += 24 * 60;}+ hoursInMinutes += exisitingDayGap;+const formattedHours = outputChronicDuration(hoursInMinutes * 60, { format: 'hours_only' }) || '';this.hoursInputTarget.value = formattedHours;} else if (startTimeInMinutes && hoursInMinutes) {diff --git a/modules/costs/app/components/time_entries/days_and_hours_form.rb b/modules/costs/app/components/time_entries/days_and_hours_form.rbindex 63c3cfd6728..1f0a1fa85a9 100644--- a/modules/costs/app/components/time_entries/days_and_hours_form.rb+++ b/modules/costs/app/components/time_entries/days_and_hours_form.rb@@ -60,6 +60,7 @@ module TimeEntriesrequired: start_and_end_time_required?,label: TimeEntry.human_attribute_name(:end_time),value: model.end_timestamp&.strftime("%H:%M"),+ caption: end_time_caption,data: {"time-entry-target" => "endTimeInput","action" => "input->time-entry#timeInputChanged"@@ -94,5 +95,20 @@ module TimeEntries""endend++ def end_time_caption # rubocop:disable Metrics/AbcSize+ relevant_hours = model.ongoing? ? model.ongoing_hours : model.hours++ return if model.start_time.blank?+ return if relevant_hours.blank?++ end_time_in_minutes = model.start_time + (relevant_hours * 60)++ return if end_time_in_minutes <= (24 * 60)++ diff_in_days = (end_time_in_minutes / (60 * 24)).floor++ "+#{I18n.t('datetime.distance_in_words.x_days', count: diff_in_days)}"+ endendend