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 /app | |
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
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/issues_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/messages_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/news_controller.rb | 2 | ||||
-rw-r--r-- | app/models/journal.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/models/user_preference.rb | 3 | ||||
-rw-r--r-- | app/views/issues/_history.rhtml | 6 | ||||
-rw-r--r-- | app/views/messages/edit.rhtml | 2 | ||||
-rw-r--r-- | app/views/messages/show.rhtml | 6 | ||||
-rw-r--r-- | app/views/my/account.rhtml | 14 | ||||
-rw-r--r-- | app/views/news/show.rhtml | 9 |
11 files changed, 34 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' %> |