From bbbb3a18860bac6a1bae9bf32537792c9d963617 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Sun, 20 Dec 2009 13:36:05 -0500 Subject: [PATCH] First whack at "promote to project" function Progress on issue #64 --- app/controllers/todos_controller.rb | 9 +++++++++ app/helpers/todos_helper.rb | 8 ++++++++ app/views/todos/_todo.html.erb | 1 + 3 files changed, 18 insertions(+) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 4589e7c8..fc928a03 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -638,6 +638,15 @@ class TodosController < ApplicationController end render :inline => "<%= auto_complete_result2(@items) %>" end + + def convert_to_project + @todo = Todo.find(params[:id]) + @project = Project.new(:name => @todo.description, :description => @todo.notes, + :default_context => @todo.context) + @todo.destroy + @project.save! + redirect_to project_url(@project) + end private diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 074be7d5..150ac9b9 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -64,6 +64,14 @@ module TodosHelper :complete => todo_stop_waiting_js(todo)) end end + + def remote_promote_to_project_menu_item(todo) + url = {:controller => 'todos', :action => 'convert_to_project', :id => todo.id, + :_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")} + url[:_tag_name] = @tag_name if @source_view == 'tag' + + return link_to("Promote to project", url) + end def todo_start_waiting_js(todo) return "$('#ul#{dom_id(todo)}').css('visibility', 'hidden'); $('##{dom_id(todo)}').block({message: null})" diff --git a/app/views/todos/_todo.html.erb b/app/views/todos/_todo.html.erb index 8a042ae6..579ea766 100644 --- a/app/views/todos/_todo.html.erb +++ b/app/views/todos/_todo.html.erb @@ -22,6 +22,7 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
  • <%= remote_defer_menu_item(1, todo) %>
  • <%= remote_defer_menu_item(7, todo) %>
  • <% end %> +
  • <%= remote_promote_to_project_menu_item(todo) %>