Shortens filter param names.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5279 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
25ea0f34a6
commit
a669dfbd7f
|
@ -27,7 +27,7 @@ class QueriesController < ApplicationController
|
|||
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
||||
@query.column_names = nil if params[:default_columns]
|
||||
|
||||
@query.add_filters(params[:fields], params[:operators], params[:values]) if params[:fields]
|
||||
@query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f]
|
||||
@query.group_by ||= params[:group_by]
|
||||
|
||||
if request.post? && params[:confirm] && @query.save
|
||||
|
@ -41,7 +41,7 @@ class QueriesController < ApplicationController
|
|||
def edit
|
||||
if request.post?
|
||||
@query.filters = {}
|
||||
@query.add_filters(params[:fields], params[:operators], params[:values]) if params[:fields]
|
||||
@query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f]
|
||||
@query.attributes = params[:query]
|
||||
@query.project = nil if params[:query_is_for_all]
|
||||
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -78,9 +78,9 @@ module QueriesHelper
|
|||
# Give it a name, required to be valid
|
||||
@query = Query.new(:name => "_")
|
||||
@query.project = @project
|
||||
if params[:fields]
|
||||
if params[:fields] || params[:f]
|
||||
@query.filters = {}
|
||||
@query.add_filters(params[:fields], params[:operators], params[:values])
|
||||
@query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v])
|
||||
else
|
||||
@query.available_filters.keys.each do |field|
|
||||
@query.add_short_filter(field, params[field]) if params[field]
|
||||
|
|
|
@ -83,26 +83,26 @@ Event.observe(document,"dom:loaded", apply_filters_observer);
|
|||
options = filter[1] %>
|
||||
<tr <%= 'style="display:none;"' unless query.has_filter?(field) %> id="tr_<%= field %>" class="filter">
|
||||
<td style="width:200px;">
|
||||
<%= check_box_tag 'fields[]', field, query.has_filter?(field), :onclick => "toggle_filter('#{field}');", :id => "cb_#{field}" %>
|
||||
<%= check_box_tag 'f[]', field, query.has_filter?(field), :onclick => "toggle_filter('#{field}');", :id => "cb_#{field}" %>
|
||||
<label for="cb_<%= field %>"><%= filter[1][:name] || l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) %></label>
|
||||
</td>
|
||||
<td style="width:150px;">
|
||||
<%= select_tag "operators[#{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.operator_for(field)), :id => "operators_#{field}", :onchange => "toggle_operator('#{field}');", :class => "select-small", :style => "vertical-align: top;" %>
|
||||
</td>
|
||||
<td>
|
||||
<div id="div_values_<%= field %>" style="display:none;">
|
||||
<% case options[:type]
|
||||
when :list, :list_optional, :list_status, :list_subprojects %>
|
||||
<select <%= "multiple=true" if query.values_for(field) and query.values_for(field).length > 1 %> name="values[<%= field %>][]" id="values_<%= field %>" class="select-small" style="vertical-align: top;">
|
||||
<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;">
|
||||
<%= options_for_select options[:values], query.values_for(field) %>
|
||||
</select>
|
||||
<%= link_to_function image_tag('bullet_toggle_plus.png'), "toggle_multi_select('#{field}');", :style => "vertical-align: bottom;" %>
|
||||
<% when :date, :date_past %>
|
||||
<%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %> <%= l(:label_day_plural) %>
|
||||
<%= text_field_tag "v[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %> <%= l(:label_day_plural) %>
|
||||
<% when :string, :text %>
|
||||
<%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 30, :class => "select-small" %>
|
||||
<%= text_field_tag "v[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 30, :class => "select-small" %>
|
||||
<% when :integer %>
|
||||
<%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %>
|
||||
<%= text_field_tag "v[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<script type="text/javascript">toggle_filter('<%= field %>');</script>
|
||||
|
@ -120,4 +120,4 @@ Event.observe(document,"dom:loaded", apply_filters_observer);
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<%= hidden_field_tag 'fields[]', '' %>
|
||||
<%= hidden_field_tag 'f[]', '' %>
|
||||
|
|
|
@ -139,9 +139,9 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
|
||||
def test_index_with_project_and_filter
|
||||
get :index, :project_id => 1, :set_filter => 1,
|
||||
:fields => ['tracker_id'],
|
||||
:operators => {'tracker_id' => '='},
|
||||
:values => {'tracker_id' => ['1']}
|
||||
:f => ['tracker_id'],
|
||||
:op => {'tracker_id' => '='},
|
||||
:v => {'tracker_id' => ['1']}
|
||||
assert_response :success
|
||||
assert_template 'index.rhtml'
|
||||
assert_not_nil assigns(:issues)
|
||||
|
|
|
@ -64,9 +64,9 @@ class QueriesControllerTest < ActionController::TestCase
|
|||
:project_id => 'ecookbook',
|
||||
:confirm => '1',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:f => ["status_id", "assigned_to_id"],
|
||||
:op => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:v => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_new_project_public_query", "is_public" => "1"}
|
||||
|
||||
q = Query.find_by_name('test_new_project_public_query')
|
||||
|
|
Loading…
Reference in New Issue