diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 3dddc2bd..0ce52b51 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -106,6 +106,7 @@ class TodosController < ApplicationController @projects = current_user.projects.find(:all) @contexts = current_user.contexts.find(:all) @source_view = params['_source_view'] || 'todo' + @tag_name = params['_tag_name'] respond_to do |format| format.js end @@ -212,7 +213,7 @@ class TodosController < ApplicationController @todo.complete! end # strange. if checkbox is not checked, there is no 'done' in params. - # Therfore I've used the negation + # Therefore I've used the negation if !(params['done'] == '1') && @todo.completed? @todo.activate! end @@ -336,6 +337,7 @@ class TodosController < ApplicationController # /todos/tag/[tag_name] shows all the actions tagged with tag_name def tag + @page_title = "TRACKS::Tagged with \'#{@tag_name}\'" @source_view = params['_source_view'] || 'tag' @tag_name = params[:name] @@ -344,28 +346,33 @@ class TodosController < ApplicationController @tag = Tag.find_by_name(@tag_name) @tag = Tag.new(:name => @tag_name) if @tag.nil? - tag_collection = @tag.todos - @not_done_todos = tag_collection.find(:all, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'active']) + + @not_done_todos = tag_collection.find(:all, + :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'active'], + :order => 'todos.completed_at DESC, todos.created_at DESC') @hidden_todos = current_user.todos.find(:all, :include => [:taggings, :tags, :context], - :conditions => ['tags.name = ? AND (todos.state = ? OR (contexts.hide = ? AND todos.state = ?))', @tag_name, 'project_hidden', true, 'active']) + :conditions => ['tags.name = ? AND (todos.state = ? OR (contexts.hide = ? AND todos.state = ?))', @tag_name, 'project_hidden', true, 'active'], + :order => 'todos.completed_at DESC, todos.created_at DESC') + @deferred = tag_collection.find(:all, + :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'deferred'], + :order => 'show_from ASC, todos.created_at DESC') + # If you've set no_completed to zero, the completed items box isn't shown on + # the tag page + max_completed = current_user.prefs.show_number_completed + @done = tag_collection.find(:all, + :limit => max_completed, + :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'completed'], + :order => 'todos.completed_at DESC') @contexts = current_user.contexts.find(:all) @contexts_to_show = @contexts.reject {|x| x.hide? } - @deferred = tag_collection.find(:all, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'deferred']) - - @page_title = "TRACKS::Tagged with \'#{@tag_name}\'" - # If you've set no_completed to zero, the completed items box isn't shown on - # the home page - max_completed = current_user.prefs.show_number_completed - @done = tag_collection.find(:all, :limit => max_completed, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'completed']) # Set count badge to number of items with this tag @not_done_todos.empty? ? @count = 0 : @count = @not_done_todos.size @down_count = @count - # @default_project_context_name_map = - # build_default_project_context_name_map(@projects).to_json + respond_to do |format| format.html { @default_project_context_name_map = build_default_project_context_name_map(@projects).to_json diff --git a/app/views/todos/_edit_form.rhtml b/app/views/todos/_edit_form.rhtml index 1807504f..b504f695 100644 --- a/app/views/todos/_edit_form.rhtml +++ b/app/views/todos/_edit_form.rhtml @@ -1,7 +1,8 @@