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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
styling of text when preview is not available
ulferts9307d0942f64
diff --git a/app/components/open_project/common/attribute_component.html.erb b/app/components/open_project/common/attribute_component.html.erbindex 2d62ab96b2c..b8b7e98eb60 100644--- a/app/components/open_project/common/attribute_component.html.erb+++ b/app/components/open_project/common/attribute_component.html.erb@@ -2,16 +2,24 @@data-controller="attribute"data-application-target="dynamic"class="op-long-text-attribute">- <p- data-attribute-target="descriptionText"- class="op-long-text-attribute--text">- <%= @attr_value %>- </p>- <%= render(Primer::Alpha::Dialog.new(id: @id, title: @name, size: :large)) do |component|- component.with_show_button(scheme: :link, display: (is_multi_type(@description) ? :block : :none), data: { 'attribute-target': 'expandButton' }) { I18n.t('js.label_expand') }- component.with_body(mt: 2) { helpers.format_text(@description) }- component.with_header+ <%= render(+ Primer::Beta::Text.new(tag: :p,+ classes: "op-long-text-attribute--text",+ color: text_color,+ data: {+ 'attribute-target': "descriptionText"+ })) { text } %>++ <%= render(+ Primer::Alpha::Dialog.new(id: id,+ title: name,+ size: :large)) do |component|+ component.with_show_button(scheme: :link,+ display: display_expand_button_value,+ data: { 'attribute-target': 'expandButton' }) { I18n.t('js.label_expand') }+ component.with_body(mt: 2) { modal_body }+ component.with_headerend%>-</div>\ No newline at end of file+</div>diff --git a/app/components/open_project/common/attribute_component.rb b/app/components/open_project/common/attribute_component.rbindex 6690f494622..537b3ca2b64 100644--- a/app/components/open_project/common/attribute_component.rb+++ b/app/components/open_project/common/attribute_component.rb@@ -30,15 +30,34 @@ require 'nokogiri'module OpenProjectmodule Commonclass AttributeComponent < Primer::Component+ attr_reader :id,+ :name,+ :description+def initialize(id, name, description, **args)super@id = id@name = name@description = description- @attr_value = is_multi_type(description) ? I18n.t('js.label_preview_not_available') : Nokogiri::HTML(description).text@system_arguments = argsend+ def text+ is_multi_type(description) ? I18n.t(:label_preview_not_available) : Nokogiri::HTML(description).text+ end++ def modal_body+ helpers.format_text(description)+ end++ def display_expand_button_value+ is_multi_type(description) ? :block : :none+ end++ def text_color+ :muted if is_multi_type(description)+ end+privatedef is_multi_type(text)diff --git a/app/components/open_project/common/attribute_component.sass b/app/components/open_project/common/attribute_component.sassindex 34d65c088e8..ff6a4ab2658 100644--- a/app/components/open_project/common/attribute_component.sass+++ b/app/components/open_project/common/attribute_component.sass@@ -4,3 +4,4 @@&--text@include text-shortenermargin: 0+ flex-grow: 1diff --git a/config/locales/en.yml b/config/locales/en.ymlindex b5154782a53..eb59e3cd864 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2142,6 +2142,7 @@ en:label_precedes: "precedes"label_preferences: "Preferences"label_preview: "Preview"+ label_preview_not_available: "(Preview not available)"label_previous: "Previous"label_previous_week: "Previous week"label_principal_invite_via_email: " or invite new users via email"diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex dda5b376780..4b0de20a7ed 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -459,7 +459,6 @@ en:label_email: "Email"label_equals: "is"label_expand: "Expand"- label_preview_not_available: "Preview not available"label_expanded: "expanded"label_expand_all: "Expand all"label_expand_project_menu: "Expand project menu"diff --git a/lookbook/previews/open_project/common/attribute_component_preview.rb b/lookbook/previews/open_project/common/attribute_component_preview.rbindex 06819bac156..ab26e9b25ad 100644--- a/lookbook/previews/open_project/common/attribute_component_preview.rb+++ b/lookbook/previews/open_project/common/attribute_component_preview.rb@@ -4,9 +4,11 @@ module OpenProjectclass AttributeComponentPreview < Lookbook::Preview# @param id# @param name- # @param description- def default(id: 'attribute_modal', name: 'Description', description: '<figure>This button is only visible when the description is truncated or it includes a figure or macro</figure>')- render OpenProject::Common::AttributeComponent.new(id, name, description)+ # @param text+ def default(id: 'attribute_modal',+ name: 'Description',+ text: '<figure>This button is only visible when the text is truncated or includes a figure or macro.</figure>')+ render OpenProject::Common::AttributeComponent.new(id, name, text)endendend