Defect #8411 » default_columns.patch
app/models/query.rb (working copy) | ||
---|---|---|
329 | 329 | |
330 | 330 |
def columns |
331 | 331 |
if has_default_columns? |
332 |
available_columns.select do |c| |
|
333 |
# Adds the project column by default for cross-project lists |
|
334 |
Setting.issue_list_default_columns.include?(c.name.to_s) || (c.name == :project && project.nil?) |
|
335 |
end |
|
332 |
default_columns |
|
336 | 333 |
else |
337 | 334 |
# preserve the column_names order |
338 | 335 |
column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact |
339 | 336 |
end |
340 | 337 |
end |
341 | 338 | |
339 |
def default_columns |
|
340 |
return @default_columns if @default_columns |
|
341 |
|
|
342 |
project_column = available_columns.find { |col| col.name == :project } unless project |
|
343 |
project_column_index = available_columns.index(project_column) unless project |
|
344 |
project_column_included = false |
|
345 |
|
|
346 |
default_columns = [] |
|
347 |
Setting.issue_list_default_columns.each do |column_name| |
|
348 |
|
|
349 |
column = available_columns.find {|col| col.name == column_name.to_sym} |
|
350 |
next unless column |
|
351 |
|
|
352 |
# Adds the project column by default for cross-project lists |
|
353 |
if project.nil? && !project_column_included && available_columns.index(column) > project_column_index |
|
354 |
default_columns << project_column |
|
355 |
project_column_included = true |
|
356 |
end |
|
357 |
default_columns << column |
|
358 |
end |
|
359 |
@default_columns = default_columns |
|
360 |
end |
|
361 |
|
|
342 | 362 |
def column_names=(names) |
343 | 363 |
if names |
344 | 364 |
names = names.select {|n| n.is_a?(Symbol) || !n.blank? } |
345 | 365 |
names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym } |
346 | 366 |
# Set column_names to nil if default columns |
347 |
if names.map(&:to_s) == Setting.issue_list_default_columns
|
|
367 |
if names == default_columns.map(&:name)
|
|
348 | 368 |
names = nil |
349 | 369 |
end |
350 | 370 |
end |