From 5c075233ae9c9a57682994336d6f9a39931a0040 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Wed, 5 Apr 2023 09:23:44 +0000 Subject: [PATCH] Group text filters in the filter select list (#38402). Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@22165 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/queries_helper.rb | 2 ++ test/helpers/queries_helper_test.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index d40ee2587..10c59c1a4 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -43,6 +43,8 @@ module QueriesHelper group = :label_time_tracking elsif %w(attachment attachment_description).include?(field) group = :label_attachment + elsif [:string, :text, :search].include?(field_options[:type]) + group = :label_string end if group (grouped[group] ||= []) << [field_options[:name], field] diff --git a/test/helpers/queries_helper_test.rb b/test/helpers/queries_helper_test.rb index 35d0919a0..b2943bd03 100644 --- a/test/helpers/queries_helper_test.rb +++ b/test/helpers/queries_helper_test.rb @@ -82,6 +82,16 @@ class QueriesHelperTest < Redmine::HelperTest end end + def test_filters_options_for_select_should_group_text_filters + with_locale 'en' do + options = filters_options_for_select(IssueQuery.new) + assert_select_in options, 'optgroup[label=?]', 'Text', 1 + assert_select_in options, 'optgroup > option[value=subject]', :text => 'Subject' + assert_select_in options, 'optgroup > option[value=cf_2]', :text => 'Searchable field' + assert_select_in options, 'optgroup > option:last-of-type[value=any_searchable]', :text => 'Any searchable text' + end + end + def test_query_to_csv_should_translate_boolean_custom_field_values f = IssueCustomField.generate!(:field_format => 'bool', :name => 'Boolean', :is_for_all => true, :trackers => Tracker.all) issues = [ -- 2.39.5