From 539fda21dcefcf90a69f5cbbe1ed1dafb3a807f8 Mon Sep 17 00:00:00 2001 From: epall Date: Mon, 16 Jun 2008 22:37:44 -0700 Subject: [PATCH] Preliminary defer buttons --- app/controllers/todos_controller.rb | 16 +++++++++++++++- app/helpers/todos_helper.rb | 4 ++++ app/views/todos/_todo.html.erb | 1 + public/stylesheets/standard.css | 6 +++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index ac0c251a..d4f95738 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -384,7 +384,21 @@ class TodosController < ApplicationController end end - private + def defer + @source_view = params['_source_view'] || 'todo' + numdays = params['days'].to_i + @todo = Todo.find(params[:id]) + @todo.show_from = (@todo.show_from || Time.now.to_date) + numdays.days + @saved = @todo.save + + respond_to do |format| + format.html { redirect_to :back } + format.js {render :action => 'update'} + end + end + + + private def get_todo_from_params @todo = current_user.todos.find(params['id']) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index ec70762e..662c3d25 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -280,4 +280,8 @@ module TodosHelper image_tag("blank.png", :title =>"Star action", :class => class_str) end + def defer_link(days) + link_to_remote "+#{days}", :url => {:controller => 'todos', :action => 'defer', :id => @todo.id, :days => days, :_source_view => @source_view.underscore.gsub(/\s+/,'_')} + end + end diff --git a/app/views/todos/_todo.html.erb b/app/views/todos/_todo.html.erb index c03e64e6..8a4f70c2 100644 --- a/app/views/todos/_todo.html.erb +++ b/app/views/todos/_todo.html.erb @@ -18,6 +18,7 @@ <%= deferred_due_date %> <%= project_and_context_links( parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %> <%= render(:partial => "todos/toggle_notes", :locals => { :item => todo }) if todo.notes? %> + <%= defer_link(1) %> <%= defer_link(7) %>