summaryrefslogtreecommitdiffstats
path: root/app/helpers/activities_helper.rb
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/helpers/activities_helper.rb
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/helpers/activities_helper.rb')
-rw-r--r--app/helpers/activities_helper.rb33
1 files changed, 33 insertions, 0 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