diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-03-05 15:41:54 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-03-05 15:41:54 +0000 |
commit | e951d8458413f02ba613163df862d1a352ed3692 (patch) | |
tree | c9f1ec441a1243ffa35bb35ba5865588c710b20e | |
parent | bbe8ea29e8d3e6de60b96c08d60de9447bcceca9 (diff) | |
download | redmine-e951d8458413f02ba613163df862d1a352ed3692.tar.gz redmine-e951d8458413f02ba613163df862d1a352ed3692.zip |
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
35 files changed, 134 insertions, 17 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 4a44d09bc..263675040 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -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') diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 49f4ba77c..64a7fa1c9 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -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 diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 66ed61cf4..c9ba6b991 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -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 diff --git a/app/models/journal.rb b/app/models/journal.rb index d757ef90d..7c5e3d3bf 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -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, diff --git a/app/models/user.rb b/app/models/user.rb index 22d66539d..2dd698f28 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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') diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 1ed9e0fd9..73e4a50c6 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -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 diff --git a/app/views/issues/_history.rhtml b/app/views/issues/_history.rhtml index 7c1ee2113..373758874 100644 --- a/app/views/issues/_history.rhtml +++ b/app/views/issues/_history.rhtml @@ -1,8 +1,7 @@ -<% 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 %> diff --git a/app/views/messages/edit.rhtml b/app/views/messages/edit.rhtml index 808b6ea27..dcc59a396 100644 --- a/app/views/messages/edit.rhtml +++ b/app/views/messages/edit.rhtml @@ -1,6 +1,6 @@ <h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%=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 %> diff --git a/app/views/messages/show.rhtml b/app/views/messages/show.rhtml index 7d4c9989e..b9897cb40 100644 --- a/app/views/messages/show.rhtml +++ b/app/views/messages/show.rhtml @@ -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> diff --git a/app/views/my/account.rhtml b/app/views/my/account.rhtml index 77568836d..20210c99a 100644 --- a/app/views/my/account.rhtml +++ b/app/views/my/account.rhtml @@ -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 %> diff --git a/app/views/news/show.rhtml b/app/views/news/show.rhtml index cc9eed043..6de8aa86e 100644 --- a/app/views/news/show.rhtml +++ b/app/views/news/show.rhtml @@ -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' %> diff --git a/lang/bg.yml b/lang/bg.yml index a99a8888a..11e18b849 100644 --- a/lang/bg.yml +++ b/lang/bg.yml @@ -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 diff --git a/lang/cs.yml b/lang/cs.yml index 5036b6b45..ccf93fb9c 100644 --- a/lang/cs.yml +++ b/lang/cs.yml @@ -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 diff --git a/lang/de.yml b/lang/de.yml index 3d0db927c..bdbe549c2 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -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 diff --git a/lang/en.yml b/lang/en.yml index a23d1b025..0445834fe 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -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 diff --git a/lang/es.yml b/lang/es.yml index 66238934d..d137054d9 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -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 diff --git a/lang/fi.yml b/lang/fi.yml index d85629e1f..b2ad672f4 100644 --- a/lang/fi.yml +++ b/lang/fi.yml @@ -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 diff --git a/lang/fr.yml b/lang/fr.yml index 85e699c3c..b992ceff2 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -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 diff --git a/lang/he.yml b/lang/he.yml index fe31e860b..66a493bbb 100644 --- a/lang/he.yml +++ b/lang/he.yml @@ -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 diff --git a/lang/it.yml b/lang/it.yml index f207c2e19..c47729c50 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -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 diff --git a/lang/ja.yml b/lang/ja.yml index f00fc4d81..37392dd7e 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -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 diff --git a/lang/ko.yml b/lang/ko.yml index cf25e23ef..5685d063a 100644 --- a/lang/ko.yml +++ b/lang/ko.yml @@ -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 diff --git a/lang/lt.yml b/lang/lt.yml index b50120764..c783f5768 100644 --- a/lang/lt.yml +++ b/lang/lt.yml @@ -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 diff --git a/lang/nl.yml b/lang/nl.yml index 2d8a6aa00..6d650456d 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -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 diff --git a/lang/pl.yml b/lang/pl.yml index 57559aedb..bf8f3f1ba 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -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 diff --git a/lang/pt-br.yml b/lang/pt-br.yml index 35f490b83..9ddd6f94b 100644 --- a/lang/pt-br.yml +++ b/lang/pt-br.yml @@ -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
diff --git a/lang/pt.yml b/lang/pt.yml index c07364f72..63972d042 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -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 diff --git a/lang/ro.yml b/lang/ro.yml index 68de767a9..9d374af53 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -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 diff --git a/lang/ru.yml b/lang/ru.yml index 39a30fd3b..d5b67f964 100644 --- a/lang/ru.yml +++ b/lang/ru.yml @@ -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 diff --git a/lang/sr.yml b/lang/sr.yml index 5e693c09e..edef5f7f5 100644 --- a/lang/sr.yml +++ b/lang/sr.yml @@ -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 diff --git a/lang/sv.yml b/lang/sv.yml index 1b4698f35..f3940759b 100644 --- a/lang/sv.yml +++ b/lang/sv.yml @@ -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 diff --git a/lang/uk.yml b/lang/uk.yml index c26454189..d8e4a7a66 100644 --- a/lang/uk.yml +++ b/lang/uk.yml @@ -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 diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml index 5d5040811..eb1a5e305 100644 --- a/lang/zh-tw.yml +++ b/lang/zh-tw.yml @@ -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 diff --git a/lang/zh.yml b/lang/zh.yml index 8646d47cd..e7d790938 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -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 diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 845a34afd..3209f261a 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -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 |