summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-08 08:24:01 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-08 08:24:01 +0000
commit0e30724d660146d133318d9b3288a8a1eba4d8c4 (patch)
tree122f24969ad517248d59458e25f37726a342b191 /app
parent7222e4012db58c53d364e3b065e70338c094e878 (diff)
downloadredmine-0e30724d660146d133318d9b3288a8a1eba4d8c4.tar.gz
redmine-0e30724d660146d133318d9b3288a8a1eba4d8c4.zip
Group events in the activity view (#12542).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10951 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/activities_helper.rb33
-rw-r--r--app/models/journal.rb1
-rw-r--r--app/models/message.rb1
-rw-r--r--app/models/time_entry.rb1
-rw-r--r--app/models/wiki_content.rb1
-rw-r--r--app/views/activities/index.html.erb9
6 files changed, 42 insertions, 4 deletions
diff --git a/app/helpers/activities_helper.rb b/app/helpers/activities_helper.rb
new file mode 100644
index 000000000..54556a0a7
--- /dev/null
+++ b/app/helpers/activities_helper.rb
@@ -0,0 +1,33 @@
+# encoding: utf-8
+#
+# Redmine - project management software
+# Copyright (C) 2006-2012 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module ActivitiesHelper
+ def sort_activity_events(events)
+ events_by_group = events.group_by(&:event_group)
+ sorted_events = []
+ events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each do |event|
+ if group_events = events_by_group.delete(event.event_group)
+ group_events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each_with_index do |e, i|
+ sorted_events << [e, i > 0]
+ end
+ end
+ end
+ sorted_events
+ end
+end
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 560ccf3b8..df52d89b2 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -28,6 +28,7 @@ class Journal < ActiveRecord::Base
acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" },
:description => :notes,
:author => :user,
+ :group => :issue,
:type => Proc.new {|o| (s = o.new_status) ? (s.is_closed? ? 'issue-closed' : 'issue-edit') : 'issue-note' },
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id, :anchor => "change-#{o.id}"}}
diff --git a/app/models/message.rb b/app/models/message.rb
index f41d48f2f..53b461501 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -29,6 +29,7 @@ class Message < ActiveRecord::Base
:date_column => "#{table_name}.created_on"
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
:description => :content,
+ :group => :parent,
:type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
:url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id}.merge(o.parent_id.nil? ? {:id => o.id} :
{:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"})}
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 3abe114c0..17c2389ec 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -30,6 +30,7 @@ class TimeEntry < ActiveRecord::Base
acts_as_event :title => Proc.new {|o| "#{l_hours(o.hours)} (#{(o.issue || o.project).event_title})"},
:url => Proc.new {|o| {:controller => 'timelog', :action => 'index', :project_id => o.project, :issue_id => o.issue}},
:author => :user,
+ :group => :issue,
:description => :comments
acts_as_activity_provider :timestamp => "#{table_name}.created_on",
diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb
index 7c5704902..7e1430ee8 100644
--- a/app/models/wiki_content.rb
+++ b/app/models/wiki_content.rb
@@ -59,6 +59,7 @@ class WikiContent < ActiveRecord::Base
:description => :comments,
:datetime => :updated_on,
:type => 'wiki-page',
+ :group => :page,
:url => Proc.new {|o| {:controller => 'wiki', :action => 'show', :project_id => o.page.wiki.project, :id => o.page.title, :version => o.version}}
acts_as_activity_provider :type => 'wiki_edits',
diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb
index bb129477b..7522e4ba0 100644
--- a/app/views/activities/index.html.erb
+++ b/app/views/activities/index.html.erb
@@ -5,13 +5,14 @@
<% @events_by_day.keys.sort.reverse.each do |day| %>
<h3><%= format_activity_day(day) %></h3>
<dl>
-<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
- <dt class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
+<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
+ <dt class="<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
<%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>
<span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %>
- <%= link_to format_activity_title(e.event_title), e.event_url %></dt>
- <dd><span class="description"><%= format_activity_description(e.event_description) %></span>
+ <%= link_to format_activity_title(e.event_title), e.event_url %>
+ </dt>
+ <dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
<span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
<% end -%>
</dl>