From a669dfbd7f9408b4d341977a6d9c79bafb11b281 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 1 Apr 2011 15:00:23 +0000 Subject: [PATCH] Shortens filter param names. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5279 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/queries_controller.rb | 4 ++-- app/helpers/queries_helper.rb | 8 ++++---- app/views/queries/_filters.rhtml | 14 +++++++------- test/functional/issues_controller_test.rb | 6 +++--- test/functional/queries_controller_test.rb | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/controllers/queries_controller.rb b/app/controllers/queries_controller.rb index 0b798636c..e54c9befb 100644 --- a/app/controllers/queries_controller.rb +++ b/app/controllers/queries_controller.rb @@ -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? diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index e9ab3769f..b6dc697e3 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -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] diff --git a/app/views/queries/_filters.rhtml b/app/views/queries/_filters.rhtml index d6d3db7f5..c0b79bfeb 100644 --- a/app/views/queries/_filters.rhtml +++ b/app/views/queries/_filters.rhtml @@ -83,26 +83,26 @@ Event.observe(document,"dom:loaded", apply_filters_observer); options = filter[1] %> id="tr_<%= field %>" class="filter"> - <%= 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}" %> - <%= 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;" %> @@ -120,4 +120,4 @@ Event.observe(document,"dom:loaded", apply_filters_observer); -<%= hidden_field_tag 'fields[]', '' %> +<%= hidden_field_tag 'f[]', '' %> diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 6e445438f..ed81597da 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -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) diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb index 7c5d7ca56..3ef897d69 100644 --- a/test/functional/queries_controller_test.rb +++ b/test/functional/queries_controller_test.rb @@ -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')