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')
# 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
end
def show
+ @comments = @news.comments
+ @comments.reverse! if User.current.wants_comments_in_reverse_order?
end
def new
belongs_to :user
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
+ attr_accessor :indice
acts_as_searchable :columns => 'notes',
:include => :issue,
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')
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 %>
</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 %> » <%=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 %>
<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>
<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) %>
<% 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 %>
<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' %>
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
text_destroy_time_entries: Delete reported hours\r
text_reassign_time_entries: 'Reassign reported hours to this issue:'\r
setting_activity_days_default: Days displayed on project activity\r
+label_chronological_order: In chronological order\r
+field_comments_sorting: Afficher les commentaires\r
+label_reverse_chronological_order: In reverse chronological order\r
+label_preferences: Preferences\r
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
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
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
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
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
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
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
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
@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