summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-02-11 01:10:48 +0000
committerGo MAEDA <maeda@farend.jp>2020-02-11 01:10:48 +0000
commitb6d26dc1700c485183351af52e275da4b1a759f8 (patch)
treeac6ab0b13275c13871f82629837e63837df96e88
parent8586bc4bf38e45b9254eca3b31c88c030aa60e64 (diff)
downloadredmine-b6d26dc1700c485183351af52e275da4b1a759f8.tar.gz
redmine-b6d26dc1700c485183351af52e275da4b1a759f8.zip
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
-rw-r--r--app/models/project_query.rb4
-rw-r--r--app/models/query.rb6
-rw-r--r--app/views/settings/_projects.html.erb7
-rw-r--r--config/settings.yml2
-rw-r--r--test/unit/project_query_test.rb9
5 files changed, 27 insertions, 1 deletions
diff --git a/app/models/project_query.rb b/app/models/project_query.rb
index 54c16d8e6..703e979d5 100644
--- a/app/models/project_query.rb
+++ b/app/models/project_query.rb
@@ -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
diff --git a/app/models/query.rb b/app/models/query.rb
index 5672a6e9e..5dec730d3 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -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)
diff --git a/app/views/settings/_projects.html.erb b/app/views/settings/_projects.html.erb
index 230e2803e..d6c51a7f1 100644
--- a/app/views/settings/_projects.html.erb
+++ b/app/views/settings/_projects.html.erb
@@ -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>
diff --git a/config/settings.yml b/config/settings.yml
index b5fc64747..b96031bed 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -230,6 +230,8 @@ time_entry_list_defaults:
- hours
totalable_names:
- hours
+project_list_display_type:
+ default: board
project_list_defaults:
serialized: true
default:
diff --git a/test/unit/project_query_test.rb b/test/unit/project_query_test.rb
index a680fb699..d441c24d6 100644
--- a/test/unit/project_query_test.rb
+++ b/test/unit/project_query_test.rb
@@ -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