Feature #32818 » 32818.patch
app/models/project_query.rb | ||
---|---|---|
74 | 74 |
@available_columns |
75 | 75 |
end |
76 | 76 | |
77 |
def display_type |
|
78 |
options[:display_type] || Setting.project_list_display_type || self.available_display_types.first |
|
79 |
end |
|
80 | ||
81 |
def display_type=(type) |
|
82 |
unless type || self.available_display_types.include?(type) |
|
83 |
type = Setting.project_list_display_type || self.available_display_types.first |
|
84 |
end |
|
85 |
options[:display_type] = type |
|
86 |
end |
|
87 | ||
77 | 88 |
def available_display_types |
78 | 89 |
['board', 'list'] |
79 | 90 |
end |
app/views/settings/_projects.html.erb | ||
---|---|---|
19 | 19 |
<fieldset class="box"> |
20 | 20 |
<legend><%= l(:setting_project_list_defaults) %></legend> |
21 | 21 |
<% query = ProjectQuery.new(Setting.project_list_defaults) %> |
22 |
<p> |
|
23 |
<label><%= l(:setting_project_list_display_type) %></label> |
|
24 |
<% query.available_display_types.each do |t| %> |
|
25 |
<%= radio_button_tag('settings[project_list_display_type]', t, Setting.project_list_display_type == t, :id => "setting_project_list_display_type_#{t}") %> |
|
26 |
<%= content_tag('label', l(:"label_display_type_#{t}"), :for => "settings_project_list_display_type_#{t}", :class => "inline") %> |
|
27 |
<% end %> |
|
28 |
</p> |
|
22 | 29 |
<%= render_query_columns_selection(query, |
23 | 30 |
:name => 'settings[project_list_defaults][column_names]') %> |
24 | 31 |
</fieldset> |
config/locales/en.yml | ||
---|---|---|
485 | 485 |
setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user |
486 | 486 |
setting_timelog_accept_future_dates: Accept time logs on future dates |
487 | 487 |
setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject |
488 |
setting_project_list_display_type: Display results as |
|
488 | 489 |
setting_project_list_defaults: Projects list defaults |
489 | 490 | |
490 | 491 |
permission_add_project: Create project |
config/settings.yml | ||
---|---|---|
230 | 230 |
- hours |
231 | 231 |
totalable_names: |
232 | 232 |
- hours |
233 |
project_list_display_type: |
|
234 |
default: board |
|
233 | 235 |
project_list_defaults: |
234 | 236 |
serialized: true |
235 | 237 |
default: |
test/unit/project_query_test.rb | ||
---|---|---|
60 | 60 |
query = ProjectQuery.new |
61 | 61 |
assert_include :cf_3, query.available_columns.map(&:name) |
62 | 62 |
end |
63 | ||
64 |
def test_display_type_default_should_equal_with_setting_project_list_display_type |
|
65 |
ProjectQuery.new.available_display_types.each do |t| |
|
66 |
with_settings :project_list_display_type => t do |
|
67 |
q = ProjectQuery.new |
|
68 |
assert_equal t, q.display_type |
|
69 |
end |
|
70 |
end |
|
71 |
end |
|
63 | 72 |
end |