mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-18 07:05:28 +01:00
fix #1195. Update all autocompleters for more sane order of returned items
This commit is contained in:
parent
d2d229c23a
commit
033afda0e1
3 changed files with 46 additions and 31 deletions
|
|
@ -31,7 +31,7 @@ class ContextsController < ApplicationController
|
|||
@all_contexts = current_user.contexts.all
|
||||
render :action => 'index', :layout => false, :content_type => Mime::TEXT
|
||||
end
|
||||
format.autocomplete { render :text => for_autocomplete(@active_contexts + @hidden_contexts, params[:term])}
|
||||
format.autocomplete &render_autocomplete
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -248,6 +248,15 @@ class ContextsController < ApplicationController
|
|||
:author => lambda { |c| nil } }
|
||||
end
|
||||
end
|
||||
|
||||
def render_autocomplete
|
||||
lambda do
|
||||
# first get active contexts with todos then those without
|
||||
filled_contexts = @active_contexts.reject { |ctx| ctx.todos.count == 0 } + @hidden_contexts.reject { |ctx| ctx.todos.count == 0 }
|
||||
empty_contexts = @active_contexts.find_all { |ctx| ctx.todos.count == 0 } + @hidden_contexts.find_all { |ctx| ctx.todos.count == 0 }
|
||||
render :text => for_autocomplete(filled_contexts + empty_contexts, params[:term])
|
||||
end
|
||||
end
|
||||
|
||||
def feed_options
|
||||
Context.feed_options(current_user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue