changes for done checkbox on mobile page

adding recent completed todos in case you accidentally tick one by mistake
This commit is contained in:
tim madden 2011-07-18 17:37:11 -05:00 committed by tim madden
parent beb18ac1f4
commit d0e7264661
8 changed files with 74 additions and 16 deletions

View file

@ -361,6 +361,49 @@ class TodosController < ApplicationController
end
end
def mobile_done
# copied from toggle_check, left out other formats as they shouldn't come here
# ultimately would like to just use toggle_check
@todo = current_user.todos.find(params['id'])
@source_view = params['_source_view'] || 'todo'
@original_item_due = @todo.due
@original_item_was_deferred = @todo.deferred?
@original_item_was_pending = @todo.pending?
@original_item_was_hidden = @todo.hidden?
@original_item_context_id = @todo.context_id
@original_item_project_id = @todo.project_id
@todo_was_completed_from_deferred_or_blocked_state = @original_item_was_deferred || @original_item_was_pending
@saved = @todo.toggle_completion!
@todo_was_blocked_from_completed_state = @todo.pending? # since we toggled_completion the previous state was completed
# check if this todo has a related recurring_todo. If so, create next todo
@new_recurring_todo = check_for_next_todo(@todo) if @saved
@predecessors = @todo.uncompleted_predecessors
if @saved
if @todo.completed?
@pending_to_activate = @todo.activate_pending_todos
else
@active_to_block = @todo.block_successors
end
end
if @saved
if cookies[:mobile_url]
old_path = cookies[:mobile_url]
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
notify(:notice, t("todos.action_marked_complete", :description => @todo.description, :completed => @todo.completed? ? 'complete' : 'incomplete'))
redirect_to old_path
else
notify(:notice, t("todos.action_marked_complete", :description => @todo.description, :completed => @todo.completed? ? 'complete' : 'incomplete'))
redirect_to todos_path(:format => 'm')
end
else
render :action => "edit", :format => :m
end
end
def toggle_star
@todo = current_user.todos.find(params['id'])
@todo.toggle_star!
@ -1176,6 +1219,10 @@ class TodosController < ApplicationController
lambda do
@page_title = t('todos.mobile_todos_page_title')
@home = true
max_completed = current_user.prefs.show_number_completed
@done = current_user.todos.completed.find(:all, :limit => max_completed, :include => Todo::DEFAULT_INCLUDES) unless max_completed == 0
cookies[:mobile_url]= { :value => request.request_uri, :secure => SITE_CONFIG['secure_cookies']}
determine_down_count

View file

@ -89,6 +89,12 @@ module TodosHelper
:title => todo.pending? ? t('todos.blocked_by', :predecessors => todo.uncompleted_predecessors.map(&:description).join(', ')) : "", :readonly => todo.pending?)
end
def remote_mobile_checkbox(todo=@todo)
form_tag mobile_done_todo_path(@todo, :format => 'm'), :method => :put, :class => "mobile-done", :name => "mobile_complete_#{@todo.id}" do
check_box_tag('_source_view', 'todo', @todo && @todo.completed?, "onClick" => "document.mobile_complete_#{@todo.id}.submit()")
end
end
def date_span(todo=@todo)
if todo.completed?
content_tag(:span, {:class => :grey}) { format_date( todo.completed_at ) }

View file

@ -4,6 +4,7 @@
<% unless @project.description.blank? -%>
<div class="project_description"><%= sanitize(@project.description) %></div>
<% end -%>
<ul class="c">
<%= render :partial => "todos/mobile_todo", :collection => @not_done, :locals => { :parent_container_type => "project" }%>
<h2><%= t('projects.deferred_actions')%></h2>
<% if @deferred.empty? -%>
@ -24,4 +25,4 @@
<% else -%><%= render :partial => "notes/mobile_notes_summary", :collection => @project.notes %>
<% end -%>
<h2><%= t('projects.settings') %></h2>
<%= t('projects.state', :state => project.aasm_current_state.to_s) %>. <%= @project_default_context %>
<%= t('projects.state', :state => project.aasm_current_state.to_s) %>. <%= @project_default_context %>

View file

@ -2,4 +2,8 @@
<p><%= t('todos.no_incomplete_actions') %></p>
<% else -%>
<%= render :partial => "contexts/mobile_context", :collection => @contexts_to_show -%>
<% end -%>
<% end -%>
<% unless @done.nil? -%>
<h2><%= t('todos.completed_actions') %></h2>
<%= render :partial => "todos/mobile_todo", :collection => @done %>
<% end %>

View file

@ -1,21 +1,18 @@
<% @todo = mobile_todo
if mobile_todo.starred?
bullet = "<span class=\"star\">"+image_tag("menustar_small.gif")+"</span>"
li_class = " class=\"star\""
else
bullet = "<span class=\"r\">&raquo;&nbsp;</span>"
li_class = ""
end -%>
<li id="<%= dom_id(mobile_todo) %>" <%= li_class %>><%= bullet %><%
<% @todo = mobile_todo -%>
<li id="<%= dom_id(mobile_todo) %>" ><%
if mobile_todo.completed?
-%><span class="m_t_d">
<% else
-%><span class="m_t">
<% end -%>
<% remote_mobile_checkbox(mobile_todo) %>
<%= date_span -%> <%= link_to mobile_todo.description, todo_path(mobile_todo, :format => 'm') -%>
<% unless mobile_todo.notes.blank? %>
<%= link_to(image_tag("mobile_notes.png", :border => "0"), mobile_todo_show_notes_path(mobile_todo, :format => 'm')) -%>
<% end %>
<% if mobile_todo.starred? %>
<%= image_tag("menustar_small.gif", :border => "0") -%>
<% end %>
<% if parent_container_type == 'context' or parent_container_type == 'tag' -%>
<%= "<span class=\"prj\"> (" +
link_to(mobile_todo.project.name, project_path(mobile_todo.project, :format => 'm')) +

View file

@ -2,4 +2,4 @@
<%= link_to @todo.description, todo_path(@todo, :format => 'm') -%>
<h2><%= t('todos.notes') %></h2>
<%= format_note(@todo.notes) %>
<%= link_to t('common.back'), @return_path %>
<%= link_to t('common.back'), @return_path %>

View file

@ -25,7 +25,7 @@ ActionController::Routing::Routes.draw do |map|
map.resources :notes
map.resources :todos,
:member => {:toggle_check => :put, :toggle_star => :put, :defer => :put},
:member => {:toggle_check => :put, :toggle_star => :put, :defer => :put, :mobile_done => :put},
:collection => {:check_deferred => :post, :filter_to_context => :post, :filter_to_project => :post, :done => :get, :all_done => :get
}

View file

@ -126,14 +126,14 @@ span.prj, span.ctx{
background: #FFC2C2;
}
ul.c li.star {
list-style-type: circle;
ul.c li {
list-style-type: none;
}
ul.c {
padding: 0;
margin: 0;
padding-left: 1.1em;
padding-left: 0.1em;
}
ul.c li {
@ -160,3 +160,6 @@ span.r {
table.c {
margin-left: 5px;
}
.mobile-done {
display:inline;
}