diff --git a/app/models/query.rb b/app/models/query.rb index d2daf2c451..1a1959dd7a 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -281,11 +281,12 @@ class Query < ActiveRecord::Base project_clauses = [] if project && !project.descendants.active.empty? ids = [project.id] - if has_filter?("subproject_id") - case operator_for("subproject_id") + subproject_filter = filter_for 'subproject_id' + if subproject_filter + case subproject_filter.operator when '=' # include the selected subprojects - ids += values_for("subproject_id").each(&:to_i) + ids += subproject_filter.values.each(&:to_i) when '!*' # main project only else diff --git a/app/views/queries/_filters.html.erb b/app/views/queries/_filters.html.erb index db387178e8..246b0ca2a3 100644 --- a/app/views/queries/_filters.html.erb +++ b/app/views/queries/_filters.html.erb @@ -117,25 +117,26 @@ Event.observe(document,"dom:loaded", apply_filters_observer); <%= label_tag "op_#{field}", l(:description_filter), :class => "hidden-for-sighted" %> - <%= select_tag "op[#{field}]", options_for_select(operators_for_select(options[:type]), query.operator_for(field)), :id => "operators_#{field}", :onchange => "toggle_operator('#{field}');", :class => "select-small", :style => "vertical-align: top;" %> + <%= select_tag "op[#{field}]", options_for_select(operators_for_select(options[:type]), query.filter_for(field).try(:operator)), :id => "operators_#{field}", :onchange => "toggle_operator('#{field}');", :class => "select-small", :style => "vertical-align: top;" %>