fixes for mobile view and for recurring todos

* fixed redirect to last page instead of /mobile after adding a new todo using mobile interface
* fixed adding new todo to tickler instead of home after marking a todo belonging an active recurring todo complete
This commit is contained in:
Reinier Balt 2008-08-04 16:13:51 +02:00
parent c6dc3fcd5b
commit db86df5497
7 changed files with 341 additions and 316 deletions

View file

@ -144,6 +144,7 @@ class ContextsController < ApplicationController
@not_done = @not_done_todos.select {|t| t.context_id == @context.id }
@down_count = @not_done.size
cookies[:mobile_url]=request.request_uri
@mobile_from_context = @context.id
render :action => 'mobile_show_context'
end
end

View file

@ -218,6 +218,7 @@ class ProjectsController < ApplicationController
@project.default_context.name
end
cookies[:mobile_url]=request.request_uri
@mobile_from_project = @project.id
render :action => 'project_mobile'
end
end

View file

@ -33,6 +33,12 @@ class TodosController < ApplicationController
format.m {
@new_mobile = true
@return_path=cookies[:mobile_url]
@mobile_from_context = current_user.contexts.find_by_id(params[:from_context]) if params[:from_context]
@mobile_from_project = current_user.projects.find_by_id(params[:from_project]) if params[:from_project]
if params[:from_project] && !params[:from_context]
# we have a project but not a context -> use the default context
@mobile_from_context = @mobile_from_project.default_context
end
render :action => "new"
}
end
@ -71,7 +77,7 @@ class TodosController < ApplicationController
# todo: use function for this fixed path
@return_path='/mobile' if @return_path.nil?
if @saved
redirect_to mobile_abbrev_url
redirect_to @return_path
else
@projects = current_user.projects.find(:all)
@contexts = current_user.contexts.find(:all)

View file

@ -114,11 +114,10 @@ module TodosHelper
tags_except_starred = @todo.tags.reject{|t| t.name == Todo::STARRED_TAG_NAME}
# removed the link. TODO: add link to mobile view of tagged actions
tag_list = tags_except_starred.collect{|t|
"<span class=\"tag #{t.name.gsub(' ','-')}\">" +
"<span class=\"tag\">" +
link_to(t.name, {:action => "tag", :controller => "todos", :id => t.name+".m"}) +
# link_to(t.name, formatted_tag_path(t, :m)) +
"</span>"}.join('')
"<span class='tags'>#{tag_list}</span>"
"<span class=\"tags\">#{tag_list}</span>"
end
def deferred_due_date

View file

@ -1,4 +1,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
new_todo_params = {}
new_todo_params[:from_project] = @mobile_from_project if @mobile_from_project
new_todo_params[:from_context] = @mobile_from_context if @mobile_from_context
-%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@ -10,7 +14,7 @@
if !@prefs.nil? -%>
<h1><span class="count"><%= @down_count %></span> <%=
user_time.strftime(@prefs.title_date_format) -%></h1>
<%= (link_to("0-Add new action", formatted_new_todo_path(:m))+" | ") unless @new_mobile -%>
<%= (link_to("0-Add new action", formatted_new_todo_path(:m, new_todo_params))+" | ") unless @new_mobile -%>
<%= (link_to("1-Home", formatted_todos_path(:m))+" | ") unless @home -%>
<%= (link_to("2-Contexts", formatted_contexts_path(:m))+" | ") -%>
<%= (link_to("3-Projects", formatted_projects_path(:m))+" | ") -%>

View file

@ -12,10 +12,24 @@ if parent_container_type == 'show_mobile' -%>
<h2><label for="todo_notes">Notes</label></h2>
<%= text_area( "todo", "notes", "cols" => 30, "rows" => 5, "tabindex" => 3) %>
<h2><label for="todo_context_id">Context</label></h2>
<%= collection_select( "todo", "context_id", @contexts, "id", "name", {"tabindex" => 4} ) %>
<%= unless @mobile_from_context
collection_select( "todo", "context_id", @contexts, "id", "name", {}, {"tabindex" => 4} )
else
select_tag("todo[context_id]", options_from_collection_for_select(
@contexts, "id", "name", @mobile_from_context.id),
{"id" => :todo_context_id, :tabindex => 4} )
end %>
<h2><label for="todo_project_id">Project</label></h2>
<%= collection_select( "todo", "project_id", @projects, "id", "name",
{:include_blank => true}, {"tabindex" => 5} ) %>
<%= unless @mobile_from_project
collection_select( "todo", "project_id", @projects, "id", "name",
{:include_blank => true}, {"tabindex" => 5} )
else
# manually add blank option since :include_blank does not work
# with options_from_collection_for_select
select_tag("todo[project_id]", "<option value=\"\"></option>"+options_from_collection_for_select(
@projects, "id", "name", @mobile_from_project.id),
{"id" => :todo_project_id, :tabindex => 5} )
end %>
<h2><label for="tag_list">Tags (separate with commas)</label></h2>
<%= text_field_tag "tag_list", @tag_list_text, :size => 30, :tabindex => 6 %>
<h2><label for="todo_due">Due</label></h2>

View file

@ -17,12 +17,12 @@ if @saved
end
# show new todo if the completed todo was recurring
unless @new_recurring_todo.nil?
unless @new_recurring_todo.nil? || @new_recurring_todo.deferred?
page.call "todoItems.ensureVisibleWithEffectAppear", item_container_id(@new_recurring_todo)
page.insert_html :bottom, item_container_id(@new_recurring_todo), :partial => 'todos/todo', :locals => { :todo => @new_recurring_todo, :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(@new_recurring_todo, 'line'), {'startcolor' => "'#99ff99'"}
else
page.notify :notice, "There is no next action after the recurring action you just finished. The recurrence is completed", 6.0 unless @recurring_todo.nil?
page.notify :notice, "There is no next action after the recurring action you just finished. The recurrence is completed", 6.0 unless @new_recurring_todo.deferred?
end
else