Shorten query[column_names] param name.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5304 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-04-03 14:31:32 +00:00 committed by Eric Davis
parent e78149f85c
commit 42653cef32
5 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -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]

View File

@ -10,7 +10,7 @@
<input type="button" value="&#8592;"
onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" />
</td>
<td><%= select_tag 'query[column_names][]',
<td><%= select_tag 'c[]',
options_for_select(query.columns.collect {|column| [column.caption, column.name]}),
:id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %>
</td>

View File

@ -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

View File

@ -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