changeset 344:1a514b9347d4 feature_121

Add Recent Activity partial, include it as a block in My Page (on by default) and in the project information page
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 31 Mar 2011 15:19:30 +0100
parents 3564e1ae2ff7
children 712264d5d60a 8d0e011332ef c80fd1ef305f
files app/controllers/my_controller.rb app/views/activities/_recent.rhtml app/views/my/blocks/_activitymyprojects.rhtml app/views/projects/show.rhtml config/locales/en.yml public/stylesheets/application.css
diffstat 6 files changed, 68 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/my_controller.rb	Thu Mar 31 11:13:21 2011 +0100
+++ b/app/controllers/my_controller.rb	Thu Mar 31 15:19:30 2011 +0100
@@ -24,14 +24,15 @@
   BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
              'issuesreportedbyme' => :label_reported_issues,
              'issueswatched' => :label_watched_issues,
+             'activitymyprojects' => :label_activity_my_recent,
              'news' => :label_news_latest,
              'calendar' => :label_calendar,
              'documents' => :label_document_plural,
              'timelog' => :label_spent_time
            }.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze
 
-  DEFAULT_LAYOUT = {  'left' => ['issuesassignedtome'], 
-                      'right' => ['issuesreportedbyme'] 
+  DEFAULT_LAYOUT = {  'left' => ['activitymyprojects'], 
+                      'right' => ['issueswatched','calendar'] 
                    }.freeze
 
   verify :xhr => true,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/views/activities/_recent.rhtml	Thu Mar 31 15:19:30 2011 +0100
@@ -0,0 +1,51 @@
+<% events = @events_by_day %>
+<% max = 5 %>
+<% if (events.nil?) 
+     activity = Redmine::Activity::Fetcher.new(User.current, :project => @project)
+     events = activity.events(Date.today - 28, Date.today + 1).first(max)
+   end
+%>
+
+<div id="activity">
+
+<% if @project.nil? %>
+   <%= content_tag('h3', l(:label_activity_my_recent)) %>
+   <div class="activity box">
+<% end %>
+
+<% if events.empty? %>
+
+   <% if @project.nil? %>
+     <p><%= l(:label_activity_my_recent_none) %></p>
+   <% end %>
+
+<% else %>
+
+   <% if !@project.nil? %>
+     <div class="activity box">
+     <%= content_tag('h3', l(:label_activity_recent)) %>
+   <% end %>
+
+   <dl>
+   <% events.sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
+     <dt class="<%= 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) %></span>
+     <%= content_tag('span', link_to_project(e.project), :class => 'project') if @project.nil? || @project != e.project %>
+     <% if e.respond_to?(:event_author) %>
+       <span class="author"><%= e.event_author %></span>
+     <% end %>
+     </dt>
+     <dd><%= link_to format_activity_title(e.event_title), e.event_url %>
+     <span class="description"><%= format_activity_description(e.event_description) %></span>
+     </dd>
+   <% end -%>
+   </dl>
+
+   </div>
+
+<% end %>
+
+<% if events.empty? and @project.nil? %></div><% end %>
+
+</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/views/my/blocks/_activitymyprojects.rhtml	Thu Mar 31 15:19:30 2011 +0100
@@ -0,0 +1,4 @@
+
+<%= render :partial => 'activities/recent' %>
+
+
--- a/app/views/projects/show.rhtml	Thu Mar 31 11:13:21 2011 +0100
+++ b/app/views/projects/show.rhtml	Thu Mar 31 15:19:30 2011 +0100
@@ -46,7 +46,9 @@
 			<% end %>
 		</p>
   </div>
+
   <% end %>
+
   <%= call_hook(:view_projects_show_left, :project => @project) %>
 </div>
 
@@ -60,6 +62,9 @@
     <p><%= link_to l(:label_news_view_all), :controller => 'news', :action => 'index', :project_id => @project %></p>
   </div>  
   <% end %>
+
+  <%= render :partial => 'activities/recent' %>
+
   <%= call_hook(:view_projects_show_right, :project => @project) %>
 </div>
 
--- a/config/locales/en.yml	Thu Mar 31 11:13:21 2011 +0100
+++ b/config/locales/en.yml	Thu Mar 31 15:19:30 2011 +0100
@@ -518,6 +518,9 @@
   label_last_login: Last connection
   label_registered_on: Registered on
   label_activity: Activity
+  label_activity_recent: Recent activity
+  label_activity_my_recent: Recent activity in my projects
+  label_activity_my_recent_none: No recent activity
   label_overall_activity: Overall activity
   label_user_activity: "{{value}}'s activity"
   label_new: New
--- a/public/stylesheets/application.css	Thu Mar 31 11:13:21 2011 +0100
+++ b/public/stylesheets/application.css	Thu Mar 31 15:19:30 2011 +0100
@@ -216,6 +216,7 @@
 h3.version { background: url(../images/package.png) no-repeat 0% 50%; padding-left: 20px; }
 
 div.issues h3 { background: url(../images/ticket.png) no-repeat 0% 50%; padding-left: 20px; }
+div.activity h3 { background: url(../images/ticket.png) no-repeat 0% 50%; padding-left: 20px; }
 div.members h3 { background: url(../images/group.png) no-repeat 0% 50%; padding-left: 20px; }
 div.news h3 { background: url(../images/news.png) no-repeat 0% 50%; padding-left: 20px; }
 div.projects h3 { background: url(../images/projects.png) no-repeat 0% 50%; padding-left: 20px; }
@@ -294,6 +295,7 @@
 div#issue-changesets p { margin-top: 0; margin-bottom: 1em;}
 
 div#activity dl, #search-results { margin-left: 2em; }
+div#activity .box dl { margin-left: 0; }
 div#activity dd, #search-results dd { margin-bottom: 1em; padding-left: 18px; font-size: 0.9em; }
 div#activity dt, #search-results dt { margin-bottom: 0px; padding-left: 20px; line-height: 18px; background-position: 0 50%; background-repeat: no-repeat; }
 div#activity dt.me .time { border-bottom: 1px solid #999; }