Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Commit

Permalink
Shorten query[column_names] param name.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5304 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang authored and edavis10 committed Apr 16, 2011
1 parent e78149f commit 42653ce
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/controllers/queries_controller.rb
Expand Up @@ -25,10 +25,11 @@ def new
@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)
Expand All @@ -45,6 +46,8 @@ def edit
@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
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/queries_helper.rb
Expand Up @@ -87,7 +87,7 @@ def retrieve_query
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]
Expand Down
2 changes: 1 addition & 1 deletion app/views/queries/_columns.rhtml
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion test/functional/issues_controller_test.rb
Expand Up @@ -248,7 +248,7 @@ def test_index_sort

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
Expand Down
3 changes: 2 additions & 1 deletion test/functional/queries_controller_test.rb
Expand Up @@ -101,7 +101,8 @@ def test_new_global_private_query_with_custom_columns
: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
Expand Down

0 comments on commit 42653ce

Please sign in to comment.