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

make start and end time required conditionally

Klaus Zanders1da8ba51966f
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.rb
index c4a42b78832..cd0c24de2bc 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
@@ -44,7 +44,7 @@ module TimeEntries
f.group(layout: :horizontal) do |g|
g.text_field name: :start_time,
type: "time",
- required: true,
+ required: start_and_end_time_required?,
label: TimeEntry.human_attribute_name(:start_time),
value: model.start_timestamp&.strftime("%H:%M"),
data: {
@@ -54,7 +54,7 @@ module TimeEntries
g.text_field name: :end_time,
type: "time",
- required: true,
+ required: start_and_end_time_required?,
label: TimeEntry.human_attribute_name(:end_time),
value: model.end_timestamp&.strftime("%H:%M"),
data: {
@@ -78,6 +78,10 @@ module TimeEntries
TimeEntry.can_track_start_and_end_time?
end
+ def start_and_end_time_required?
+ TimeEntry.must_track_start_and_end_time?
+ end
+
def hours_value
if model.hours.present?
ChronicDuration.output(model.hours * 3600, format: :hours_only)