mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-29 20:26:11 +01:00
Ticket #923: Filtering on active or pending todos in pred. auto completer.
Conflicts: app/controllers/todos_controller.rb
This commit is contained in:
parent
c543eb3659
commit
1f45497a52
1 changed files with 13 additions and 9 deletions
|
|
@ -305,8 +305,6 @@ class TodosController < ApplicationController
|
|||
@todo.save!
|
||||
end
|
||||
|
||||
|
||||
|
||||
@context_changed = @original_item_context_id != @todo.context_id
|
||||
@todo_was_activated_from_deferred_state = @original_item_was_deferred && @todo.active?
|
||||
|
||||
|
|
@ -601,17 +599,21 @@ class TodosController < ApplicationController
|
|||
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 ],
|
||||
:conditions => [ '(todos.state = ? OR todos.state = ?) AND ' +
|
||||
'NOT (id = ?) AND lower(description) LIKE ? AND project_id = ?',
|
||||
'active', 'pending',
|
||||
@todo.id,
|
||||
'%' + params[:predecessor_list].downcase + '%',
|
||||
@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] + '%' ],
|
||||
:conditions => [ '(todos.state = ? OR todos.state = ?) AND ' +
|
||||
'NOT (id = ?) AND lower(description) LIKE ?',
|
||||
'active', 'pending',
|
||||
params[:id], '%' + params[:predecessor_list].downcase + '%' ],
|
||||
:order => 'description ASC',
|
||||
:limit => 10
|
||||
)
|
||||
|
|
@ -619,7 +621,9 @@ class TodosController < ApplicationController
|
|||
else
|
||||
# New todo - TODO: Filter on project
|
||||
@items = current_user.todos.find(:all,
|
||||
:conditions => [ 'description LIKE ?', '%' + params[:predecessor_list] + '%' ],
|
||||
:conditions => [ '(todos.state = ? OR todos.state = ?) AND lower(description) LIKE ?',
|
||||
'active', 'pending',
|
||||
'%' + params[:predecessor_list].downcase + '%' ],
|
||||
:order => 'description ASC',
|
||||
:limit => 10
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue