Bug #300: Actions can be created with dependencies through the add_new_item_form

Still lacks error checking for circular dependencies and other validation.
Also, javascript for displaying the new item is broken.

Conflicts:

	app/views/layouts/standard.html.erb
This commit is contained in:
Eric Allen 2009-11-04 22:45:38 -05:00
parent 6d97bca57f
commit 1f556a4f0a
3 changed files with 53 additions and 19 deletions

View file

@ -54,6 +54,7 @@ class TodosController < ApplicationController
p = TodoCreateParamsHelper.new(params, prefs)
p.parse_dates() unless mobile?
tag_list = p.tag_list
predecessor_list = p.predecessor_list
@todo = current_user.todos.build(p.attributes)
@ -77,6 +78,14 @@ class TodosController < ApplicationController
@todo.tags.reload
end
unless predecessor_list.blank?
@todo.add_predecessor_list(predecessor_list)
unless @todo.uncompleted_predecessors.empty? || @todo.state == 'project_hidden'
@todo.state = 'pending'
end
@saved = @todo.save
end
respond_to do |format|
format.html { redirect_to :action => "index" }
format.m do
@ -559,20 +568,29 @@ class TodosController < ApplicationController
end
def auto_complete_for_predecessor
get_todo_from_params
# Begin matching todos in current project
@items = current_user.todos.find(:all,
:conditions => [ 'NOT (id = ?) AND description LIKE ? AND project_id = ?',
@todo.id,
'%' + params[:predecessor_list] + '%',
@todo.project_id ],
:order => 'description ASC',
:limit => 10
)
if @items.empty? # Match todos in other projects
unless params['id'].nil?
get_todo_from_params
# Begin matching todos in current project
@items = current_user.todos.find(:all,
:conditions => [ 'NOT (id = ?) AND description LIKE ?',
params[:id], '%' + params[:predecessor_list] + '%' ],
:conditions => [ 'NOT (id = ?) AND description LIKE ? AND project_id = ?',
@todo.id,
'%' + params[:predecessor_list] + '%',
@todo.project_id ],
:order => 'description ASC',
:limit => 10
)
if @items.empty? # Match todos in other projects
@items = current_user.todos.find(:all,
:conditions => [ 'NOT (id = ?) AND description LIKE ?',
params[:id], '%' + params[:predecessor_list] + '%' ],
:order => 'description ASC',
:limit => 10
)
end
else
# New todo - TODO: Filter on project
@items = current_user.todos.find(:all,
:conditions => [ 'description LIKE ?', '%' + params[:predecessor_list] + '%' ],
:order => 'description ASC',
:limit => 10
)
@ -1023,6 +1041,10 @@ class TodosController < ApplicationController
def tag_list
@params['tag_list']
end
def predecessor_list
@params['predecessor_list']
end
def parse_dates()
@attributes['show_from'] = @prefs.parse_date(show_from)