@@ -27,7 +27,7 class QueriesController < ApplicationController | |||||
27 | @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin? |
|
27 | @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin? | |
28 | @query.column_names = nil if params[:default_columns] |
|
28 | @query.column_names = nil if params[:default_columns] | |
29 |
|
29 | |||
30 | @query.add_filters(params[:fields], params[:operators], params[:values]) if params[:fields] |
|
30 | @query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f] | |
31 | @query.group_by ||= params[:group_by] |
|
31 | @query.group_by ||= params[:group_by] | |
32 |
|
32 | |||
33 | if request.post? && params[:confirm] && @query.save |
|
33 | if request.post? && params[:confirm] && @query.save | |
@@ -41,7 +41,7 class QueriesController < ApplicationController | |||||
41 | def edit |
|
41 | def edit | |
42 | if request.post? |
|
42 | if request.post? | |
43 | @query.filters = {} |
|
43 | @query.filters = {} | |
44 | @query.add_filters(params[:fields], params[:operators], params[:values]) if params[:fields] |
|
44 | @query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f] | |
45 | @query.attributes = params[:query] |
|
45 | @query.attributes = params[:query] | |
46 | @query.project = nil if params[:query_is_for_all] |
|
46 | @query.project = nil if params[:query_is_for_all] | |
47 | @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin? |
|
47 | @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin? |
@@ -1,5 +1,5 | |||||
1 |
# |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
@@ -78,9 +78,9 module QueriesHelper | |||||
78 | # Give it a name, required to be valid |
|
78 | # Give it a name, required to be valid | |
79 | @query = Query.new(:name => "_") |
|
79 | @query = Query.new(:name => "_") | |
80 | @query.project = @project |
|
80 | @query.project = @project | |
81 | if params[:fields] |
|
81 | if params[:fields] || params[:f] | |
82 | @query.filters = {} |
|
82 | @query.filters = {} | |
83 | @query.add_filters(params[:fields], params[:operators], params[:values]) |
|
83 | @query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) | |
84 | else |
|
84 | else | |
85 | @query.available_filters.keys.each do |field| |
|
85 | @query.available_filters.keys.each do |field| | |
86 | @query.add_short_filter(field, params[field]) if params[field] |
|
86 | @query.add_short_filter(field, params[field]) if params[field] |
@@ -83,26 +83,26 Event.observe(document,"dom:loaded", apply_filters_observer); | |||||
83 | options = filter[1] %> |
|
83 | options = filter[1] %> | |
84 | <tr <%= 'style="display:none;"' unless query.has_filter?(field) %> id="tr_<%= field %>" class="filter"> |
|
84 | <tr <%= 'style="display:none;"' unless query.has_filter?(field) %> id="tr_<%= field %>" class="filter"> | |
85 | <td style="width:200px;"> |
|
85 | <td style="width:200px;"> | |
86 |
<%= check_box_tag 'f |
|
86 | <%= check_box_tag 'f[]', field, query.has_filter?(field), :onclick => "toggle_filter('#{field}');", :id => "cb_#{field}" %> | |
87 | <label for="cb_<%= field %>"><%= filter[1][:name] || l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) %></label> |
|
87 | <label for="cb_<%= field %>"><%= filter[1][:name] || l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) %></label> | |
88 | </td> |
|
88 | </td> | |
89 | <td style="width:150px;"> |
|
89 | <td style="width:150px;"> | |
90 |
<%= select_tag "op |
|
90 | <%= 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;" %> | |
91 | </td> |
|
91 | </td> | |
92 | <td> |
|
92 | <td> | |
93 | <div id="div_values_<%= field %>" style="display:none;"> |
|
93 | <div id="div_values_<%= field %>" style="display:none;"> | |
94 | <% case options[:type] |
|
94 | <% case options[:type] | |
95 | when :list, :list_optional, :list_status, :list_subprojects %> |
|
95 | when :list, :list_optional, :list_status, :list_subprojects %> | |
96 |
<select <%= "multiple=true" if query.values_for(field) and query.values_for(field).length > 1 %> name="v |
|
96 | <select <%= "multiple=true" if query.values_for(field) and query.values_for(field).length > 1 %> name="v[<%= field %>][]" id="values_<%= field %>" class="select-small" style="vertical-align: top;"> | |
97 | <%= options_for_select options[:values], query.values_for(field) %> |
|
97 | <%= options_for_select options[:values], query.values_for(field) %> | |
98 | </select> |
|
98 | </select> | |
99 | <%= link_to_function image_tag('bullet_toggle_plus.png'), "toggle_multi_select('#{field}');", :style => "vertical-align: bottom;" %> |
|
99 | <%= link_to_function image_tag('bullet_toggle_plus.png'), "toggle_multi_select('#{field}');", :style => "vertical-align: bottom;" %> | |
100 | <% when :date, :date_past %> |
|
100 | <% when :date, :date_past %> | |
101 |
<%= text_field_tag "v |
|
101 | <%= text_field_tag "v[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %> <%= l(:label_day_plural) %> | |
102 | <% when :string, :text %> |
|
102 | <% when :string, :text %> | |
103 |
<%= text_field_tag "v |
|
103 | <%= text_field_tag "v[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 30, :class => "select-small" %> | |
104 | <% when :integer %> |
|
104 | <% when :integer %> | |
105 |
<%= text_field_tag "v |
|
105 | <%= text_field_tag "v[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %> | |
106 | <% end %> |
|
106 | <% end %> | |
107 | </div> |
|
107 | </div> | |
108 | <script type="text/javascript">toggle_filter('<%= field %>');</script> |
|
108 | <script type="text/javascript">toggle_filter('<%= field %>');</script> | |
@@ -120,4 +120,4 Event.observe(document,"dom:loaded", apply_filters_observer); | |||||
120 | </td> |
|
120 | </td> | |
121 | </tr> |
|
121 | </tr> | |
122 | </table> |
|
122 | </table> | |
123 |
<%= hidden_field_tag 'f |
|
123 | <%= hidden_field_tag 'f[]', '' %> |
@@ -139,9 +139,9 class IssuesControllerTest < ActionController::TestCase | |||||
139 |
|
139 | |||
140 | def test_index_with_project_and_filter |
|
140 | def test_index_with_project_and_filter | |
141 | get :index, :project_id => 1, :set_filter => 1, |
|
141 | get :index, :project_id => 1, :set_filter => 1, | |
142 |
:f |
|
142 | :f => ['tracker_id'], | |
143 |
:op |
|
143 | :op => {'tracker_id' => '='}, | |
144 |
:v |
|
144 | :v => {'tracker_id' => ['1']} | |
145 | assert_response :success |
|
145 | assert_response :success | |
146 | assert_template 'index.rhtml' |
|
146 | assert_template 'index.rhtml' | |
147 | assert_not_nil assigns(:issues) |
|
147 | assert_not_nil assigns(:issues) |
@@ -64,9 +64,9 class QueriesControllerTest < ActionController::TestCase | |||||
64 | :project_id => 'ecookbook', |
|
64 | :project_id => 'ecookbook', | |
65 | :confirm => '1', |
|
65 | :confirm => '1', | |
66 | :default_columns => '1', |
|
66 | :default_columns => '1', | |
67 |
:f |
|
67 | :f => ["status_id", "assigned_to_id"], | |
68 |
:op |
|
68 | :op => {"assigned_to_id" => "=", "status_id" => "o"}, | |
69 |
:v |
|
69 | :v => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, | |
70 | :query => {"name" => "test_new_project_public_query", "is_public" => "1"} |
|
70 | :query => {"name" => "test_new_project_public_query", "is_public" => "1"} | |
71 |
|
71 | |||
72 | q = Query.find_by_name('test_new_project_public_query') |
|
72 | q = Query.find_by_name('test_new_project_public_query') |
General Comments 0
You need to be logged in to leave comments.
Login now