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

Introduce optional formatting for the AttributeComponent in order to pass pre-formatted values to it.

Dombi Attila95a0b0825dcf
diff --git a/app/components/open_project/common/attribute_component.rb b/app/components/open_project/common/attribute_component.rb
index 993b893d5ed..8857890f824 100644
--- a/app/components/open_project/common/attribute_component.rb
+++ b/app/components/open_project/common/attribute_component.rb
@@ -34,11 +34,12 @@ module OpenProject
:name,
:description,
:lines,
- :background_reference_id
+ :background_reference_id,
+ :formatted
PARAGRAPH_CSS_CLASS = "op-uc-p".freeze
- def initialize(id, name, description, lines: 1, background_reference_id: "content", **args)
+ def initialize(id, name, description, lines: 1, background_reference_id: "content", formatted: false, **args)
super
@id = id
@name = name
@@ -46,6 +47,7 @@ module OpenProject
@system_arguments = args
@lines = lines
@background_reference_id = background_reference_id
+ @formatted = formatted
end
def short_text
@@ -57,7 +59,7 @@ module OpenProject
end
def full_text
- @full_text ||= helpers.format_text(description)
+ @full_text ||= formatted ? description : helpers.format_text(description)
end
def display_expand_button_value
diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb
index 5e195d7500f..e88037f71a2 100644
--- a/app/components/projects/row_component.rb
+++ b/app/components/projects/row_component.rb
@@ -54,10 +54,15 @@ module Projects
return nil unless user_can_view_project?
cf = column.custom_field
- custom_value = project.custom_value_for(cf)
+ custom_value = project.formatted_custom_value_for(cf)
if cf.field_format == "text" && custom_value.present?
- render OpenProject::Common::AttributeComponent.new("dialog-#{project.id}-cf-#{cf.id}", cf.name, custom_value.value)
+ render OpenProject::Common::AttributeComponent.new(
+ "dialog-#{project.id}-cf-#{cf.id}",
+ cf.name,
+ custom_value,
+ formatted: true
+ )
elsif custom_value.is_a?(Array)
safe_join(Array(custom_value).compact_blank, ", ")
else