Project

General

Profile

Feature #13849 » grouped-filter-trunk-r13551.diff

Go MAEDA, 2014-11-03 09:48

View differences:

app/helpers/queries_helper.rb (working copy)
31 31
    end
32 32
  end
33 33

  
34
  def grouped_filters_options_for_select(query)
35
    option_hash = ActiveSupport::OrderedHash.new
36
    query.available_filters.each do |field, field_options|
37
      if field_options[:type] == :relation
38
        label = :label_related_issues
39
      elsif field_options[:type] == :date_past || field_options[:type] == :date
40
        label = :label_grouped_filter_date
41
      else
42
        label = :label_grouped_filter_non_date
43
      end
44
      (option_hash[label] ||= []) << [field_options[:name], field]
45
    end
46
    options = []
47
    option_hash.each do |k, v|
48
      options << [l(k), v]
49
    end
50
    grouped_options_for_select(options)
51
  end
52

  
34 53
  def query_filters_hidden_tags(query)
35 54
    tags = ''.html_safe
36 55
    query.filters.each do |field, options|
app/views/queries/_filters.html.erb (working copy)
20 20
</td>
21 21
<td class="add-filter">
22 22
<%= label_tag('add_filter_select', l(:label_filter_add)) %>
23
<%= select_tag 'add_filter_select', filters_options_for_select(query), :name => nil %>
23
<%= select_tag('add_filter_select',
24
               content_tag(:option) +
25
                 grouped_filters_options_for_select(query),
26
               :name => nil) %>
24 27
</td>
25 28
</tr>
26 29
</table>
config/locales/en.yml (working copy)
920 920
  label_latest_compatible_version: Latest compatible version
921 921
  label_unknown_plugin: Unknown plugin
922 922
  label_add_projects: Add projects
923
  label_grouped_filter_non_date: Filters
924
  label_grouped_filter_date: Date filters
923 925

  
924 926
  button_login: Login
925 927
  button_submit: Submit
public/javascripts/application.js (working copy)
102 102
  }
103 103
  $('#cb_'+fieldId).prop('checked', true);
104 104
  toggleFilter(field);
105
  $('#add_filter_select').val('').children('option').each(function() {
105
  $('#add_filter_select').val('').children('optgroup').children('option').each(function() {
106 106
    if ($(this).attr('value') == field) {
107 107
      $(this).attr('disabled', true);
108 108
    }
(9-9/9)