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
[#63737] Render help text icon in Primerized forms
Alexander Brandon Coles304c6ea85ed9
diff --git a/app/forms/application_form.rb b/app/forms/application_form.rbindex 87a6882aa5e..a45ed39c78d 100644--- a/app/forms/application_form.rb+++ b/app/forms/application_form.rb@@ -29,6 +29,8 @@#++class ApplicationForm < Primer::Forms::Base+ include AttributeHelpTexts::FormHelper+def self.settings_formform do |f|f = Settings::FormDecorator.new(f)@@ -41,9 +43,7 @@ class ApplicationForm < Primer::Forms::Baseend# @return [ActionView::Base] the view helper instance- def helpers- @view_context.helpers- end+ delegate :helpers, to: :@view_context# @return [ActiveRecord::Base] the model instance given to the form builderdef modeldiff --git a/app/forms/attribute_help_texts/form_helper.rb b/app/forms/attribute_help_texts/form_helper.rbnew file mode 100644index 00000000000..ced8acacdb7--- /dev/null+++ b/app/forms/attribute_help_texts/form_helper.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module AttributeHelpTexts+ module FormHelper+ def wrap_attribute_label_with_help_text(label, attribute)+ render OpenProject::Common::AttributeLabelComponent.new(+ model:,+ attribute:,+ tag: nil,+ current_user: User.current+ ).with_content(label)+ end+ end+enddiff --git a/frontend/src/global_styles/primer/_overrides.sass b/frontend/src/global_styles/primer/_overrides.sassindex b8a1e1cc1c4..bb47bd45618 100644--- a/frontend/src/global_styles/primer/_overrides.sass+++ b/frontend/src/global_styles/primer/_overrides.sass@@ -117,3 +117,14 @@ ul.SegmentedControl,.generic-table.generic-table--action-menu-buttonmin-width: max-content !important++.FormControl-label:has(.op-attribute-help-text)+ @extend .op-attribute-label++ // the width of a space between the label text and asterisk+ > :not(.op-attribute-help-text)::before+ content: "\00a0"++ // we override ordering to display help text after the asterisk+ > .op-attribute-help-text+ order: 1diff --git a/lib/primer/open_project/forms/dsl/input_methods.rb b/lib/primer/open_project/forms/dsl/input_methods.rbindex 25ada7426ca..55fb66f36fd 100644--- a/lib/primer/open_project/forms/dsl/input_methods.rb+++ b/lib/primer/open_project/forms/dsl/input_methods.rb@@ -44,6 +44,21 @@ module Primerdef work_package_autocompleter(**, &)add_input WorkPackageAutocompleterInput.new(builder:, form:, **, &)end++ def decorate_options(include_help_text: true, **options)+ if include_help_text && supports_help_texts?(builder.object)+ options[:label] = form.wrap_attribute_label_with_help_text(options[:label], options[:name])+ end+ options+ end++ private++ def supports_help_texts?(model)+ return @supports_help_texts if defined?(@supports_help_texts)++ @supports_help_texts = model && ::AttributeHelpText.available_types.include?(model.model_name)+ endendendend