mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Add my activities to my page (#2471).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@17443 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3a894f3a91
commit
87a671ce75
@ -28,6 +28,7 @@ class MyController < ApplicationController
|
|||||||
helper :users
|
helper :users
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
helper :queries
|
helper :queries
|
||||||
|
helper :activities
|
||||||
|
|
||||||
def index
|
def index
|
||||||
page
|
page
|
||||||
|
|||||||
@ -164,4 +164,10 @@ module MyHelper
|
|||||||
|
|
||||||
render :partial => 'my/blocks/timelog', :locals => {:block => block, :entries => entries, :entries_by_day => entries_by_day, :days => days}
|
render :partial => 'my/blocks/timelog', :locals => {:block => block, :entries => entries, :entries_by_day => entries_by_day, :days => days}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_activity_block(block, settings)
|
||||||
|
events_by_day = Redmine::Activity::Fetcher.new(User.current, :author => User.current).events(nil, nil, :limit => 10).group_by(&:event_date)
|
||||||
|
|
||||||
|
render :partial => 'my/blocks/activity', :locals => {:events_by_day => events_by_day}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
17
app/views/activities/_activities.html.erb
Normal file
17
app/views/activities/_activities.html.erb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<div id="activity">
|
||||||
|
<% events_by_day.keys.sort.reverse_each do |day| %>
|
||||||
|
<h3><%= format_activity_day(day) %></h3>
|
||||||
|
<dl>
|
||||||
|
<% sort_activity_events(events_by_day[day]).each do |e, in_group| -%>
|
||||||
|
<dt class="<%= e.event_type %> icon icon-<%= 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', e.project, :class => 'project') if @project.nil? || @project != e.project %>
|
||||||
|
<%= 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>
|
||||||
|
<% end -%>
|
||||||
|
</div>
|
||||||
@ -1,24 +1,8 @@
|
|||||||
<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2>
|
<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2>
|
||||||
|
|
||||||
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
|
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
|
||||||
|
|
||||||
<div id="activity">
|
<%= render :partial => 'activities/activities', :locals => {:events_by_day => @events_by_day} %>
|
||||||
<% @events_by_day.keys.sort.reverse_each do |day| %>
|
|
||||||
<h3><%= format_activity_day(day) %></h3>
|
|
||||||
<dl>
|
|
||||||
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
|
|
||||||
<dt class="<%= e.event_type %> icon icon-<%= 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', e.project, :class => 'project') if @project.nil? || @project != e.project %>
|
|
||||||
<%= 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>
|
|
||||||
<% end -%>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
|
<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
|
||||||
|
|
||||||
<span class="pagination">
|
<span class="pagination">
|
||||||
|
|||||||
5
app/views/my/blocks/_activity.html.erb
Normal file
5
app/views/my/blocks/_activity.html.erb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<h3><%= link_to l(:label_activity), :controller => 'activities',
|
||||||
|
:action => 'index', :id => nil, :user_id => User.current,
|
||||||
|
:from => events_by_day.keys.first %></h3>
|
||||||
|
|
||||||
|
<%= render :partial => 'activities/activities', :locals => {:events_by_day => events_by_day} %>
|
||||||
@ -51,21 +51,7 @@
|
|||||||
<h3><%= link_to l(:label_activity), :controller => 'activities',
|
<h3><%= link_to l(:label_activity), :controller => 'activities',
|
||||||
:action => 'index', :id => nil, :user_id => @user,
|
:action => 'index', :id => nil, :user_id => @user,
|
||||||
:from => @events_by_day.keys.first %></h3>
|
:from => @events_by_day.keys.first %></h3>
|
||||||
|
<%= render :partial => 'activities/activities', :locals => {:events_by_day => @events_by_day} %>
|
||||||
<div id="activity">
|
|
||||||
<% @events_by_day.keys.sort.reverse_each do |day| %>
|
|
||||||
<h4><%= format_activity_day(day) %></h4>
|
|
||||||
<dl>
|
|
||||||
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
|
|
||||||
<dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
|
|
||||||
<span class="time"><%= format_time(e.event_datetime, false) %></span>
|
|
||||||
<%= content_tag('span', e.project, :class => 'project') %>
|
|
||||||
<%= 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>
|
|
||||||
<% end -%>
|
|
||||||
</dl>
|
|
||||||
<% end -%>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% other_formats_links do |f| %>
|
<% other_formats_links do |f| %>
|
||||||
<%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :key => User.current.rss_key} %>
|
<%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :key => User.current.rss_key} %>
|
||||||
|
|||||||
@ -29,7 +29,8 @@ module Redmine
|
|||||||
'news' => {:label => :label_news_latest},
|
'news' => {:label => :label_news_latest},
|
||||||
'calendar' => {:label => :label_calendar},
|
'calendar' => {:label => :label_calendar},
|
||||||
'documents' => {:label => :label_document_plural},
|
'documents' => {:label => :label_document_plural},
|
||||||
'timelog' => {:label => :label_spent_time}
|
'timelog' => {:label => :label_spent_time},
|
||||||
|
'activity' => {:label => :label_activity}
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.groups
|
def self.groups
|
||||||
|
|||||||
@ -198,6 +198,24 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_page_with_activity
|
||||||
|
user = User.find(2)
|
||||||
|
user.pref.my_page_layout = {'top' => ['activity']}
|
||||||
|
user.pref.save!
|
||||||
|
|
||||||
|
get :page
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
assert_select 'div#block-activity' do
|
||||||
|
assert_select 'h3' do
|
||||||
|
assert_select 'a[href=?]', activity_path(from: Date.today, user_id: user.id), :text => 'Activity'
|
||||||
|
end
|
||||||
|
assert_select 'div#activity' do
|
||||||
|
assert_select 'dt', 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_page_with_all_blocks
|
def test_page_with_all_blocks
|
||||||
blocks = Redmine::MyPage.blocks.keys
|
blocks = Redmine::MyPage.blocks.keys
|
||||||
preferences = User.find(2).pref
|
preferences = User.find(2).pref
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user