From 42653cef3257469cdba56c73ca554fc15dcd7644 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 3 Apr 2011 14:31:32 +0000 Subject: [PATCH] Shorten query[column_names] param name. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5304 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/queries_controller.rb | 5 ++++- app/helpers/queries_helper.rb | 2 +- app/views/queries/_columns.rhtml | 2 +- test/functional/issues_controller_test.rb | 2 +- test/functional/queries_controller_test.rb | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/queries_controller.rb b/app/controllers/queries_controller.rb index e54c9bef..60f3b445 100644 --- a/app/controllers/queries_controller.rb +++ b/app/controllers/queries_controller.rb @@ -25,10 +25,11 @@ class QueriesController < ApplicationController @query.project = params[:query_is_for_all] ? nil : @project @query.user = User.current @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[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f] @query.group_by ||= params[:group_by] + @query.column_names = params[:c] if params[:c] + @query.column_names = nil if params[:default_columns] if request.post? && params[:confirm] && @query.save flash[:notice] = l(:notice_successful_create) @@ -45,6 +46,8 @@ class QueriesController < ApplicationController @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? + @query.group_by ||= params[:group_by] + @query.column_names = params[:c] if params[:c] @query.column_names = nil if params[:default_columns] if @query.save diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index b6dc697e..61a1846d 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -87,7 +87,7 @@ module QueriesHelper end end @query.group_by = params[:group_by] - @query.column_names = params[:query] && params[:query][:column_names] + @query.column_names = params[:c] || (params[:query] && params[:query][:column_names]) session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names} else @query = Query.find_by_id(session[:query][:id]) if session[:query][:id] diff --git a/app/views/queries/_columns.rhtml b/app/views/queries/_columns.rhtml index 91ee627b..f96d87b0 100644 --- a/app/views/queries/_columns.rhtml +++ b/app/views/queries/_columns.rhtml @@ -10,7 +10,7 @@ - <%= select_tag 'query[column_names][]', + <%= select_tag 'c[]', options_for_select(query.columns.collect {|column| [column.caption, column.name]}), :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index da25ac06..d013b59e 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -248,7 +248,7 @@ class IssuesControllerTest < ActionController::TestCase def test_index_with_columns columns = ['tracker', 'subject', 'assigned_to'] - get :index, :set_filter => 1, :query => { 'column_names' => columns} + get :index, :set_filter => 1, :c => columns assert_response :success # query should use specified columns diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb index 3ef897d6..ea3a7ada 100644 --- a/test/functional/queries_controller_test.rb +++ b/test/functional/queries_controller_test.rb @@ -101,7 +101,8 @@ class QueriesControllerTest < ActionController::TestCase :fields => ["status_id", "assigned_to_id"], :operators => {"assigned_to_id" => "=", "status_id" => "o"}, :values => { "assigned_to_id" => ["me"], "status_id" => ["1"]}, - :query => {"name" => "test_new_global_private_query", "is_public" => "1", "column_names" => ["", "tracker", "subject", "priority", "category"]} + :query => {"name" => "test_new_global_private_query", "is_public" => "1"}, + :c => ["", "tracker", "subject", "priority", "category"] q = Query.find_by_name('test_new_global_private_query') assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q