##// END OF EJS Templates
Allow project column to be removed from the global issue list columns (#8411)....
Etienne Massip -
r7418:98e18b2141d3
parent child
Show More
@@ -378,14 +378,17 class Query < ActiveRecord::Base
378 end
378 end
379
379
380 def columns
380 def columns
381 if has_default_columns?
381 # preserve the column_names order
382 available_columns.select do |c|
382 (has_default_columns? ? default_columns_names : column_names).collect do |name|
383 # Adds the project column by default for cross-project lists
383 available_columns.find { |col| col.name == name }
384 Setting.issue_list_default_columns.include?(c.name.to_s) || (c.name == :project && project.nil?)
384 end.compact
385 end
385 end
386 else
386
387 # preserve the column_names order
387 def default_columns_names
388 column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact
388 @default_columns_names ||= begin
389 default_columns = Setting.issue_list_default_columns.map(&:to_sym)
390
391 project.present? ? default_columns : [:project] | default_columns
389 end
392 end
390 end
393 end
391
394
@@ -394,7 +397,7 class Query < ActiveRecord::Base
394 names = names.select {|n| n.is_a?(Symbol) || !n.blank? }
397 names = names.select {|n| n.is_a?(Symbol) || !n.blank? }
395 names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym }
398 names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym }
396 # Set column_names to nil if default columns
399 # Set column_names to nil if default columns
397 if names.map(&:to_s) == Setting.issue_list_default_columns
400 if names == default_columns_names
398 names = nil
401 names = nil
399 end
402 end
400 end
403 end
@@ -285,6 +285,27 class IssuesControllerTest < ActionController::TestCase
285 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } }
285 :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } }
286 end
286 end
287
287
288 def test_index_without_project_should_implicitly_add_project_column_to_default_columns
289 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
290 get :index, :set_filter => 1
291
292 # query should use specified columns
293 query = assigns(:query)
294 assert_kind_of Query, query
295 assert_equal [:project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
296 end
297
298 def test_index_without_project_and_explicit_default_columns_should_not_add_project_column
299 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
300 columns = ['tracker', 'subject', 'assigned_to']
301 get :index, :set_filter => 1, :c => columns
302
303 # query should use specified columns
304 query = assigns(:query)
305 assert_kind_of Query, query
306 assert_equal columns.map(&:to_sym), query.columns.map(&:name)
307 end
308
288 def test_index_with_custom_field_column
309 def test_index_with_custom_field_column
289 columns = %w(tracker subject cf_2)
310 columns = %w(tracker subject cf_2)
290 get :index, :set_filter => 1, :c => columns
311 get :index, :set_filter => 1, :c => columns
General Comments 0
You need to be logged in to leave comments. Login now