diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 32d0a869..f19efd91 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -81,23 +81,19 @@ class ApplicationController < ActionController::Base # def count_undone_todos_phrase(todos_parent, string="actions") count = count_undone_todos(todos_parent) - if count == 1 - word = string.singularize - else - word = string.pluralize - end + word = count == 1 ? string.singularize : string.pluralize return count.to_s + " " + word end def count_undone_todos(todos_parent) - if todos_parent.nil? - count = 0 - elsif (todos_parent.is_a?(Project) && todos_parent.hidden?) + return 0 if todos_parent.nil? + + if (todos_parent.is_a?(Project) && todos_parent.hidden?) count = eval "@project_project_hidden_todo_counts[#{todos_parent.id}]" else count = eval "@#{todos_parent.class.to_s.downcase}_not_done_counts[#{todos_parent.id}]" end - count || 0 + end # Convert a date object to the format specified in the user's preferences in diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index c87ce450..59c16ee7 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -1,6 +1,6 @@ class StatsController < ApplicationController - helper :todos + helper :todos, :projects append_before_filter :init, :exclude => [] @@ -643,6 +643,18 @@ class StatsController < ApplicationController end end + def done + @source_view = 'done' + + @done_recently = current_user.todos.completed.all(:limit => 10, :order => 'completed_at DESC') + + init_not_done_counts(['project']) + @last_completed_projects = current_user.projects.completed.all(:limit => 10, :order => 'completed_at DESC') + + @last_completed_contexts = [] + #@last_completed_contexts = current_user.contexts.completed.all(:limit => 10, :order => 'completed_at DESC') + end + private def get_unique_tags_of_user diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 6ad84bf3..5dc13faa 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -471,14 +471,30 @@ class TodosController < ApplicationController def done @source_view = 'done' @page_title = t('todos.completed_tasks_title') + completed_todos = current_user.todos.completed - @done_today = completed_todos.completed_after(Time.zone.now.beginning_of_day) - @done_this_week = completed_todos.completed_after(Time.zone.now.beginning_of_week)-@done_today - @done_this_month = completed_todos.completed_after(Time.zone.now.beginning_of_month)-@done_this_week - @done_previous_month = completed_todos.completed_after( (Time.zone.now.beginning_of_month - 1.day).beginning_of_month)-@done_this_month + start_of_this_day = Time.zone.now.beginning_of_day + start_of_this_week = Time.zone.now.beginning_of_week + start_of_this_month = Time.zone.now.beginning_of_month + start_of_previous_month = (Time.zone.now.beginning_of_month - 1.day).beginning_of_month + includes = {:include => [:context, :project, :tags, :taggings, :successors, :predecessors]} + + @done_today = completed_todos.completed_after(start_of_this_day).all(includes) + @done_this_week = completed_todos.completed_after(start_of_this_week).completed_before(start_of_this_day).all(includes) + @done_this_month = completed_todos.completed_after(start_of_this_month).completed_before(start_of_this_week).all(includes) @count = @done_today.size + @done_this_week.size + @done_this_month.size end + def all_done + @source_view = 'done' + @page_title = t('todos.completed_tasks_title') + + includes = [:context, :project, :tags, :taggings, :successors, :predecessors] + + @done = current_user.todos.completed.paginate :page => params[:page], :per_page => 20, :order => 'completed_at DESC', :include => includes + @count = @done.size + end + def list_deferred @source_view = 'deferred' @page_title = t('todos.deferred_tasks_title') @@ -961,7 +977,7 @@ class TodosController < ApplicationController # If you've set no_completed to zero, the completed items box isn't shown # on the home page max_completed = current_user.prefs.show_number_completed - @done = current_user.completed_todos.find(:all, :limit => max_completed, :include => [ :context, :project, :tags ]) unless max_completed == 0 + @done = current_user.todos.completed.find(:all, :limit => max_completed, :include => [ :context, :project, :tags ]) unless max_completed == 0 # Set count badge to number of not-done, not hidden context items @count = current_user.todos.active.not_hidden.count(:all) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b4003c36..470af029 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,7 +5,6 @@ class UsersController < ApplicationController # GET /users GET /users.xml def index - @users = User.find(:all, :order => 'login') respond_to do |format| format.html do @page_title = "TRACKS::Manage Users" @@ -15,7 +14,10 @@ class UsersController < ApplicationController # we get returned here when signup is successful store_location end - format.xml { render :xml => @users.to_xml(:except => [ :password ]) } + format.xml do + @users = User.find(:all, :order => 'login') + render :xml => @users.to_xml(:except => [ :password ]) + end end end diff --git a/app/views/stats/done.html.erb b/app/views/stats/done.html.erb new file mode 100644 index 00000000..efe5875f --- /dev/null +++ b/app/views/stats/done.html.erb @@ -0,0 +1,44 @@ +
+
+ +

+ <%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.actions') %> +

+ <% if @done_recently.empty? -%> +

<%= t('todos.no_last_completed_actions') %>

+ <% else -%> + <%= render :partial => "todos/todo", :collection => @done_recently, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %> + <% end -%> +
+ +
+ +

+ <%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.projects') %> +

+ <% if @last_completed_projects.empty? -%> +

<%= t('projects.no_last_completed_projects') %>

+ <% else -%> +
+ <%= render :partial => '/projects/project_listing', + :collection => @last_completed_projects, + :locals => {:suppress_drag_handle => true} + %> +
+ <% end -%> +
+ +
+ +

+ <%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.contexts') %> +

+ <% if @last_completed_contexts.empty? -%> +

<%= t('projects.no_last_completed_contexts') %>

+ <% else -%> + TODO + <% end -%> +
+ + +
diff --git a/app/views/todos/all_done.html.erb b/app/views/todos/all_done.html.erb new file mode 100644 index 00000000..b758bb4f --- /dev/null +++ b/app/views/todos/all_done.html.erb @@ -0,0 +1,22 @@ +<% + paginate_options = { + :class => :add_note_link, + :previous_label => '« '+ t('common.previous'), + :next_label => t('common.next')+' »', + :inner_window => 2 + } +%> +
+
+ <%= will_paginate @done, paginate_options %> +

<%= t('todos.all_completed') %>

+ <% if @done.empty? -%> +

<%= t('todos.no_completed_actions') %>

+ <% else -%> + <%= render :partial => "todos/todo", :collection => @done, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %> + <% end -%> +
+ + <%= will_paginate @done, paginate_options %> + +
diff --git a/app/views/todos/done.html.erb b/app/views/todos/done.html.erb index 41d12693..10508202 100644 --- a/app/views/todos/done.html.erb +++ b/app/views/todos/done.html.erb @@ -18,7 +18,7 @@
-

<%= t('todos.completed_rest_of_month', :month_name => 'TODO') %>

+

<%= t('todos.completed_rest_of_month') %>

<% if @done_this_month.empty? -%>

<%= t('todos.no_completed_actions') %>

<% else -%> @@ -26,14 +26,6 @@ <% end -%>
-
-

<%= t('todos.completed_rest_of_previous_month', :month_name => 'TODO2') %>

- <% if @done_previous_month.empty? -%> -

<%= t('todos.no_completed_actions') %>

- <% else -%> - <%= render :partial => "todos/todo", :collection => @done_previous_month, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %> - <% end -%> -
- +

You can see all completed actions <%= link_to "here", all_done_todos_path %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 263a4ed6..e978fa13 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -62,6 +62,9 @@ en: cancel: "Cancel" ok: "Ok" add: "Add" + previous: "Previous" + next: "Next" + last: "Last" project: "Project" projects: "Projects" context: "Context" @@ -288,6 +291,7 @@ en: actions_in_project_title: "Actions in this project" notes: "Notes" notes_empty: "There are no notes for this project" + no_last_completed_projects: "No completed projects found" settings: "Settings" state: "This project is %{state}" this_project: "This project" @@ -468,6 +472,7 @@ en: no_deferred_actions_with: "No deferred actions with the tag '%{tag_name}'" completed_actions_with: "Completed actions with the tag %{tag_name}" no_completed_actions_with: "No completed actions with the tag '%{tag_name}'" + no_last_completed_actions: "No completed actions found" next_action_description: "Next action description" new_related_todo_created: "A new todo was added which belongs to this recurring todo" new_related_todo_created_short: "created a new todo" @@ -660,6 +665,7 @@ en: completed_rest_of_week: "Completed in the rest of this week" completed_rest_of_month: "Completed in the rest of this month" completed_rest_of_previous_month: "Completed in the rest of the previous month" + all_completed: "All completed actions" added_new_next_action: "Added new next action" added_new_next_action_singular: "Added new next action" added_new_next_action_plural: "Added new next actions" diff --git a/config/routes.rb b/config/routes.rb index 33d5bf5e..b2a16706 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,7 +16,7 @@ ActionController::Routing::Routes.draw do |map| contexts.done 'contexts/done', :action => 'completed' end - map.resources :projects, :collection => {:order => :post, :alphabetize => :post, :actionize => :post} do |projects| + map.resources :projects, :collection => {:order => :post, :alphabetize => :post, :actionize => :post, :done => :get} do |projects| projects.resources :todos, :name_prefix => "project_" end @@ -28,7 +28,8 @@ ActionController::Routing::Routes.draw do |map| map.resources :todos, :member => {:toggle_check => :put, :toggle_star => :put}, - :collection => {:check_deferred => :post, :filter_to_context => :post, :filter_to_project => :post, :done => :get} + :collection => {:check_deferred => :post, :filter_to_context => :post, :filter_to_project => :post, + :done => :get, :all_done => :get} map.with_options :controller => :todos do |todos| todos.home '', :action => "index" @@ -83,7 +84,12 @@ ActionController::Routing::Routes.draw do |map| end map.preferences 'preferences', :controller => 'preferences', :action => 'index' - map.stats 'stats', :controller => 'stats', :action => 'index' + + map.with_options :controller => :stats do |stats| + stats.stats_page 'stats', :action => 'index' + stats.done_overview 'done', :action => 'done' + end + map.search 'search', :controller => 'search', :action => 'index' map.data 'data', :controller => 'data', :action => 'index' map.done 'done', :controller => 'todos', :action => 'completed_overview' diff --git a/public/stylesheets/standard.css b/public/stylesheets/standard.css index 0fee6eb6..c029ed91 100644 --- a/public/stylesheets/standard.css +++ b/public/stylesheets/standard.css @@ -721,12 +721,12 @@ li { padding-top:10px; font-size: 0.8em; } + .sortable_row { background: #fff; _background: transparent; /* the underscore is only used by ie6 and below */ padding: 4px 4px 4px 8px; margin: 2px 2px; - border: 1px solid #ccc; } .edit-form { @@ -769,7 +769,6 @@ div.buttons, div.buttons a, div.buttons a:hover { div#list-active-projects, div#list-hidden-projects, div#list-completed-projects, div#list-contexts, div#projects-empty-nd { clear:right; - border: 1px solid #999; } .project-state-group h2, .list-stategroup-contexts-container h2 {