From 2d2fccce8c04df89bbcf32ec2c8f2493431b1894 Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Tue, 13 Jan 2026 20:01:09 +0100 Subject: [PATCH] add has_comment to field formats using primer form --- app/forms/custom_fields/details_form.rb | 12 ++++++++++++ .../shared_custom_field_expectations.rb | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/app/forms/custom_fields/details_form.rb b/app/forms/custom_fields/details_form.rb index eb37d53f2ee..87351ee8f17 100644 --- a/app/forms/custom_fields/details_form.rb +++ b/app/forms/custom_fields/details_form.rb @@ -136,6 +136,14 @@ module CustomFields ) end + if show_has_comment_field? + details_form.check_box( + name: :has_comment, + label: label(:has_comment), + caption: instructions(:has_comment) + ) + end + if show_is_required_field? details_form.check_box( name: :is_required, @@ -224,6 +232,10 @@ module CustomFields %w[text].include?(model.field_format) end + def show_has_comment_field? + model.can_have_comment? + end + def show_is_required_field? %w[calculated_value bool].exclude?(model.field_format) end diff --git a/spec/features/admin/custom_fields/shared_custom_field_expectations.rb b/spec/features/admin/custom_fields/shared_custom_field_expectations.rb index 6ea6b8db63c..12502c3e5f4 100644 --- a/spec/features/admin/custom_fields/shared_custom_field_expectations.rb +++ b/spec/features/admin/custom_fields/shared_custom_field_expectations.rb @@ -150,6 +150,7 @@ RSpec.shared_examples_for "expected fields for the custom field's format", :aggr # Form element labels, default English translation in the trailing comment: let(:label_name) { I18n.t("attributes.name") } # Name let(:label_section) { I18n.t("activerecord.attributes.project_custom_field.custom_field_section") } # Section + let(:label_has_comment) { I18n.t("activerecord.attributes.custom_field.has_comment") } # Add a comment text field let(:label_is_for_all) { I18n.t("attributes.is_for_all") } # For all projects let(:label_admin_only) { I18n.t("activerecord.attributes.custom_field.admin_only") } # Admin-only let(:label_searchable) { I18n.t("activerecord.attributes.custom_field.searchable") } # Searchable @@ -185,6 +186,12 @@ RSpec.shared_examples_for "expected fields for the custom field's format", :aggr expect(page).to have_no_label(label_section) end + if type == "Project" + expect(page).to have_field(label_has_comment) + else + expect(page).to have_no_label(label_has_comment) + end + if type == "Work package" expect(page).to have_field(label_is_filter) else