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

Enable remaining work field when there are errors in wp

Christophe Bliardbf0729a8ab4e
diff --git a/app/forms/work_packages/progress_form.rb b/app/forms/work_packages/progress_form.rb
index 37e448fb154..ad499175b27 100644
--- a/app/forms/work_packages/progress_form.rb
+++ b/app/forms/work_packages/progress_form.rb
@@ -61,7 +61,7 @@ class WorkPackages::ProgressForm < ApplicationForm
else
render_text_field(group, name: :estimated_hours, label: I18n.t(:label_work))
render_text_field(group, name: :remaining_hours, label: I18n.t(:label_remaining_work),
- disabled: @work_package.estimated_hours.nil?)
+ disabled: disabled_remaining_work_field?)
render_readonly_text_field(group, name: :done_ratio, label: I18n.t(:label_percent_complete))
end
end
@@ -153,4 +153,10 @@ class WorkPackages::ProgressForm < ApplicationForm
{}
end
end
+
+ # Remaining work field is enabled when work is set, or when there are errors
+ # on fields so that they can be corrected.
+ def disabled_remaining_work_field?
+ @work_package.estimated_hours.nil? && @work_package.errors.empty?
+ end
end