@@ -25,10 +25,11 class QueriesController < ApplicationController | |||||
25 | @query.project = params[:query_is_for_all] ? nil : @project |
|
25 | @query.project = params[:query_is_for_all] ? nil : @project | |
26 | @query.user = User.current |
|
26 | @query.user = User.current | |
27 | @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin? |
|
27 | @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin? | |
28 | @query.column_names = nil if params[:default_columns] |
|
|||
29 |
|
28 | |||
30 | @query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f] |
|
29 | @query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) if params[:fields] || params[:f] | |
31 | @query.group_by ||= params[:group_by] |
|
30 | @query.group_by ||= params[:group_by] | |
|
31 | @query.column_names = params[:c] if params[:c] | |||
|
32 | @query.column_names = nil if params[:default_columns] | |||
32 |
|
33 | |||
33 | if request.post? && params[:confirm] && @query.save |
|
34 | if request.post? && params[:confirm] && @query.save | |
34 | flash[:notice] = l(:notice_successful_create) |
|
35 | flash[:notice] = l(:notice_successful_create) | |
@@ -45,6 +46,8 class QueriesController < ApplicationController | |||||
45 | @query.attributes = params[:query] |
|
46 | @query.attributes = params[:query] | |
46 | @query.project = nil if params[:query_is_for_all] |
|
47 | @query.project = nil if params[:query_is_for_all] | |
47 | @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin? |
|
48 | @query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin? | |
|
49 | @query.group_by ||= params[:group_by] | |||
|
50 | @query.column_names = params[:c] if params[:c] | |||
48 | @query.column_names = nil if params[:default_columns] |
|
51 | @query.column_names = nil if params[:default_columns] | |
49 |
|
52 | |||
50 | if @query.save |
|
53 | if @query.save |
@@ -87,7 +87,7 module QueriesHelper | |||||
87 | end |
|
87 | end | |
88 | end |
|
88 | end | |
89 | @query.group_by = params[:group_by] |
|
89 | @query.group_by = params[:group_by] | |
90 | @query.column_names = params[:query] && params[:query][:column_names] |
|
90 | @query.column_names = params[:c] || (params[:query] && params[:query][:column_names]) | |
91 | session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names} |
|
91 | session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names} | |
92 | else |
|
92 | else | |
93 | @query = Query.find_by_id(session[:query][:id]) if session[:query][:id] |
|
93 | @query = Query.find_by_id(session[:query][:id]) if session[:query][:id] |
@@ -10,7 +10,7 | |||||
10 | <input type="button" value="←" |
|
10 | <input type="button" value="←" | |
11 | onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" /> |
|
11 | onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" /> | |
12 | </td> |
|
12 | </td> | |
13 |
<td><%= select_tag ' |
|
13 | <td><%= select_tag 'c[]', | |
14 | options_for_select(query.columns.collect {|column| [column.caption, column.name]}), |
|
14 | options_for_select(query.columns.collect {|column| [column.caption, column.name]}), | |
15 | :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> |
|
15 | :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> | |
16 | </td> |
|
16 | </td> |
@@ -248,7 +248,7 class IssuesControllerTest < ActionController::TestCase | |||||
248 |
|
248 | |||
249 | def test_index_with_columns |
|
249 | def test_index_with_columns | |
250 | columns = ['tracker', 'subject', 'assigned_to'] |
|
250 | columns = ['tracker', 'subject', 'assigned_to'] | |
251 |
get :index, :set_filter => 1, : |
|
251 | get :index, :set_filter => 1, :c => columns | |
252 | assert_response :success |
|
252 | assert_response :success | |
253 |
|
253 | |||
254 | # query should use specified columns |
|
254 | # query should use specified columns |
@@ -101,7 +101,8 class QueriesControllerTest < ActionController::TestCase | |||||
101 | :fields => ["status_id", "assigned_to_id"], |
|
101 | :fields => ["status_id", "assigned_to_id"], | |
102 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, |
|
102 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, | |
103 | :values => { "assigned_to_id" => ["me"], "status_id" => ["1"]}, |
|
103 | :values => { "assigned_to_id" => ["me"], "status_id" => ["1"]}, | |
104 |
:query => {"name" => "test_new_global_private_query", "is_public" => "1", |
|
104 | :query => {"name" => "test_new_global_private_query", "is_public" => "1"}, | |
|
105 | :c => ["", "tracker", "subject", "priority", "category"] | |||
105 |
|
106 | |||
106 | q = Query.find_by_name('test_new_global_private_query') |
|
107 | q = Query.find_by_name('test_new_global_private_query') | |
107 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q |
|
108 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q |
General Comments 0
You need to be logged in to leave comments.
Login now