Feature #3058 » 0007-user-preference-for-issue-history-default-tab.patch
| app/helpers/issues_helper.rb | ||
|---|---|---|
| 562 | 562 |
tabs |
| 563 | 563 |
end |
| 564 | 564 | |
| 565 |
def issue_history_default_tab |
|
| 566 |
# tab params overrides user default tab preference |
|
| 567 |
return params[:tab] if params[:tab].present? |
|
| 568 |
user_default_tab = User.current.pref.history_default_tab |
|
| 569 | ||
| 570 |
case user_default_tab |
|
| 571 |
when 'last_tab_visited' |
|
| 572 |
cookies['history_last_tab'].present? ? cookies['history_last_tab'] : 'notes' |
|
| 573 |
when '' |
|
| 574 |
'notes' |
|
| 575 |
else |
|
| 576 |
user_default_tab |
|
| 577 |
end |
|
| 578 |
end |
|
| 579 | ||
| 565 | 580 |
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 | ||
|---|---|---|
| 33 | 33 |
'warn_on_leaving_unsaved', |
| 34 | 34 |
'no_self_notified', |
| 35 | 35 |
'textarea_font', |
| 36 |
'recently_used_projects' |
|
| 36 |
'recently_used_projects', |
|
| 37 |
'history_default_tab' |
|
| 37 | 38 | |
| 38 | 39 |
TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional'] |
| 39 | 40 | |
| ... | ... | |
| 93 | 94 | |
| 94 | 95 |
def recently_used_projects; (self[:recently_used_projects] || 3).to_i; end |
| 95 | 96 |
def recently_used_projects=(value); self[:recently_used_projects] = value.to_i; end |
| 97 |
def history_default_tab; self[:history_default_tab]; end |
|
| 98 |
def history_default_tab=(value); self[:history_default_tab]=value; end |
|
| 96 | 99 | |
| 97 | 100 |
# Returns the names of groups that are displayed on user's page |
| 98 | 101 |
# Example: |
| 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 | ||
|---|---|---|
| 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 | 7 |
<p><%= pref_fields.text_field :recently_used_projects, :size => 2 %></p> |
| 8 |
<p><%= pref_fields.select :history_default_tab, history_default_tab_options %></p> |
|
| 8 | 9 |
<% end %> |
| config/locales/en.yml | ||
|---|---|---|
| 383 | 383 |
field_digest: Checksum |
| 384 | 384 |
field_default_assigned_to: Default assignee |
| 385 | 385 |
field_recently_used_projects: Number of recently used projects in jump box |
| 386 |
field_history_default_tab: Issue's history default tab |
|
| 386 | 387 | |
| 387 | 388 |
setting_app_title: Application title |
| 388 | 389 |
setting_welcome_text: Welcome text |
| ... | ... | |
| 1058 | 1059 |
label_preferred_body_part_html: HTML (experimental) |
| 1059 | 1060 |
label_issue_history_properties: Property changes |
| 1060 | 1061 |
label_issue_history_notes: Notes |
| 1062 |
label_last_tab_visited: Last visited tab |
|
| 1061 | 1063 | |
| 1062 | 1064 |
button_login: Login |
| 1063 | 1065 |
button_submit: Submit |
| public/javascripts/application.js | ||
|---|---|---|
| 929 | 929 |
$(document).ready(function(){
|
| 930 | 930 |
$('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
|
| 931 | 931 |
toggleDisabledInit(); |
| 932 | ||
| 933 |
$('#history .tabs').on('click', 'a', function(e){
|
|
| 934 |
var tab = $(e.target).attr('id').replace('tab-','');
|
|
| 935 |
document.cookie = 'history_last_tab=' + tab |
|
| 936 |
}); |
|
| 932 | 937 |
}); |
| 933 | 938 | |
| 934 | 939 |
$(document).ready(function(){
|
| test/functional/users_controller_test.rb | ||
|---|---|---|
| 292 | 292 |
'time_zone' => 'Paris', |
| 293 | 293 |
'comments_sorting' => 'desc', |
| 294 | 294 |
'warn_on_leaving_unsaved' => '0', |
| 295 |
'textarea_font' => 'proportional' |
|
| 295 |
'textarea_font' => 'proportional', |
|
| 296 |
'history_default_tab' => 'history' |
|
| 296 | 297 |
} |
| 297 | 298 |
} |
| 298 | 299 |
end |
| ... | ... | |
| 303 | 304 |
assert_equal 'desc', user.pref[:comments_sorting] |
| 304 | 305 |
assert_equal '0', user.pref[:warn_on_leaving_unsaved] |
| 305 | 306 |
assert_equal 'proportional', user.pref[:textarea_font] |
| 307 |
assert_equal 'history', user.pref[:history_default_tab] |
|
| 306 | 308 |
end |
| 307 | 309 | |
| 308 | 310 |
def test_create_with_generate_password_should_email_the_password |
- « Previous
- 1
- …
- 26
- 27
- 28
- Next »