summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2019-10-19 11:43:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2019-10-19 11:43:23 +0000
commit95188f26c3f47f110c6d928e5df0b108802032b3 (patch)
tree87c6eb46833289a4d8cfbe921060b34c75393949
parent45f039187df03e8925cb0d08ccc1838c9ea2d5c2 (diff)
downloadredmine-95188f26c3f47f110c6d928e5df0b108802032b3.tar.gz
redmine-95188f26c3f47f110c6d928e5df0b108802032b3.zip
Set default columns for the projects list (#29482).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@18766 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/projects_controller.rb2
-rw-r--r--app/models/project_query.rb2
-rw-r--r--app/views/settings/_projects.html.erb8
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/settings.yml7
-rw-r--r--test/functional/projects_controller_test.rb10
6 files changed, 28 insertions, 2 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index b9bda6b43..2e4fc5303 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -274,6 +274,6 @@ class ProjectsController < ApplicationController
end
def retrieve_project_query
- retrieve_query(ProjectQuery, false)
+ retrieve_query(ProjectQuery, false, :defaults => @default_columns_names)
end
end
diff --git a/app/models/project_query.rb b/app/models/project_query.rb
index ecf3e687b..c0e0e92e7 100644
--- a/app/models/project_query.rb
+++ b/app/models/project_query.rb
@@ -69,7 +69,7 @@ class ProjectQuery < Query
end
def default_columns_names
- @default_columns_names ||= [:name, :identifier, :short_description]
+ @default_columns_names = Setting.project_list_defaults.symbolize_keys[:column_names].map(&:to_sym)
end
def default_sort_criteria
diff --git a/app/views/settings/_projects.html.erb b/app/views/settings/_projects.html.erb
index fd9ea1b76..230e2803e 100644
--- a/app/views/settings/_projects.html.erb
+++ b/app/views/settings/_projects.html.erb
@@ -16,5 +16,13 @@
:blank => "--- #{l(:actionview_instancetag_blank_option)} ---" %></p>
</div>
+<fieldset class="box">
+ <legend><%= l(:setting_project_list_defaults) %></legend>
+ <% query = ProjectQuery.new(Setting.project_list_defaults) %>
+ <%= render_query_columns_selection(query,
+ :name => 'settings[project_list_defaults][column_names]') %>
+</fieldset>
+
+
<%= submit_tag l(:button_save) %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index e5ae3220f..8c39859d7 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -484,6 +484,7 @@ en:
setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user
setting_timelog_accept_future_dates: Accept time logs on future dates
setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject
+ setting_project_list_defaults: Projects list defaults
permission_add_project: Create project
permission_add_subprojects: Create subprojects
diff --git a/config/settings.yml b/config/settings.yml
index d345a4cfa..05081c0fa 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -230,6 +230,13 @@ time_entry_list_defaults:
- hours
totalable_names:
- hours
+project_list_defaults:
+ serialized: true
+ default:
+ column_names:
+ - name
+ - identifier
+ - short_description
issue_done_ratio:
default: 'issue_field'
default_projects_public:
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index 5e1efd240..0997ef83c 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -147,6 +147,16 @@ class ProjectsControllerTest < Redmine::ControllerTest
assert_include 'idnt-2', child_level2
end
+ def test_index_with_default_query_setting
+ with_settings :project_list_defaults => {'column_names' => %w(name short_description status)} do
+ get :index, :params => {
+ :display_type => 'list'
+ }
+ assert_response :success
+ end
+ assert_equal ['Name', 'Description', 'Status'], columns_in_list
+ end
+
def test_autocomplete_js
get :autocomplete, :params => {
:format => 'js',