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 clear button to the time input fields and reset both when one is clicked
Klaus Zandersece288c076eb
diff --git a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.tsindex 7ca1627b60e..aaa05e598a7 100644--- a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts@@ -107,6 +107,20 @@ export default class TimeEntryController extends Controller {return;}+ // The time entry input fields are currently not valid, so we do not need to calculate anything.+ // A time entry input field is invalid when it is only partially filled out.+ if (!this.startTimeInputTarget.checkValidity() || !this.endTimeInputTarget.checkValidity()) {+ return;+ }++ // when we have reset one of the input fields for start- or end-time, we want to unset both fields+ if ((initiatedBy === this.startTimeInputTarget && this.startTimeInputTarget.value === '') || (initiatedBy === this.endTimeInputTarget && this.endTimeInputTarget.value === '')) {+ this.startTimeInputTarget.value = '';+ this.endTimeInputTarget.value = '';+ this.toggleEndTimePlusCaption(0, 0);+ return;+ }+const startTimeParts = this.startTimeInputTarget.value.split(':');const endTimeParts = this.endTimeInputTarget.value.split(':');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 481c579bf17..0e25d1fe2b0 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@@ -50,6 +50,7 @@ module TimeEntriesrequired: start_and_end_time_required?,label: TimeEntry.human_attribute_name(:start_time),value: model.start_timestamp&.strftime("%H:%M"),+ show_clear_button: true,data: {"time-entry-target" => "startTimeInput","action" => "input->time-entry#timeInputChanged"@@ -60,6 +61,7 @@ module TimeEntriesrequired: start_and_end_time_required?,label: TimeEntry.human_attribute_name(:end_time),value: model.end_timestamp&.strftime("%H:%M"),+ show_clear_button: true,caption: end_time_caption,data: {"time-entry-target" => "endTimeInput",