From 6e228dc06a041e646730ca1bfce1634707d4fe4e Mon Sep 17 00:00:00 2001 From: Henriette Darge Date: Thu, 19 Feb 2026 15:54:35 +0100 Subject: [PATCH] Fine-tune the shown forms of custom fields & fix tests --- .../custom_fields/details_component.rb | 8 +++++-- app/forms/custom_fields/details_form.rb | 6 +++--- .../project_custom_fields/list_items.html.erb | 6 +++--- .../custom_fields/_custom_options.html.erb | 10 ++++----- app/views/custom_fields/list_items.html.erb | 6 +++--- .../custom_fields/projects/boolean_spec.rb | 4 +--- .../projects/create_in_section_spec.rb | 2 +- .../custom_fields/projects/shared_context.rb | 12 +---------- .../shared_custom_field_expectations.rb | 21 ++++++++----------- .../custom_fields/time_entries/list_spec.rb | 12 +++++++---- .../custom_fields/work_packages/list_spec.rb | 9 ++++---- .../work_packages/multi_value_list_spec.rb | 9 +++++--- .../custom_fields/reorder_options_spec.rb | 4 ++++ spec/models/custom_field_spec.rb | 11 ---------- spec/support/pages/custom_fields/index.rb | 2 +- 15 files changed, 56 insertions(+), 66 deletions(-) diff --git a/app/components/custom_fields/details_component.rb b/app/components/custom_fields/details_component.rb index 31b51f12b82..e2d4f0272ee 100644 --- a/app/components/custom_fields/details_component.rb +++ b/app/components/custom_fields/details_component.rb @@ -84,8 +84,12 @@ module CustomFields end def persisted_cf_has_no_items_or_projects? - if custom_field.list? && custom_field.custom_options.empty? && custom_field.projects.empty? - return true + if custom_field.list? && custom_field.custom_options.empty? + if custom_field.respond_to?(:projects) + custom_field.projects.empty? + end + + true end custom_field.persisted? && diff --git a/app/forms/custom_fields/details_form.rb b/app/forms/custom_fields/details_form.rb index 57d4f747f26..eb37d53f2ee 100644 --- a/app/forms/custom_fields/details_form.rb +++ b/app/forms/custom_fields/details_form.rb @@ -82,7 +82,6 @@ module CustomFields details_form.text_field( name: :regexp, label: label(:regexp), - size: 50, caption: instructions(:regexp), input_width: :medium ) @@ -238,7 +237,7 @@ module CustomFields end def show_right_to_left_field? - %w[text].include?(model.field_format) + model.is_a?(WorkPackageCustomField) && %w[text].include?(model.field_format) end def show_multi_value_field? @@ -258,7 +257,8 @@ module CustomFields end def show_is_searchable_field? - %w[bool date float int user version hierarchy weighted_item_list calculated_value].exclude?(model.field_format) + (model.is_a?(WorkPackageCustomField) || model.is_a?(ProjectCustomField)) && + %w[bool date float int user version hierarchy weighted_item_list calculated_value].exclude?(model.field_format) end def show_non_open_versions_field? diff --git a/app/views/admin/settings/project_custom_fields/list_items.html.erb b/app/views/admin/settings/project_custom_fields/list_items.html.erb index f0adfc60203..6247d928387 100644 --- a/app/views/admin/settings/project_custom_fields/list_items.html.erb +++ b/app/views/admin/settings/project_custom_fields/list_items.html.erb @@ -65,10 +65,10 @@ See COPYRIGHT and LICENSE files for more details. flex.with_column do render Primer::Beta::Button.new( scheme: :primary, - type: :submit, - ) do |button| + type: :submit + ) do |button| button.with_leading_visual_icon(icon: :check) - t(:button_submit) + t(:button_save) end end end diff --git a/app/views/custom_fields/_custom_options.html.erb b/app/views/custom_fields/_custom_options.html.erb index b122d871e5a..fa89235fbe6 100644 --- a/app/views/custom_fields/_custom_options.html.erb +++ b/app/views/custom_fields/_custom_options.html.erb @@ -93,7 +93,7 @@ See COPYRIGHT and LICENSE files for more details. no_label: true %> - + <%= co_f.check_box :default_value, container_class: "custom-option-default-value", data: { @@ -105,7 +105,7 @@ See COPYRIGHT and LICENSE files for more details. <%= op_icon("icon-context icon-arrow-down2 icon-small") %>