Project

General

Profile

Feature #1422 » activitydaterange-for-2.5.2.patch

The feature patch for redmine V2.5.2 - Frei-Cedric Hackbarth - macio GmbH, 2014-10-13 09:41

View differences:

app/controllers/activities_controller.rb (working copy)
@days = Setting.activity_days_default.to_i
if params[:from]
begin; @date_to = params[:from].to_date + 1; rescue; end
begin; @date_from = params[:from].to_date; rescue; end
end
if params[:to]
begin; @date_to = params[:to].to_date + 1; rescue; end
end
if (@date_from == nil) || (@date_to == nil)
@date_to = Date.today + 1
@date_from = @date_to - @days
end
@date_to ||= Date.today + 1
@date_from = @date_to - @days
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
app/views/activities/index.html.erb (working copy)
<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_from), :end => format_date(@date_to - 1)) %></p>
<%=form_tag({:controller => 'activities', :action => 'index', :project_id => @project}, :method => :get, :id => 'query_form') do %>
<%= l(:label_date_from) %>
<%= text_field_tag 'from',@date_from,:size => 10 %>
<%= calendar_for('from') %>
<%= l(:label_date_to) %>
<%= text_field_tag 'to',@date_to - 1,:size => 10 %>
<%= calendar_for('to') %>
<%= submit_tag( l(:button_apply) , :class => 'button-small' ) %>
<% end %>
<div id="activity">
<% @events_by_day.keys.sort.reverse.each do |day| %>
<h3><%= format_activity_day(day) %></h3>
......
<div style="float:left;">
<%= link_to_content_update("\xc2\xab " + l(:label_previous),
params.merge(:from => @date_to - @days - 1),
:title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1))) %>
params.merge(:from => @date_from - @days, :to => @date_from - 1),
:title => l(:label_date_from_to, :start => format_date(@date_from - @days), :end => format_date(@date_from - 1))) %>
</div>
<div style="float:right;">
<%= link_to_content_update(l(:label_next) + " \xc2\xbb",
params.merge(:from => @date_to + @days - 1),
:title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))) unless @date_to >= Date.today %>
params.merge(:from => @date_to, :to => @date_to + @days - 1),
:title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))) unless @date_to > Date.today %>
</div>
&nbsp;
<% other_formats_links do |f| %>
<%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %>
<%= f.link_to 'Atom', :url => params.merge(:from => nil, :to => nil, :key => User.current.rss_key) %>
<% end %>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %>
<%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :to => nil, :key => User.current.rss_key)) %>
<% end %>
<% content_for :sidebar do %>
......
<%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
<label for="show_<%=t%>">
<%= link_to(l("label_#{t.singularize}_plural"),
{"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%>
{"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from], :to => params[:to]})%>
</label>
</li>
<% end %>
app/views/users/show.html.erb (working copy)
<% unless @events_by_day.empty? %>
<h3><%= link_to l(:label_activity), :controller => 'activities',
:action => 'index', :id => nil, :user_id => @user,
:from => @events_by_day.keys.first %></h3>
:from => @events_by_day.keys.first - Setting.activity_days_default.to_i,
:to => @events_by_day.keys.first %>
</h3>
<p>
<%=l(:label_reported_issues)%>: <%= Issue.where(:author_id => @user.id).count %>
(2-2/7)