start on done overview page

This commit is contained in:
Reinier Balt 2011-05-03 19:14:30 +02:00
parent 01057af684
commit 559a02d6f1
10 changed files with 127 additions and 32 deletions

View file

@ -81,23 +81,19 @@ class ApplicationController < ActionController::Base
# #
def count_undone_todos_phrase(todos_parent, string="actions") def count_undone_todos_phrase(todos_parent, string="actions")
count = count_undone_todos(todos_parent) count = count_undone_todos(todos_parent)
if count == 1 word = count == 1 ? string.singularize : string.pluralize
word = string.singularize
else
word = string.pluralize
end
return count.to_s + "&nbsp;" + word return count.to_s + "&nbsp;" + word
end end
def count_undone_todos(todos_parent) def count_undone_todos(todos_parent)
if todos_parent.nil? return 0 if todos_parent.nil?
count = 0
elsif (todos_parent.is_a?(Project) && todos_parent.hidden?) if (todos_parent.is_a?(Project) && todos_parent.hidden?)
count = eval "@project_project_hidden_todo_counts[#{todos_parent.id}]" count = eval "@project_project_hidden_todo_counts[#{todos_parent.id}]"
else else
count = eval "@#{todos_parent.class.to_s.downcase}_not_done_counts[#{todos_parent.id}]" count = eval "@#{todos_parent.class.to_s.downcase}_not_done_counts[#{todos_parent.id}]"
end end
count || 0
end end
# Convert a date object to the format specified in the user's preferences in # Convert a date object to the format specified in the user's preferences in

View file

@ -1,6 +1,6 @@
class StatsController < ApplicationController class StatsController < ApplicationController
helper :todos helper :todos, :projects
append_before_filter :init, :exclude => [] append_before_filter :init, :exclude => []
@ -643,6 +643,18 @@ class StatsController < ApplicationController
end end
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 private
def get_unique_tags_of_user def get_unique_tags_of_user

View file

@ -471,14 +471,30 @@ class TodosController < ApplicationController
def done def done
@source_view = 'done' @source_view = 'done'
@page_title = t('todos.completed_tasks_title') @page_title = t('todos.completed_tasks_title')
completed_todos = current_user.todos.completed completed_todos = current_user.todos.completed
@done_today = completed_todos.completed_after(Time.zone.now.beginning_of_day) start_of_this_day = Time.zone.now.beginning_of_day
@done_this_week = completed_todos.completed_after(Time.zone.now.beginning_of_week)-@done_today start_of_this_week = Time.zone.now.beginning_of_week
@done_this_month = completed_todos.completed_after(Time.zone.now.beginning_of_month)-@done_this_week start_of_this_month = Time.zone.now.beginning_of_month
@done_previous_month = completed_todos.completed_after( (Time.zone.now.beginning_of_month - 1.day).beginning_of_month)-@done_this_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 @count = @done_today.size + @done_this_week.size + @done_this_month.size
end 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 def list_deferred
@source_view = 'deferred' @source_view = 'deferred'
@page_title = t('todos.deferred_tasks_title') @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 # If you've set no_completed to zero, the completed items box isn't shown
# on the home page # on the home page
max_completed = current_user.prefs.show_number_completed 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 # Set count badge to number of not-done, not hidden context items
@count = current_user.todos.active.not_hidden.count(:all) @count = current_user.todos.active.not_hidden.count(:all)

View file

@ -5,7 +5,6 @@ class UsersController < ApplicationController
# GET /users GET /users.xml # GET /users GET /users.xml
def index def index
@users = User.find(:all, :order => 'login')
respond_to do |format| respond_to do |format|
format.html do format.html do
@page_title = "TRACKS::Manage Users" @page_title = "TRACKS::Manage Users"
@ -15,7 +14,10 @@ class UsersController < ApplicationController
# we get returned here when signup is successful # we get returned here when signup is successful
store_location store_location
end 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
end end

View file

@ -0,0 +1,44 @@
<div id="display_box">
<div class="container">
<div class=add_note_link><%= link_to "Show all", done_todos_path%></div>
<h2>
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.actions') %>
</h2>
<% if @done_recently.empty? -%>
<div class="message"><p><%= t('todos.no_last_completed_actions') %></p></div>
<% else -%>
<%= render :partial => "todos/todo", :collection => @done_recently, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
<% end -%>
</div>
<div class="container">
<div class=add_note_link><%= link_to "Show all", done_projects_path%></div>
<h2>
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.projects') %>
</h2>
<% if @last_completed_projects.empty? -%>
<div class="message"><p><%= t('projects.no_last_completed_projects') %></p></div>
<% else -%>
<div id="list-completed-projects" class="project-list">
<%= render :partial => '/projects/project_listing',
:collection => @last_completed_projects,
:locals => {:suppress_drag_handle => true}
%>
</div>
<% end -%>
</div>
<div class="container">
<div class=add_note_link><%= link_to "Show all", done_contexts_path%></div>
<h2>
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.contexts') %>
</h2>
<% if @last_completed_contexts.empty? -%>
<div class="message"><p><%= t('projects.no_last_completed_contexts') %></p></div>
<% else -%>
TODO
<% end -%>
</div>
</div><!-- End of display_box -->

View file

@ -0,0 +1,22 @@
<%
paginate_options = {
:class => :add_note_link,
:previous_label => '&laquo; '+ t('common.previous'),
:next_label => t('common.next')+' &raquo;',
:inner_window => 2
}
%>
<div id="display_box_projects">
<div class="container">
<%= will_paginate @done, paginate_options %>
<h2><%= t('todos.all_completed') %></h2>
<% if @done.empty? -%>
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
<% else -%>
<%= render :partial => "todos/todo", :collection => @done, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
<% end -%>
</div>
<%= will_paginate @done, paginate_options %>
</div><!-- End of display_box -->

View file

@ -18,7 +18,7 @@
</div> </div>
<div class="container"> <div class="container">
<h2><%= t('todos.completed_rest_of_month', :month_name => 'TODO') %></h2> <h2><%= t('todos.completed_rest_of_month') %></h2>
<% if @done_this_month.empty? -%> <% if @done_this_month.empty? -%>
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div> <div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
<% else -%> <% else -%>
@ -26,14 +26,6 @@
<% end -%> <% end -%>
</div> </div>
<div class="container"> <p>You can see all completed actions <%= link_to "here", all_done_todos_path %></p>
<h2><%= t('todos.completed_rest_of_previous_month', :month_name => 'TODO2') %></h2>
<% if @done_previous_month.empty? -%>
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
<% else -%>
<%= render :partial => "todos/todo", :collection => @done_previous_month, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
<% end -%>
</div>
</div><!-- End of display_box --> </div><!-- End of display_box -->

View file

@ -62,6 +62,9 @@ en:
cancel: "Cancel" cancel: "Cancel"
ok: "Ok" ok: "Ok"
add: "Add" add: "Add"
previous: "Previous"
next: "Next"
last: "Last"
project: "Project" project: "Project"
projects: "Projects" projects: "Projects"
context: "Context" context: "Context"
@ -288,6 +291,7 @@ en:
actions_in_project_title: "Actions in this project" actions_in_project_title: "Actions in this project"
notes: "Notes" notes: "Notes"
notes_empty: "There are no notes for this project" notes_empty: "There are no notes for this project"
no_last_completed_projects: "No completed projects found"
settings: "Settings" settings: "Settings"
state: "This project is %{state}" state: "This project is %{state}"
this_project: "This project" this_project: "This project"
@ -468,6 +472,7 @@ en:
no_deferred_actions_with: "No deferred actions with the tag '%{tag_name}'" no_deferred_actions_with: "No deferred actions with the tag '%{tag_name}'"
completed_actions_with: "Completed 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_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" 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: "A new todo was added which belongs to this recurring todo"
new_related_todo_created_short: "created a new 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_week: "Completed in the rest of this week"
completed_rest_of_month: "Completed in the rest of this month" completed_rest_of_month: "Completed in the rest of this month"
completed_rest_of_previous_month: "Completed in the rest of the previous 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: "Added new next action"
added_new_next_action_singular: "Added new next action" added_new_next_action_singular: "Added new next action"
added_new_next_action_plural: "Added new next actions" added_new_next_action_plural: "Added new next actions"

View file

@ -16,7 +16,7 @@ ActionController::Routing::Routes.draw do |map|
contexts.done 'contexts/done', :action => 'completed' contexts.done 'contexts/done', :action => 'completed'
end 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_" projects.resources :todos, :name_prefix => "project_"
end end
@ -28,7 +28,8 @@ ActionController::Routing::Routes.draw do |map|
map.resources :todos, map.resources :todos,
:member => {:toggle_check => :put, :toggle_star => :put}, :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| map.with_options :controller => :todos do |todos|
todos.home '', :action => "index" todos.home '', :action => "index"
@ -83,7 +84,12 @@ ActionController::Routing::Routes.draw do |map|
end end
map.preferences 'preferences', :controller => 'preferences', :action => 'index' 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.search 'search', :controller => 'search', :action => 'index'
map.data 'data', :controller => 'data', :action => 'index' map.data 'data', :controller => 'data', :action => 'index'
map.done 'done', :controller => 'todos', :action => 'completed_overview' map.done 'done', :controller => 'todos', :action => 'completed_overview'

View file

@ -721,12 +721,12 @@ li {
padding-top:10px; padding-top:10px;
font-size: 0.8em; font-size: 0.8em;
} }
.sortable_row { .sortable_row {
background: #fff; background: #fff;
_background: transparent; /* the underscore is only used by ie6 and below */ _background: transparent; /* the underscore is only used by ie6 and below */
padding: 4px 4px 4px 8px; padding: 4px 4px 4px 8px;
margin: 2px 2px; margin: 2px 2px;
border: 1px solid #ccc;
} }
.edit-form { .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 { div#list-active-projects, div#list-hidden-projects, div#list-completed-projects, div#list-contexts, div#projects-empty-nd {
clear:right; clear:right;
border: 1px solid #999;
} }
.project-state-group h2, .list-stategroup-contexts-container h2 { .project-state-group h2, .list-stategroup-contexts-container h2 {