mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-22 15:14:07 +01:00
fix #999 by adding a menu to the mobile interface where you can choose the action you want to take on a todo, including deferring
This commit is contained in:
parent
174becee81
commit
5c015fea16
11 changed files with 603 additions and 523 deletions
|
|
@ -217,19 +217,20 @@ class TodosController < ApplicationController
|
|||
@tag_name = params['_tag_name']
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.m {
|
||||
@projects = current_user.projects.active
|
||||
@contexts = current_user.contexts.find(:all)
|
||||
@edit_mobile = true
|
||||
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
render :template => "/todos/edit_mobile.html.erb"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@todo = current_user.todos.find(params['id'])
|
||||
respond_to do |format|
|
||||
format.m do
|
||||
@projects = current_user.projects.active
|
||||
@contexts = current_user.contexts.find(:all)
|
||||
@edit_mobile = true
|
||||
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
render :action => 'show'
|
||||
end
|
||||
format.m { render :action => 'show' }
|
||||
format.xml { render :xml => @todo.to_xml( *to_xml_params ) }
|
||||
end
|
||||
end
|
||||
|
|
@ -316,6 +317,17 @@ class TodosController < ApplicationController
|
|||
redirect_to :action => "index"
|
||||
end
|
||||
end
|
||||
format.m {
|
||||
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
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -327,6 +339,17 @@ class TodosController < ApplicationController
|
|||
format.js
|
||||
format.xml { render :xml => @todo.to_xml( *to_xml_params ) }
|
||||
format.html { redirect_to request.referrer}
|
||||
format.m {
|
||||
if cookies[:mobile_url]
|
||||
old_path = cookies[:mobile_url]
|
||||
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
|
||||
notify(:notice, "Star toggled")
|
||||
redirect_to old_path
|
||||
else
|
||||
notify(:notice, "Star toggled")
|
||||
redirect_to todos_path(:format => 'm')
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -648,6 +671,16 @@ class TodosController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js {render :action => 'update'}
|
||||
format.m {
|
||||
notify(:notice, t("todos.action_deferred", :description => @todo.description))
|
||||
if cookies[:mobile_url]
|
||||
old_path = cookies[:mobile_url]
|
||||
cookies[:mobile_url] = {:value => nil, :secure => SITE_CONFIG['secure_cookies']}
|
||||
redirect_to old_path
|
||||
else
|
||||
redirect_to todos_path(:format => 'm')
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<% @tag_list_text = ""
|
||||
<% @tag_list_text = ""
|
||||
@tag_list_text = tag_list_text if @todo -%>
|
||||
<span class="errors">
|
||||
<%= error_messages_for("todo") %>
|
||||
</span>
|
||||
<% this_year = current_user.time.to_date.strftime("%Y").to_i
|
||||
if parent_container_type == 'show_mobile' -%>
|
||||
<% this_year = current_user.time.to_date.strftime("%Y").to_i -%>
|
||||
<% if parent_container_type == 'show_mobile' -%>
|
||||
<p><label for="todo_done"><%= t('todos.done') %></label> <%= check_box_tag("done", 1, @todo && @todo.completed?, "tabindex" => 1, "onClick" => "document.mobileEdit.submit()") %></p>
|
||||
<% end -%>
|
||||
<h2><label for="todo_description"><%= t('common.description') %></label></h2>
|
||||
|
|
@ -13,10 +13,10 @@ if parent_container_type == 'show_mobile' -%>
|
|||
<%= text_area( "todo", "notes", "cols" => 40, "rows" => 3, "tabindex" => 3) %>
|
||||
<h2><label for="todo_context_id"><%= t('common.context') %></label></h2>
|
||||
<%= unless @mobile_from_context
|
||||
collection_select( "todo", "context_id", @contexts, "id", "name", {}, {"tabindex" => 4} )
|
||||
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),
|
||||
@contexts, "id", "name", @mobile_from_context.id),
|
||||
{"id" => :todo_context_id, :tabindex => 4} )
|
||||
end %>
|
||||
<h2><label for="todo_project_id"><%= t('common.project') %></label></h2>
|
||||
|
|
@ -24,10 +24,10 @@ end %>
|
|||
collection_select( "todo", "project_id", @projects, "id", "name",
|
||||
{:include_blank => t('todos.no_project')}, {"tabindex" => 5} )
|
||||
else
|
||||
# manually add blank option since :include_blank does not work
|
||||
# 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),
|
||||
@projects, "id", "name", @mobile_from_project.id),
|
||||
{"id" => :todo_project_id, :tabindex => 5} )
|
||||
end %>
|
||||
<h2><label for="tag_list"><%= t('todos.tags') %></label></h2>
|
||||
|
|
@ -36,5 +36,5 @@ end %>
|
|||
<%= date_select("todo", "due", {:order => [:day, :month, :year],
|
||||
:start_year => this_year, :include_blank => '--'}, :tabindex => 7) %>
|
||||
<h2><label for="todo_show_from"><%= t('todos.show_from') %></label></h2>
|
||||
<%= date_select("todo", "show_from", {:order => [:day, :month, :year],
|
||||
<%= date_select("todo", "show_from", {:order => [:day, :month, :year],
|
||||
:start_year => this_year, :include_blank => true}, :tabindex => 8) %>
|
||||
5
app/views/todos/edit_mobile.html.erb
Normal file
5
app/views/todos/edit_mobile.html.erb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<% form_tag todo_path(@todo, :format => 'm'), :name => 'mobileEdit', :method => :put do %>
|
||||
<%= render :partial => 'edit_mobile_form', :locals => { :parent_container_type => "show_mobile" } %>
|
||||
<p><input type="submit" value="<%= t('common.update') %>" tabindex="6" accesskey="#" /></p>
|
||||
<% end -%>
|
||||
<%= link_to t('common.cancel'), @return_path %>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<% form_tag todos_path(:format => 'm'), :method => :post do %>
|
||||
<%= render :partial => 'edit_mobile' %>
|
||||
<%= render :partial => 'edit_mobile_form' %>
|
||||
<p><input type="submit" value="<%= t('common.create') %>" tabindex="12" accesskey="#" /></p>
|
||||
<% end -%>
|
||||
<%= link_to t('common.back'), @return_path %>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,29 @@
|
|||
<% form_tag todo_path(@todo, :format => 'm'), :name => 'mobileEdit', :method => :put do %>
|
||||
<%= render :partial => 'edit_mobile', :locals => { :parent_container_type => "show_mobile" } %>
|
||||
<p><input type="submit" value="<%= t('common.update') %>" tabindex="6" accesskey="#" /></p>
|
||||
<% end -%>
|
||||
<%= link_to t('common.cancel'), @return_path %>
|
||||
<h2>Description</h2>
|
||||
<%= @todo.description %><br/>
|
||||
|
||||
<h2>Actions</h2>
|
||||
|
||||
<form method="get" action="<%= edit_todo_path(@todo, :format => :m)%>">
|
||||
<button>Edit this action</button>
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
</form><br/>
|
||||
|
||||
<form method="post" action="<%=toggle_star_todo_path(@todo, :format=>:m)%>">
|
||||
<button>Toggle Star</button>
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
</form><br/>
|
||||
|
||||
<form method="post" action="<%=toggle_check_todo_path(@todo, :format=>:m)%>">
|
||||
<button>Mark complete</button>
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
</form><br/>
|
||||
|
||||
<form method="post" action="<%=defer_todo_path(@todo, :format=>:m, :days => 1)%>">
|
||||
<button>Defer 1 day</button>
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
</form><br/>
|
||||
|
||||
<form method="post" action="<%=defer_todo_path(@todo, :format=>:m, :days => 7)%>">
|
||||
<button>Defer 7 days</button>
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
</form><br/>
|
||||
Loading…
Add table
Add a link
Reference in a new issue