Defect #8411 » query_default_columns.patch
| app/models/query.rb (working copy) | ||
|---|---|---|
| 369 | 369 |
end |
| 370 | 370 | |
| 371 | 371 |
def columns |
| 372 |
if has_default_columns? |
|
| 373 |
available_columns.select do |c| |
|
| 374 |
# Adds the project column by default for cross-project lists |
|
| 375 |
Setting.issue_list_default_columns.include?(c.name.to_s) || (c.name == :project && project.nil?) |
|
| 376 |
end |
|
| 377 |
else |
|
| 378 |
# preserve the column_names order |
|
| 379 |
column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact
|
|
| 380 |
end |
|
| 372 |
# preserve the column_names order |
|
| 373 |
(has_default_columns? ? default_columns_names : column_names).collect do |name| |
|
| 374 |
available_columns.find { |col| col.name == name }
|
|
| 375 |
end.compact |
|
| 381 | 376 |
end |
| 382 | 377 | |
| 378 |
def default_columns_names |
|
| 379 |
@default_columns_names ||= Setting.issue_list_default_columns.map(&:to_sym) |
|
| 380 |
|
|
| 381 |
project.present? || @default_columns_names.include?(:project) ? @default_columns_names : [:project] + @default_columns_names |
|
| 382 |
end |
|
| 383 |
|
|
| 383 | 384 |
def column_names=(names) |
| 384 | 385 |
if names |
| 385 | 386 |
names = names.select {|n| n.is_a?(Symbol) || !n.blank? }
|
| 386 | 387 |
names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym }
|
| 387 | 388 |
# Set column_names to nil if default columns |
| 388 |
if names.map(&:to_s) == Setting.issue_list_default_columns
|
|
| 389 |
if names == default_columns_names
|
|
| 389 | 390 |
names = nil |
| 390 | 391 |
end |
| 391 | 392 |
end |
- « Previous
- 1
- 2
- Next »