Add system setting for default results display format of project query (#32818).

Patch by Takenori TAKAKI and Marius BALTEANU.


git-svn-id: http://svn.redmine.org/redmine/trunk@19505 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2020-02-11 01:10:48 +00:00
parent 8586bc4bf3
commit b6d26dc170
5 changed files with 27 additions and 1 deletions

View File

@@ -82,6 +82,10 @@ class ProjectQuery < Query
@default_columns_names = Setting.project_list_defaults.symbolize_keys[:column_names].map(&:to_sym)
end
def default_display_type
Setting.project_list_display_type
end
def default_sort_criteria
[[]]
end

View File

@@ -766,6 +766,10 @@ class Query < ActiveRecord::Base
[]
end
def default_display_type
self.available_display_types.first
end
def column_names=(names)
if names
names = names.select {|n| n.is_a?(Symbol) || !n.blank? }
@@ -997,7 +1001,7 @@ class Query < ActiveRecord::Base
end
def display_type
options[:display_type] || self.available_display_types.first
options[:display_type] || self.default_display_type
end
def display_type=(type)

View File

@@ -19,6 +19,13 @@
<fieldset class="box">
<legend><%= l(:setting_project_list_defaults) %></legend>
<% query = ProjectQuery.new(Setting.project_list_defaults) %>
<p>
<label><%= l(:label_display_type) %></label>
<% query.available_display_types.each do |t| %>
<%= radio_button_tag('settings[project_list_display_type]', t, Setting.project_list_display_type == t, :id => "setting_project_list_display_type_#{t}") %>
<%= content_tag('label', l(:"label_display_type_#{t}"), :for => "settings_project_list_display_type_#{t}", :class => "inline") %>
<% end %>
</p>
<%= render_query_columns_selection(query,
:name => 'settings[project_list_defaults][column_names]') %>
</fieldset>

View File

@@ -230,6 +230,8 @@ time_entry_list_defaults:
- hours
totalable_names:
- hours
project_list_display_type:
default: board
project_list_defaults:
serialized: true
default:

View File

@@ -60,4 +60,13 @@ class ProjectQueryTest < ActiveSupport::TestCase
query = ProjectQuery.new
assert_include :cf_3, query.available_columns.map(&:name)
end
def test_display_type_default_should_equal_with_setting_project_list_display_type
ProjectQuery.new.available_display_types.each do |t|
with_settings :project_list_display_type => t do
q = ProjectQuery.new
assert_equal t, q.display_type
end
end
end
end