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
add logic to calculate start time based on end time and hours
Klaus Zanders12483f2f926f
diff --git a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.tsindex 6d47dac225d..7ca1627b60e 100644--- a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts@@ -141,6 +141,13 @@ export default class TimeEntryController extends Controller {Math.floor(newEndTime / 60).toString().padStart(2, '0'),Math.round(newEndTime % 60).toString().padStart(2, '0'),].join(':');+ } else if (endTimeInMinutes && hoursInMinutes) {+ const newStartTime = (endTimeInMinutes - hoursInMinutes) % (24 * 60);++ this.startTimeInputTarget.value = [+ Math.floor(newStartTime / 60).toString().padStart(2, '0'),+ Math.round(newStartTime % 60).toString().padStart(2, '0'),+ ].join(':');}this.toggleEndTimePlusCaption(startTimeInMinutes, hoursInMinutes);diff --git a/modules/costs/spec/features/time_entry_dialog_spec.rb b/modules/costs/spec/features/time_entry_dialog_spec.rbindex f639a62d499..ac2f56cb27a 100644--- a/modules/costs/spec/features/time_entry_dialog_spec.rb+++ b/modules/costs/spec/features/time_entry_dialog_spec.rb@@ -174,6 +174,20 @@ RSpec.describe "time entry dialog", :js, with_flag: :track_start_and_end_times_ftime_logging_modal.shows_caption("+2 days")end+ it "calculates the end time based on start time and hours" do+ time_logging_modal.update_time_field("start_time", hour: 10, minute: 0)+ time_logging_modal.update_field("hours", "3h")++ time_logging_modal.has_field_with_value("end_time", "13:00")+ end++ it "calculates the start time based on end time and hours" do+ time_logging_modal.update_time_field("end_time", hour: 10, minute: 0)+ time_logging_modal.update_field("hours", "3h")++ time_logging_modal.has_field_with_value("start_time", "07:00")+ end+it "recalculates the end time, when changing the hours field" dotime_logging_modal.update_time_field("start_time", hour: 10, minute: 0)time_logging_modal.update_time_field("end_time", hour: 12, minute: 30)