# HG changeset patch # User Toshi MARUYAMA # Date 1366638971 -32400 # Node ID 2faf648733bcc8b01bc063eb93a246843f63481c # Parent 80f0903f791c34946a748f3e51164cf01e7cf3f3 (#13849) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -29,6 +29,25 @@ module QueriesHelper end end + def grouped_filters_options_for_select(query) + option_hash = ActiveSupport::OrderedHash.new + query.available_filters.each do |field, field_options| + if field_options[:type] == :relation + label = :label_related_issues + elsif field_options[:type] == :date_past || field_options[:type] == :date + label = :label_grouped_filter_date + else + label = :label_grouped_filter_non_date + end + (option_hash[label] ||= []) << [field_options[:name], field] + end + options = [] + option_hash.each do |k, v| + options << [l(k), v] + end + grouped_options_for_select(options) + end + def query_filters_hidden_tags(query) tags = ''.html_safe query.filters.each do |field, options| diff --git a/app/views/queries/_filters.html.erb b/app/views/queries/_filters.html.erb --- a/app/views/queries/_filters.html.erb +++ b/app/views/queries/_filters.html.erb @@ -20,7 +20,10 @@ var allProjects = <%= raw query.all_proj <%= label_tag('add_filter_select', l(:label_filter_add)) %> -<%= select_tag 'add_filter_select', filters_options_for_select(query), :name => nil %> +<%= select_tag('add_filter_select', + content_tag(:option) + + grouped_filters_options_for_select(query), + :name => nil) %> diff --git a/config/locales/en.yml b/config/locales/en.yml --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -893,6 +893,8 @@ en: label_cross_project_hierarchy: With project hierarchy label_cross_project_system: With all projects label_gantt_progress_line: Progress line + label_grouped_filter_non_date: Filters + label_grouped_filter_date: Date filters button_login: Login button_submit: Submit diff --git a/public/javascripts/application.js b/public/javascripts/application.js --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -106,7 +106,7 @@ function addFilter(field, operator, valu } $('#cb_'+fieldId).attr('checked', true); toggleFilter(field); - $('#add_filter_select').val('').children('option').each(function() { + $('#add_filter_select').val('').children('optgroup').children('option').each(function() { if ($(this).attr('value') == field) { $(this).attr('disabled', true); }