First whack at "promote to project" function

Progress on issue #64
This commit is contained in:
Eric Allen 2009-12-20 13:36:05 -05:00
parent ce3897a2bd
commit bbbb3a1886
3 changed files with 18 additions and 0 deletions

View file

@ -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

View file

@ -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})"

View file

@ -22,6 +22,7 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
<li><%= remote_defer_menu_item(1, todo) %></li>
<li><%= remote_defer_menu_item(7, todo) %></li>
<% end %>
<li><%= remote_promote_to_project_menu_item(todo) %></li>
</ul>
</li>
</ul>