Defect #26537 » 0001-show-project-column-by-default-in-global-time-entry-.patch
app/controllers/timelog_controller.rb | ||
---|---|---|
272 | 272 |
end |
273 | 273 | |
274 | 274 |
def retrieve_time_entry_query |
275 |
retrieve_query(TimeEntryQuery, false, :defaults => Setting.time_entry_list_defaults.symbolize_keys)
|
|
275 |
retrieve_query(TimeEntryQuery, false, :defaults => @default_columns_names)
|
|
276 | 276 |
end |
277 | 277 |
end |
app/models/time_entry_query.rb | ||
---|---|---|
103 | 103 | |
104 | 104 |
def default_columns_names |
105 | 105 |
@default_columns_names ||= begin |
106 |
default_columns = [:spent_on, :user, :activity, :issue, :comments, :hours] |
|
107 | ||
106 |
default_columns = Setting.time_entry_list_defaults.symbolize_keys[:column_names].map(&:to_sym) |
|
108 | 107 |
project.present? ? default_columns : [:project] | default_columns |
109 | 108 |
end |
110 | 109 |
end |
111 | 110 | |
112 | 111 |
def default_totalable_names |
113 |
[:hours]
|
|
112 |
Setting.time_entry_list_defaults.symbolize_keys[:totalable_names].map(&:to_sym)
|
|
114 | 113 |
end |
115 | 114 | |
116 | 115 |
def default_sort_criteria |
app/views/settings/_timelog.html.erb | ||
---|---|---|
13 | 13 |
<legend><%= l(:setting_time_entry_list_defaults) %></legend> |
14 | 14 | |
15 | 15 |
<% query = TimeEntryQuery.new(Setting.time_entry_list_defaults) %> |
16 |
<%= hidden_field_tag('settings[time_entry_list_defaults][column_names][]', '') %> |
|
16 | 17 |
<%= render_query_columns_selection(query, |
17 | 18 |
:name => 'settings[time_entry_list_defaults][column_names]') %> |
18 | ||
19 | 19 |
<p> |
20 | 20 |
<label><%= l(:label_total_plural) %></label> |
21 | 21 |
<%= available_totalable_columns_tags(query, |
config/settings.yml | ||
---|---|---|
219 | 219 |
- issue |
220 | 220 |
- comments |
221 | 221 |
- hours |
222 |
totalable_names: |
|
223 |
- hours |
|
222 | 224 |
issue_done_ratio: |
223 | 225 |
default: 'issue_field' |
224 | 226 |
default_projects_public: |
test/functional/timelog_controller_test.rb | ||
---|---|---|
24 | 24 |
:trackers, :enumerations, :issue_statuses, |
25 | 25 |
:custom_fields, :custom_values, |
26 | 26 |
:projects_trackers, :custom_fields_trackers, |
27 |
:custom_fields_projects |
|
27 |
:custom_fields_projects, :issue_categories
|
|
28 | 28 | |
29 | 29 |
include Redmine::I18n |
30 | 30 | |
... | ... | |
711 | 711 |
assert_select '.total-for-hours', :text => 'Hours: 162.90' |
712 | 712 |
assert_select 'form#query_form[action=?]', '/time_entries' |
713 | 713 | |
714 |
assert_equal ['Date', 'User', 'Activity', 'Issue', 'Comment', 'Hours'], columns_in_list |
|
714 |
assert_equal ['Project', 'Date', 'User', 'Activity', 'Issue', 'Comment', 'Hours'], columns_in_list
|
|
715 | 715 |
assert_select '.query-totals>span', 1 |
716 | 716 |
end |
717 | 717 | |
718 | 718 |
def test_index_with_default_query_setting |
719 |
with_settings :time_entry_list_defaults => {'column_names' => %w(spent_on issue user hours)} do |
|
719 |
with_settings :time_entry_list_defaults => {'column_names' => %w(spent_on issue user hours), 'totalable_names' => []} do
|
|
720 | 720 |
get :index |
721 | 721 |
assert_response :success |
722 | 722 |
end |
723 | 723 | |
724 | 724 |
assert_select 'table.time-entries thead' do |
725 |
assert_select 'th.project' |
|
725 | 726 |
assert_select 'th.spent_on' |
726 | 727 |
assert_select 'th.issue' |
727 | 728 |
assert_select 'th.user' |
728 | 729 |
assert_select 'th.hours' |
729 | 730 |
end |
730 | 731 |
assert_select 'table.time-entries tbody' do |
732 |
assert_select 'td.project' |
|
731 | 733 |
assert_select 'td.spent_on' |
732 | 734 |
assert_select 'td.issue' |
733 | 735 |
assert_select 'td.user' |
734 | 736 |
assert_select 'td.hours' |
735 | 737 |
end |
736 |
assert_equal ['Date', 'Issue', 'User', 'Hours'], columns_in_list |
|
738 |
assert_equal ['Project', 'Date', 'Issue', 'User', 'Hours'], columns_in_list
|
|
737 | 739 |
end |
738 | 740 | |
739 | 741 |
def test_index_with_default_query_setting_using_custom_field |
... | ... | |
747 | 749 |
assert_response :success |
748 | 750 |
end |
749 | 751 | |
750 |
assert_equal ['Date', 'User', 'Hours', 'Foo'], columns_in_list |
|
752 |
assert_equal ['Project', 'Date', 'User', 'Hours', 'Foo'], columns_in_list
|
|
751 | 753 | |
752 | 754 |
assert_select '.total-for-hours' |
753 | 755 |
assert_select ".total-for-cf-#{field.id}" |