Commit e951d845 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Add a user preference to choose how comments/replies are displayed: in…

Add a user preference to choose how comments/replies are displayed: in chronological or reverse chronological order (#589, #776).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1197 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent bbe8ea29
......@@ -92,6 +92,8 @@ class IssuesController < ApplicationController
def show
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
@journals.each_with_index {|j,i| j.indice = i+1}
@journals.reverse! if User.current.wants_comments_in_reverse_order?
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@activities = Enumeration::get_values('ACTI')
......
......@@ -29,6 +29,8 @@ class MessagesController < ApplicationController
# Show a topic and its replies
def show
@replies = @topic.children
@replies.reverse! if User.current.wants_comments_in_reverse_order?
@reply = Message.new(:subject => "RE: #{@message.subject}")
render :action => "show", :layout => false if request.xhr?
end
......
......@@ -36,6 +36,8 @@ class NewsController < ApplicationController
end
def show
@comments = @news.comments
@comments.reverse! if User.current.wants_comments_in_reverse_order?
end
def new
......
......@@ -23,6 +23,7 @@ class Journal < ActiveRecord::Base
belongs_to :user
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
attr_accessor :indice
acts_as_searchable :columns => 'notes',
:include => :issue,
......
......@@ -144,6 +144,10 @@ class User < ActiveRecord::Base
self.pref.time_zone.nil? ? nil : TimeZone[self.pref.time_zone]
end
def wants_comments_in_reverse_order?
self.pref[:comments_sorting] == 'desc'
end
# Return user's RSS key (a 40 chars long string), used to access feeds
def rss_key
token = self.rss_token || Token.create(:user => self, :action => 'feeds')
......
......@@ -46,4 +46,7 @@ class UserPreference < ActiveRecord::Base
self.others.store attr_name, value
end
end
def comments_sorting; self[:comments_sorting] end
def comments_sorting=(order); self[:comments_sorting]=order end
end
<% note_id = 1 %>
<% for journal in journals %>
<div id="change-<%= journal.id %>">
<h4><div style="float:right;"><%= link_to "##{note_id}", :anchor => "note-#{note_id}" %></div>
<%= content_tag('a', '', :name => "note-#{note_id}")%>
<h4><div style="float:right;"><%= link_to "##{journal.indice}", :anchor => "note-#{journal.indice}" %></div>
<%= content_tag('a', '', :name => "note-#{journal.indice}")%>
<%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
<ul>
<% for detail in journal.details %>
......@@ -11,5 +10,4 @@
</ul>
<%= render_notes(journal) unless journal.notes.blank? %>
</div>
<% note_id += 1 %>
<% end %>
<h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> &#187; <%=h @message.subject %></h2>
<% form_for :message, @message, :url => {:action => 'edit'}, :html => {:multipart => true} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= render :partial => 'form', :locals => {:f => f, :replying => !@message.parent.nil?} %>
<%= submit_tag l(:button_save) %>
<% end %>
......@@ -15,11 +15,11 @@
<br />
<h3 class="icon22 icon22-comment"><%= l(:label_reply_plural) %></h3>
<% @topic.children.each do |message| %>
<% @replies.each do |message| %>
<a name="<%= "message-#{message.id}" %>"></a>
<div class="contextual">
<%= link_to_if_authorized l(:button_edit), {:action => 'edit', :id => message}, :class => 'icon icon-edit' %>
<%= link_to_if_authorized l(:button_delete), {:action => 'destroy', :id => message}, :method => :post, :confirm => l(:text_are_you_sure), :class => 'icon icon-del' %>
<%= link_to_if_authorized image_tag('edit.png'), {:action => 'edit', :id => message}, :title => l(:button_edit) %>
<%= link_to_if_authorized image_tag('delete.png'), {:action => 'destroy', :id => message}, :method => :post, :confirm => l(:text_are_you_sure), :title => l(:button_delete) %>
</div>
<div class="message reply">
<h4><%=h message.subject %> - <%= authoring message.created_on, message.author %></h4>
......
......@@ -15,11 +15,6 @@
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
<p><%= f.select :language, lang_options_for_select %></p>
<% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %>
<p><%= pref_fields.select :time_zone, TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %></p>
<p><%= pref_fields.check_box :hide_mail %></p>
<% end %>
</div>
<%= submit_tag l(:button_save) %>
......@@ -38,6 +33,15 @@
<% end %>
<p><label><%= check_box_tag 'no_self_notified', 1, @user.pref[:no_self_notified] %> <%= l(:label_user_mail_no_self_notified) %></label></p>
</div>
<h3><%=l(:label_preferences)%></h3>
<div class="box tabular">
<% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %>
<p><%= pref_fields.check_box :hide_mail %></p>
<p><%= pref_fields.select :time_zone, TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %></p>
<p><%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %></p>
<% end %>
</div>
</div>
<% end %>
......
......@@ -34,14 +34,15 @@
<div id="comments" style="margin-bottom:16px;">
<h3 class="icon22 icon22-comment"><%= l(:label_comment_plural) %></h3>
<% @news.comments.each do |comment| %>
<% @comments.each do |comment| %>
<% next if comment.new_record? %>
<h4><%= authoring comment.created_on, comment.author %></h4>
<div class="contextual">
<%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy_comment', :id => @news, :comment_id => comment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
<%= link_to_if_authorized image_tag('delete.png'), {:controller => 'news', :action => 'destroy_comment', :id => @news, :comment_id => comment},
:confirm => l(:text_are_you_sure), :method => :post, :title => l(:button_delete) %>
</div>
<h4><%= authoring comment.created_on, comment.author %></h4>
<%= textilizable(comment.comments) %>
<% end if @news.comments_count > 0 %>
<% end if @comments.any? %>
</div>
<% if authorize_for 'news', 'add_comment' %>
......
......@@ -608,3 +608,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -608,3 +608,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -609,3 +609,7 @@ enumeration_issue_priorities: Ticket-Prioritäten
enumeration_doc_categories: Dokumentenkategorien
enumeration_activities: Aktivitäten (Zeiterfassung)
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -177,6 +177,7 @@ field_column_names: Columns
field_time_zone: Time zone
field_searchable: Searchable
field_default_value: Default value
field_comments_sorting: Afficher les commentaires
setting_app_title: Application title
setting_app_subtitle: Application subtitle
......@@ -501,6 +502,9 @@ label_ldap_authentication: LDAP authentication
label_downloads_abbr: D/L
label_optional_description: Optional description
label_add_another_file: Add another file
label_preferences: Preferences
label_chronological_order: In chronological order
label_reverse_chronological_order: In reverse chronological order
button_login: Login
button_submit: Submit
......
......@@ -611,3 +611,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -612,3 +612,7 @@ text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
label_on: 'on'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -177,6 +177,7 @@ field_column_names: Colonnes
field_time_zone: Fuseau horaire
field_searchable: Utilisé pour les recherches
field_default_value: Valeur par défaut
field_comments_sorting: Afficher les commentaires
setting_app_title: Titre de l'application
setting_app_subtitle: Sous-titre de l'application
......@@ -501,6 +502,9 @@ label_ldap_authentication: Authentification LDAP
label_downloads_abbr: D/L
label_optional_description: Description facultative
label_add_another_file: Ajouter un autre fichier
label_preferences: Préférences
label_chronological_order: Dans l'ordre chronologique
label_reverse_chronological_order: Dans l'ordre chronologique inverse
button_login: Connexion
button_submit: Soumettre
......
......@@ -608,3 +608,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -608,3 +608,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -609,3 +609,7 @@ label_optional_description: Optional description
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -608,3 +608,7 @@ label_last_month: last month
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -609,3 +609,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -609,3 +609,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -608,3 +608,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -608,3 +608,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -608,3 +608,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -608,3 +608,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -612,3 +612,7 @@ text_assign_time_entries_to_project: Прикрепить зарегистрир
text_destroy_time_entries: Удалить зарегистрированное время
text_reassign_time_entries: 'Перенести зарегистрированное время на следующую задачу:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -609,3 +609,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -609,3 +609,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -610,3 +610,7 @@ text_assign_time_entries_to_project: Assign reported hours to the project
text_destroy_time_entries: Delete reported hours
text_reassign_time_entries: 'Reassign reported hours to this issue:'
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -609,3 +609,7 @@ enumeration_issue_priorities: 項目優先權
enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (time tracking)
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -609,3 +609,7 @@ enumeration_issue_priorities: 问题优先级
enumeration_doc_categories: 文档类别
enumeration_activities: 活动(时间跟踪)
setting_activity_days_default: Days displayed on project activity
label_chronological_order: In chronological order
field_comments_sorting: Afficher les commentaires
label_reverse_chronological_order: In reverse chronological order
label_preferences: Preferences
......@@ -144,4 +144,12 @@ class UserTest < Test::Unit::TestCase
@jsmith.reload
assert !@jsmith.projects.first.recipients.include?(@jsmith.mail)
end
def test_comments_sorting_preference
assert !@jsmith.wants_comments_in_reverse_order?
@jsmith.pref.comments_sorting = 'asc'
assert !@jsmith.wants_comments_in_reverse_order?
@jsmith.pref.comments_sorting = 'desc'
assert @jsmith.wants_comments_in_reverse_order?
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment