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 error messages consistent in progress popover

Christophe Bliard88b2e1f83d0e
diff --git a/app/forms/work_packages/progress_form.rb b/app/forms/work_packages/progress_form.rb
index 58cad379767..f9da8ecd385 100644
--- a/app/forms/work_packages/progress_form.rb
+++ b/app/forms/work_packages/progress_form.rb
@@ -144,7 +144,8 @@ class WorkPackages::ProgressForm < ApplicationForm
text_field_options = {
name:,
value: field_value(name),
- label:
+ label:,
+ validation_message: validation_message(name)
}
text_field_options.reverse_merge!(default_field_options(name))
@@ -179,6 +180,12 @@ class WorkPackages::ProgressForm < ApplicationForm
end
end
+ def validation_message(name)
+ # it's ok to take the first error only, that's how primer_view_component does it anyway.
+ message = @work_package.errors.messages_for(name).first
+ message&.upcase_first
+ end
+
def as_percent(value)
value ? "#{value}%" : nil
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 37d0bcdd9e9..b5d4509a723 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1113,10 +1113,10 @@ en:
assigned_to:
format: "%{message}"
done_ratio:
- does_not_match_work_and_remaining_work: "does not match work and remaining work"
- cannot_be_set_when_work_is_zero: "cannot be set when work is zero"
- must_be_set_when_remaining_work_is_set: "Required when Remaining work is set."
- must_be_set_when_work_and_remaining_work_are_set: "Required when Work and Remaining work are set."
+ does_not_match_work_and_remaining_work: "does not match Work and Remaining work"
+ cannot_be_set_when_work_is_zero: "cannot be set when Work is 0h"
+ must_be_set_when_remaining_work_is_set: "required when Remaining work is set."
+ must_be_set_when_work_and_remaining_work_are_set: "required when Work and Remaining work are set."
inclusion: "must be between 0 and 100."
due_date:
not_start_date: "is not on start date, although this is required for milestones."
@@ -1146,19 +1146,17 @@ en:
does_not_exist: "The specified category does not exist."
estimated_hours:
not_a_number: "is not a valid duration."
- cant_be_inferior_to_remaining_work: "Cannot be lower than Remaining work."
- must_be_set_when_remaining_work_and_percent_complete_are_set: "Required when Remaining work and % Complete are set."
- format: "%{message}"
+ cant_be_inferior_to_remaining_work: "cannot be lower than Remaining work."
+ must_be_set_when_remaining_work_and_percent_complete_are_set: "required when Remaining work and % Complete are set."
remaining_hours:
not_a_number: "is not a valid duration."
- cant_exceed_work: "Cannot be higher than Work."
- must_be_set_when_work_is_set: "Required when Work is set."
- must_be_set_when_work_and_percent_complete_are_set: "Required when Work and % Complete are set."
+ cant_exceed_work: "cannot be higher than Work."
+ must_be_set_when_work_is_set: "required when Work is set."
+ must_be_set_when_work_and_percent_complete_are_set: "required when Work and % Complete are set."
must_be_set_to_zero_hours_when_work_is_set_and_percent_complete_is_100p: >-
- must be set to 0h when Work is set and % Complete is 100%.
+ must be 0h when Work is set and % Complete is 100%.
must_be_unset_when_work_is_unset_and_percent_complete_is_100p: >-
- must be unset when Work is unset and % Complete is 100%.
- format: "%{message}"
+ must be empty when Work is empty and % Complete is 100%.
readonly_status: "The work package is in a readonly status so its attributes cannot be changed."
type:
attributes: