From bbe8ea29e8d3e6de60b96c08d60de9447bcceca9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 5 Mar 2008 13:44:08 +0000 Subject: Display the last 30 days on the activity view rather than the current month. Number of days can be configured in the application settings. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1196 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 23 ++++++----------------- app/helpers/projects_helper.rb | 4 ++++ app/views/projects/activity.rhtml | 18 +++++++++--------- app/views/settings/_general.rhtml | 3 +++ 4 files changed, 22 insertions(+), 26 deletions(-) (limited to 'app') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f9d6d0f0b..b9758c810 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -218,25 +218,14 @@ class ProjectsController < ApplicationController end def activity - if params[:year] and params[:year].to_i > 1900 - @year = params[:year].to_i - if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 - @month = params[:month].to_i - end + @days = Setting.activity_days_default.to_i + + if params[:from] + begin; @date_to = params[:from].to_date; rescue; end end - @year ||= Date.today.year - @month ||= Date.today.month - case params[:format] - when 'atom' - # 30 last days - @date_from = Date.today - 30 - @date_to = Date.today + 1 - else - # current month - @date_from = Date.civil(@year, @month, 1) - @date_to = @date_from >> 1 - end + @date_to ||= Date.today + 1 + @date_from = @date_to - @days @event_types = %w(issues news files documents changesets wiki_pages messages) @event_types.delete('wiki_pages') unless @project.wiki diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index c07bbd2c2..a16377412 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -26,6 +26,10 @@ module ProjectsHelper }, options end + def format_activity_day(date) + date == Date.today ? l(:label_today).titleize : format_date(date) + end + def format_activity_description(text) h(truncate(text, 250)) end diff --git a/app/views/projects/activity.rhtml b/app/views/projects/activity.rhtml index aca08fd6f..95c8d485f 100644 --- a/app/views/projects/activity.rhtml +++ b/app/views/projects/activity.rhtml @@ -1,8 +1,8 @@ -

<%= "#{month_name(@month)} #{@year}" %>

+

<%= l(:label_activity) %>

-<% @events_by_day.keys.sort {|x,y| y <=> x }.each do |day| %> -

<%= day_name(day.cwday) %> <%= day.day %>

+<% @events_by_day.keys.sort.reverse.each do |day| %> +

<%= format_activity_day(day) %>

<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<%= format_time(e.event_datetime, false) %> @@ -19,14 +19,14 @@ <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
-<% prev_params = params.clone.update :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1) %> -<%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), - {:update => "content", :url => prev_params}, {:href => url_for(prev_params)} %> +<%= link_to_remote(('« ' + l(:label_previous)), + {:update => "content", :url => params.merge(:from => @date_to - @days), :complete => 'window.scrollTo(0,0)'}, + {:href => url_for(params.merge(:from => @date_to - @days))}) %>
-<% next_params = params.clone.update :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1) %> -<%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), - {:update => "content", :url => next_params}, {:href => url_for(next_params)} %> +<%= link_to_remote((l(:label_next) + ' »'), + {:update => "content", :url => params.merge(:from => @date_to + @days), :complete => 'window.scrollTo(0,0)'}, + {:href => url_for(params.merge(:from => @date_to + @days))}) unless @date_to >= Date.today %>
 

diff --git a/app/views/settings/_general.rhtml b/app/views/settings/_general.rhtml index 548ebbfac..bb56c43db 100644 --- a/app/views/settings/_general.rhtml +++ b/app/views/settings/_general.rhtml @@ -29,6 +29,9 @@

<%= text_field_tag 'settings[per_page_options]', Setting.per_page_options_array.join(', '), :size => 20 %>
<%= l(:text_comma_separated) %>

+

+<%= text_field_tag 'settings[activity_days_default]', Setting.activity_days_default, :size => 6 %> <%= l(:label_day_plural) %>

+

<%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %>

-- cgit v1.2.3