Feature #3058 » 0007-user-preference-for-issue-history-default-tab.patch
| app/helpers/issues_helper.rb | ||
|---|---|---|
| 559 | 559 | tabs | 
| 560 | 560 | end | 
| 561 | 561 | |
| 562 | def issue_history_default_tab | |
| 563 | # tab params overrides user default tab preference | |
| 564 | return params[:tab] if params[:tab].present? | |
| 565 | user_default_tab = User.current.pref.history_default_tab | |
| 566 | ||
| 567 | case user_default_tab | |
| 568 | when 'last_tab_visited' | |
| 569 | cookies['history_last_tab'].present? ? cookies['history_last_tab'] : 'notes' | |
| 570 | when '' | |
| 571 | 'notes' | |
| 572 | else | |
| 573 | user_default_tab | |
| 574 | end | |
| 575 | end | |
| 576 | ||
| 562 | 577 | end | 
| app/helpers/users_helper.rb | ||
|---|---|---|
| 33 | 33 |     [[l(:label_font_default), '']] + UserPreference::TEXTAREA_FONT_OPTIONS.map {|o| [l("label_font_#{o}"), o]} | 
| 34 | 34 | end | 
| 35 | 35 | |
| 36 | def history_default_tab_options | |
| 37 |     [[l('label_issue_history_notes'), 'notes'], | |
| 38 |      [l('label_history'), 'history'], | |
| 39 |      [l('label_issue_history_properties'), 'properties'], | |
| 40 |      [l('label_time_entry_plural'), 'time_entries'], | |
| 41 |      [l('label_associated_revisions'), 'changesets'], | |
| 42 |      [l('label_last_tab_visited'), 'last_tab_visited']] | |
| 43 | end | |
| 44 | ||
| 36 | 45 | def change_status_link(user) | 
| 37 | 46 |     url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil} | 
| 38 | 47 | |
| app/models/user_preference.rb | ||
|---|---|---|
| 30 | 30 | 'comments_sorting', | 
| 31 | 31 | 'warn_on_leaving_unsaved', | 
| 32 | 32 | 'no_self_notified', | 
| 33 | 'textarea_font' | |
| 33 | 'textarea_font', | |
| 34 | 'history_default_tab' | |
| 34 | 35 | |
| 35 | 36 | TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional'] | 
| 36 | 37 | |
| ... | ... | |
| 88 | 89 | def textarea_font; self[:textarea_font] end | 
| 89 | 90 | def textarea_font=(value); self[:textarea_font]=value; end | 
| 90 | 91 | |
| 92 | def history_default_tab; self[:history_default_tab]; end | |
| 93 | def history_default_tab=(value); self[:history_default_tab]=value; end | |
| 94 | ||
| 91 | 95 | # Returns the names of groups that are displayed on user's page | 
| 92 | 96 | # Example: | 
| 93 | 97 | # preferences.my_page_groups | 
| app/views/issues/show.html.erb | ||
|---|---|---|
| 124 | 124 | |
| 125 | 125 | <div id="history"> | 
| 126 | 126 | <h3><%=l(:label_history)%></h3> | 
| 127 | <%= render_tabs issue_history_tabs, params[:tab] ? params[:tab] : 'notes' %> | |
| 127 | <%= render_tabs issue_history_tabs, issue_history_default_tab %> | |
| 128 | 128 | </div> | 
| 129 | 129 | |
| 130 | 130 | <%= render partial: 'action_menu_edit' unless User.current.wants_comments_in_reverse_order? %> | 
| app/views/users/_preferences.html.erb | ||
|---|---|---|
| 4 | 4 | <p><%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %></p> | 
| 5 | 5 | <p><%= pref_fields.check_box :warn_on_leaving_unsaved %></p> | 
| 6 | 6 | <p><%= pref_fields.select :textarea_font, textarea_font_options %></p> | 
| 7 | <p><%= pref_fields.select :history_default_tab, history_default_tab_options %></p> | |
| 7 | 8 | <% end %> | 
| config/locales/en.yml | ||
|---|---|---|
| 380 | 380 | field_full_width_layout: Full width layout | 
| 381 | 381 | field_digest: Checksum | 
| 382 | 382 | field_default_assigned_to: Default assignee | 
| 383 | field_history_default_tab: Issue's history default tab | |
| 383 | 384 | |
| 384 | 385 | setting_app_title: Application title | 
| 385 | 386 | setting_welcome_text: Welcome text | 
| ... | ... | |
| 1037 | 1038 | label_nothing_to_preview: Nothing to preview | 
| 1038 | 1039 | label_issue_history_properties: Property changes | 
| 1039 | 1040 | label_issue_history_notes: Notes | 
| 1041 | label_last_tab_visited: Last visited tab | |
| 1040 | 1042 | |
| 1041 | 1043 | button_login: Login | 
| 1042 | 1044 | button_submit: Submit | 
| public/javascripts/application.js | ||
|---|---|---|
| 918 | 918 | $(document).ready(function(){ | 
| 919 | 919 |   $('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange); | 
| 920 | 920 | toggleDisabledInit(); | 
| 921 | ||
| 922 |   $('#history .tabs').on('click', 'a', function(e){ | |
| 923 |     var tab = $(e.target).attr('id').replace('tab-',''); | |
| 924 | document.cookie = 'history_last_tab=' + tab | |
| 925 | }); | |
| 921 | 926 | }); | 
| 922 | 927 | |
| 923 | 928 | $(document).ready(function(){ | 
| test/functional/users_controller_test.rb | ||
|---|---|---|
| 244 | 244 | 'time_zone' => 'Paris', | 
| 245 | 245 | 'comments_sorting' => 'desc', | 
| 246 | 246 | 'warn_on_leaving_unsaved' => '0', | 
| 247 | 'textarea_font' => 'proportional' | |
| 247 | 'textarea_font' => 'proportional', | |
| 248 | 'history_default_tab' => 'history' | |
| 248 | 249 | } | 
| 249 | 250 | } | 
| 250 | 251 | end | 
| ... | ... | |
| 255 | 256 | assert_equal 'desc', user.pref[:comments_sorting] | 
| 256 | 257 | assert_equal '0', user.pref[:warn_on_leaving_unsaved] | 
| 257 | 258 | assert_equal 'proportional', user.pref[:textarea_font] | 
| 259 | assert_equal 'history', user.pref[:history_default_tab] | |
| 258 | 260 | end | 
| 259 | 261 | |
| 260 | 262 | def test_create_with_generate_password_should_email_the_password | 
| test/helpers/issues_helper_test.rb | ||
|---|---|---|
| 329 | 329 | def test_find_name_by_reflection_should_return_nil_for_missing_record | 
| 330 | 330 |     assert_nil find_name_by_reflection('status', 99) | 
| 331 | 331 | end | 
| 332 | ||
| 332 | 333 | end |