]> source.dussan.org Git - redmine.git/commitdiff
User preference for issue history default tab (#3058).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 20 Jun 2019 07:13:54 +0000 (07:13 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 20 Jun 2019 07:13:54 +0000 (07:13 +0000)
Patch by Marius BALTEANU.

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

app/helpers/issues_helper.rb
app/helpers/users_helper.rb
app/models/user_preference.rb
app/views/issues/show.html.erb
app/views/users/_preferences.html.erb
config/locales/en.yml
public/javascripts/application.js
test/functional/users_controller_test.rb

index 3001113303162c1d42ccca47f8098b49a6ac75c6..8d16e7a4069223bdb36da4166ad7d8826e29fc18 100644 (file)
@@ -562,4 +562,19 @@ module IssuesHelper
     tabs
   end
 
+  def issue_history_default_tab
+    # tab params overrides user default tab preference
+    return params[:tab] if params[:tab].present?
+    user_default_tab = User.current.pref.history_default_tab
+
+    case user_default_tab
+    when 'last_tab_visited'
+      cookies['history_last_tab'].present? ? cookies['history_last_tab'] : 'notes'
+    when ''
+      'notes'
+    else
+      user_default_tab
+    end
+  end
+
 end
index 6b908edca51ac4a88b7772e12b2a5f9472909894..dece86165ccc45a06f5e1b175c9f993ef379e3e5 100644 (file)
@@ -33,6 +33,15 @@ module UsersHelper
     [[l(:label_font_default), '']] + UserPreference::TEXTAREA_FONT_OPTIONS.map {|o| [l("label_font_#{o}"), o]}
   end
 
+  def history_default_tab_options
+    [[l('label_issue_history_notes'), 'notes'],
+     [l('label_history'), 'history'],
+     [l('label_issue_history_properties'), 'properties'],
+     [l('label_time_entry_plural'), 'time_entries'],
+     [l('label_associated_revisions'), 'changesets'],
+     [l('label_last_tab_visited'), 'last_tab_visited']]
+  end
+
   def change_status_link(user)
     url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
 
index 14444ae6de4b72d1b26c92c4fc6799584a92be2c..cd94486a3b609e5c6b8985c93c266884b14f1241 100644 (file)
@@ -33,7 +33,8 @@ class UserPreference < ActiveRecord::Base
     'warn_on_leaving_unsaved',
     'no_self_notified',
     'textarea_font',
-    'recently_used_projects'
+    'recently_used_projects',
+    'history_default_tab'
 
   TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional']
 
@@ -93,6 +94,8 @@ class UserPreference < ActiveRecord::Base
 
   def recently_used_projects; (self[:recently_used_projects] || 3).to_i; end
   def recently_used_projects=(value); self[:recently_used_projects] = value.to_i; end
+  def history_default_tab; self[:history_default_tab]; end
+  def history_default_tab=(value); self[:history_default_tab]=value; end
 
   # Returns the names of groups that are displayed on user's page
   # Example:
index d50f5e2267ce68a92916a485da1bce3315e4ed7b..c4777ff83c8b52cd39769ddee76861aea52c21d6 100644 (file)
@@ -124,7 +124,7 @@ end %>
 
 <div id="history">
 <h3><%=l(:label_history)%></h3>
-<%= render_tabs issue_history_tabs, params[:tab] ? params[:tab] : 'notes' %>
+<%= render_tabs issue_history_tabs, issue_history_default_tab %>
 </div>
 
 <%= render partial: 'action_menu_edit' unless User.current.wants_comments_in_reverse_order? %>
index 6c4e5337aad5e18c8f7a3e36caa0701d06b41d82..6397c3a38e57c977e41c57227c8efac033d2beea 100644 (file)
@@ -5,4 +5,5 @@
 <p><%= pref_fields.check_box :warn_on_leaving_unsaved %></p>
 <p><%= pref_fields.select :textarea_font, textarea_font_options %></p>
 <p><%= pref_fields.text_field :recently_used_projects, :size => 2 %></p>
+<p><%= pref_fields.select :history_default_tab, history_default_tab_options %></p>
 <% end %>
index 7d54ff4991d8d9e9c48688b95b3edf5545a23d4a..0b64e979e57762b86b5bd4152111edde5910c78c 100644 (file)
@@ -383,6 +383,7 @@ en:
   field_digest: Checksum
   field_default_assigned_to: Default assignee
   field_recently_used_projects: Number of recently used projects in jump box
+  field_history_default_tab: Issue's history default tab
 
   setting_app_title: Application title
   setting_welcome_text: Welcome text
@@ -1058,6 +1059,7 @@ en:
   label_preferred_body_part_html: HTML (experimental)
   label_issue_history_properties: Property changes
   label_issue_history_notes: Notes
+  label_last_tab_visited: Last visited tab
 
   button_login: Login
   button_submit: Submit
index c1ecd86c7cf54884d24a29ac3879d346a7a811ee..42da02765ea4f429bc9a24dc62a9d2d49ee6141f 100644 (file)
@@ -929,6 +929,11 @@ function toggleNewObjectDropdown() {
 $(document).ready(function(){
   $('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
   toggleDisabledInit();
+
+  $('#history .tabs').on('click', 'a', function(e){
+    var tab = $(e.target).attr('id').replace('tab-','');
+    document.cookie = 'history_last_tab=' + tab
+  });
 });
 
 $(document).ready(function(){
index dd5454909ecae0ec29dac27c3e57279fd22cd555..846a85cd5b5a61f8d0e1dc60ce971fa60bf4af6d 100644 (file)
@@ -292,7 +292,8 @@ class UsersControllerTest < Redmine::ControllerTest
           'time_zone' => 'Paris',
           'comments_sorting' => 'desc',
           'warn_on_leaving_unsaved' => '0',
-          'textarea_font' => 'proportional'
+          'textarea_font' => 'proportional',
+          'history_default_tab' => 'history'
         }
       }
     end
@@ -303,6 +304,7 @@ class UsersControllerTest < Redmine::ControllerTest
     assert_equal 'desc', user.pref[:comments_sorting]
     assert_equal '0', user.pref[:warn_on_leaving_unsaved]
     assert_equal 'proportional', user.pref[:textarea_font]
+    assert_equal 'history', user.pref[:history_default_tab]
   end
 
   def test_create_with_generate_password_should_email_the_password