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

[#66093] #calculation_error -> #first_calculation_error

Tobias Dillmann1b811fe94711
diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb
index ad05fe27816..8c3d66abee1 100644
--- a/app/components/projects/row_component.rb
+++ b/app/components/projects/row_component.rb
@@ -100,15 +100,15 @@ module Projects
end
end
- def render_calculated_value(calculated_value, custom_value)
- if (error = calculated_value.calculation_error(project:))
+ def render_calculated_value(custom_field, custom_value)
+ if (error = custom_field.first_calculation_error(project:))
render(Primer::Alpha::Dialog.new(title: I18n.t("calculated_values.error_dialog.title"),
data: {
- test_selector: "calculated-value-error-dialog-#{calculated_value.id}"
+ test_selector: "calculated-value-error-dialog-#{custom_field.id}"
})) do |dialog|
dialog.with_show_button(icon: "alert-fill",
"aria-label": I18n.t("calculated_values.error_dialog.title"),
- data: { test_selector: "calculated-value-error-btn-#{calculated_value.id}" },
+ data: { test_selector: "calculated-value-error-btn-#{custom_field.id}" },
scheme: :invisible)
dialog.with_body { error.error_message }
end
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index d48a03cdb4b..81b8478f245 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -353,7 +353,7 @@ class CustomField < ApplicationRecord
#
# When there is at least one calculation error, will return the first one - or `nil` if there are none.
# Use this method when you want to present a calculation error to the user.
- def calculation_error(project:)
+ def first_calculation_error(project:)
return nil unless calculated_value?
calculated_value_errors.where(project:).first
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/item_component.rb b/modules/overviews/app/components/overviews/project_custom_fields/item_component.rb
index 585e4247a3c..b7047bc38f4 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/item_component.rb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/item_component.rb
@@ -50,11 +50,11 @@ module Overviews
end
def calculation_error?
- @project_custom_field.calculation_error(project: @project).present?
+ @project_custom_field.first_calculation_error(project: @project).present?
end
def render_calculation_error
- error = @project_custom_field.calculation_error(project: @project)
+ error = @project_custom_field.first_calculation_error(project: @project)
render(Primer::OpenProject::FlexLayout.new(align_items: :flex_start,
data: {