From 37bf35f0bcba28e271789542fb8c81a6c77236b6 Mon Sep 17 00:00:00 2001 From: Felipe Artur Date: Tue, 26 Jul 2016 18:21:20 -0300 Subject: Todos sorting dropdown --- app/finders/todos_finder.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/finders') diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb index 4fe0070552e..37e919e6cf7 100644 --- a/app/finders/todos_finder.rb +++ b/app/finders/todos_finder.rb @@ -33,7 +33,7 @@ class TodosFinder # the project IDs yielded by the todos query thus far items = by_project(items) - items.reorder(id: :desc) + sort(items) end private @@ -106,6 +106,10 @@ class TodosFinder params[:type] end + def sort(items) + params[:sort] ? items.sort(params[:sort]) : items.reorder(id: :desc) + end + def by_action(items) if action? items = items.where(action: to_action_id) -- cgit v1.2.1