Merge branch 'master' into new-gui

Conflicts:
	Gemfile.lock
	app/assets/stylesheets/tracks.css.scss
	app/controllers/todos_controller.rb
	app/services/rich_message_extractor.rb
	app/services/todo_from_rich_message.rb
	app/views/todos/all_done.html.erb
	config/initializers/rack-mini-profiler.rb
	test/models/rich_message_extractor_test.rb
	test/models/todo_from_rich_message_test.rb
This commit is contained in:
Reinier Balt 2014-03-06 10:31:39 +01:00
commit 899df1ef8f
33 changed files with 1487 additions and 1313 deletions

View file

@ -211,4 +211,4 @@ form#todo-form-new-action {
div.hide_me {
display: none;
}
}

View file

@ -269,7 +269,7 @@ class ApplicationController < ActionController::Base
def all_done_todos_for(object)
object_name = object.class.name.downcase # context or project
@source_view = object_name
@source_view = "all_done"
@page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name)
@done = object.todos.completed.reorder('completed_at DESC').includes(Todo::DEFAULT_INCLUDES).
@ -280,11 +280,11 @@ class ApplicationController < ActionController::Base
def done_todos_for(object)
object_name = object.class.name.downcase # context or project
@source_view = object_name
@source_view = "done"
eval("@#{object_name} = object")
@page_title = t("#{object_name.pluralize}.completed_tasks_title", "#{object_name}_name".to_sym => object.name)
@done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(object)
@done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(object.todos)
@count = @done_today.size + @done_rest_of_week.size + @done_rest_of_month.size
render :template => 'todos/done'

View file

@ -524,7 +524,7 @@ class TodosController < ApplicationController
@source_view = 'done'
@page_title = t('todos.completed_tasks_title')
@done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(current_user)
@done_today, @done_rest_of_week, @done_rest_of_month = DoneTodos.done_todos_for_container(current_user.todos)
@count = @done_today.size + @done_rest_of_week.size + @done_rest_of_month.size
respond_to do |format|
@ -678,7 +678,7 @@ class TodosController < ApplicationController
end
def done_by_tag_setup
@source_view = params['_source_view'] || 'tag'
@source_view = params['_source_view'] || 'done'
@tag_name = sanitize(params[:name]) # sanitize to prevent XSS vunerability!
@page_title = t('todos.all_completed_tagged_page_title', :tag_name => @tag_name)
@tag = Tag.where(:name => @tag_name).first_or_create
@ -769,7 +769,11 @@ class TodosController < ApplicationController
@items = get_not_completed_for_predecessor(current_user, @todo.id) unless !@items.empty?
else
# New todo - TODO: Filter on current project in project view
<<<<<<< HEAD
@items = get_not_complete_for_predecessor(current_user)
=======
@items = get_not_completed_for_predecessor(current_user)
>>>>>>> master
end
render :inline => format_dependencies_as_json_for_auto_complete(@items)
end
@ -1010,7 +1014,10 @@ end
@target_context_count = actions_in_target.count
}
from.done {
@remaining_in_context = DoneTodos.remaining_in_container(current_user, @original_completed_period)
@remaining_in_context = DoneTodos.remaining_in_container(current_user.todos, @original_completed_period)
}
from.all_done {
@remaining_in_context = current_user.todos.completed.count
}
end
end
@ -1271,18 +1278,18 @@ end
completed_todos.completed_after(start_of_this_day).includes(includes[:include])
end
def get_done_in_period(before, after, includes = {:include => Todo::DEFAULT_INCLUDES})
def get_done_in_period(completed_todos, before, after, includes = {:include => Todo::DEFAULT_INCLUDES})
completed_todos.completed_before(before).completed_after(after).includes(includes[:include])
end
# all completed todos [begin_of_week, start_of_today]
def get_done_rest_of_week(completed_todos, includes = {:include => Todo::DEFAULT_INCLUDES})
get_done_in_period(Time.zone.now.beginning_of_day, Time.zone.now.beginning_of_week)
get_done_in_period(completed_todos, Time.zone.now.beginning_of_day, Time.zone.now.beginning_of_week)
end
# all completed todos [begin_of_month, begin_of_week]
def get_done_rest_of_month(completed_todos, includes = {:include => Todo::DEFAULT_INCLUDES})
get_done_in_period(Time.zone.now.beginning_of_week, Time.zone.now.beginning_of_month)
get_done_in_period(completed_todos, Time.zone.now.beginning_of_week, Time.zone.now.beginning_of_month)
end
def get_not_done_todos

View file

@ -230,7 +230,7 @@ module ApplicationHelper
when "projects"
send("#{type}_todos_project_path", @project)
when "todos"
if source_view_is(:tag)
if @tag_name
send("#{type}_tag_path",@tag_name)
else
send("#{type}_todos_path")

View file

@ -513,7 +513,7 @@ module TodosHelper
)
end
return false if source_view_is_one_of(:calendar, :done)
return false if source_view_is_one_of(:calendar, :done, :all_done)
return @remaining_in_context == 0
end
@ -682,6 +682,7 @@ module TodosHelper
}
page.todo { container_id = context_container_empty_id(@original_item) if @remaining_in_context == 0 }
page.done { container_id = "completed_#{@original_completed_period}_container-empty-d" if @remaining_in_context == 0 }
page.all_done { container_id = "all-done-empty-nd" if @remaining_in_context == 0 }
end
return container_id.blank? ? "" : "$(\"##{container_id}\").slideDown(100);".html_safe
end

View file

@ -51,12 +51,12 @@ class RichMessageExtractor
def due
due = select_for DUE_MARKER
due.blank? ? nil : Date.parse(due[1].strip)
due.blank? ? nil : Time.zone.parse(fix_date_string(due[1].strip))
end
def show_from
show_from = select_for TICKLER_MARKER
show_from.blank? ? nil : Date.parse(show_from[1].strip)
show_from.blank? ? nil : Time.zone.parse(fix_date_string(show_from[1].strip))
end
def starred?
@ -69,4 +69,8 @@ class RichMessageExtractor
@message.match /#{symbol}(.*?)(?=[#{ALL_MARKERS.join}]|\Z)/
end
def fix_date_string yymmdd
"20#{yymmdd[0..1]}-#{yymmdd[2..3]}-#{yymmdd[4..5]} 00:00"
end
end

View file

@ -48,8 +48,8 @@ class TodoFromRichMessage
todo.raw_notes = notes
todo.context_id = context_id
todo.project_id = project_id unless project_id.nil?
todo.show_from = show_from if show_from.is_a? Date
todo.due = due if due.is_a? Date
todo.show_from = show_from if show_from.is_a? Time
todo.due = due if due.is_a? Time
todo.tag_with tags unless tags.nil? || tags.empty?
todo.starred = star
todo

View file

@ -7,6 +7,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, user-scalable=no">
<%= stylesheet_link_tag "mobile", :media => 'handheld,all' %>
<%= favicon_link_tag 'favicon.ico' %>

View file

@ -21,4 +21,4 @@
<%= render :partial => "todos/todo", :collection => @done, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
<% end -%>
<div class="paginate_footer"><%= will_paginate @done, paginate_options %></div>
<div class="paginate_footer"><%= will_paginate @done, paginate_options %></div>