]> source.dussan.org Git - redmine.git/commitdiff
Add system setting for default results display format of project query (#32818).
authorGo MAEDA <maeda@farend.jp>
Tue, 11 Feb 2020 01:10:48 +0000 (01:10 +0000)
committerGo MAEDA <maeda@farend.jp>
Tue, 11 Feb 2020 01:10:48 +0000 (01:10 +0000)
Patch by Takenori TAKAKI and Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@19505 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project_query.rb
app/models/query.rb
app/views/settings/_projects.html.erb
config/settings.yml
test/unit/project_query_test.rb

index 54c16d8e6bae7a4287dd1789503bd63f0a0be889..703e979d5bc6efd5768b2a31c979c41d0a2f5c45 100644 (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
index 5672a6e9efb59097618f00c3a15bcbd3650cdced..5dec730d3d0ecca619293fd1ae8bced078296351 100644 (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)
index 230e2803ece555f2e748bf4065e0ad49d90fc129..d6c51a7f1f4dce9b140b23a561a3d4343cbe193e 100644 (file)
 <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>
index b5fc64747d268cb031fa716fc7fedc73dec85d2a..b96031bed8e622ec391439da6431a9bac27b9864 100644 (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:
index a680fb699bd5761e6ae1c406e59028025c712fd0..d441c24d61360994fb6c47b45e96e7c490dda100 100644 (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