<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -106,6 +106,7 @@ class TodosController &lt; 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 &lt; 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') &amp;&amp; @todo.completed?
       @todo.activate!
     end
@@ -336,6 +337,7 @@ class TodosController &lt; ApplicationController
   
   # /todos/tag/[tag_name] shows all the actions tagged with tag_name
   def tag
+    @page_title = &quot;TRACKS::Tagged with \'#{@tag_name}\'&quot;
     @source_view = params['_source_view'] || 'tag'
     @tag_name = params[:name]
     
@@ -344,28 +346,33 @@ class TodosController &lt; ApplicationController
     
     @tag = Tag.find_by_name(@tag_name)
     @tag = Tag.new(:name =&gt; @tag_name) if @tag.nil?
-    
     tag_collection = @tag.todos
-    @not_done_todos = tag_collection.find(:all, :conditions =&gt; ['taggings.user_id = ? and state = ?', current_user.id, 'active'])
+    
+    @not_done_todos = tag_collection.find(:all, 
+      :conditions =&gt; ['taggings.user_id = ? and state = ?', current_user.id, 'active'],
+      :order =&gt; 'todos.completed_at DESC, todos.created_at DESC')
     @hidden_todos = current_user.todos.find(:all, 
       :include =&gt; [:taggings, :tags, :context], 
-      :conditions =&gt; ['tags.name = ? AND (todos.state = ? OR (contexts.hide = ? AND todos.state = ?))', @tag_name, 'project_hidden', true, 'active'])
+      :conditions =&gt; ['tags.name = ? AND (todos.state = ? OR (contexts.hide = ? AND todos.state = ?))', @tag_name, 'project_hidden', true, 'active'],
+      :order =&gt; 'todos.completed_at DESC, todos.created_at DESC')
+    @deferred = tag_collection.find(:all, 
+      :conditions =&gt; ['taggings.user_id = ? and state = ?', current_user.id, 'deferred'],
+      :order =&gt; '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 =&gt; max_completed, 
+      :conditions =&gt; ['taggings.user_id = ? and state = ?', current_user.id, 'completed'], 
+      :order =&gt; 'todos.completed_at DESC')
     
     @contexts = current_user.contexts.find(:all)
     @contexts_to_show = @contexts.reject {|x| x.hide? }
     
-    @deferred = tag_collection.find(:all, :conditions =&gt; ['taggings.user_id = ? and state = ?', current_user.id, 'deferred'])
-
-    @page_title = &quot;TRACKS::Tagged with \'#{@tag_name}\'&quot;
-    # 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 =&gt; max_completed, :conditions =&gt; ['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>
      <filename>app/controllers/todos_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,8 @@
 &lt;div id=&quot;error_status&quot;&gt;&lt;%= error_messages_for(&quot;todo&quot;, :object_name =&gt; 'action') %&gt;&lt;/div&gt;
 
-&lt;%= hidden_field( &quot;todo&quot;, &quot;id&quot; ) %&gt;
-&lt;%= source_view_tag( @source_view ) %&gt;
+&lt;%= hidden_field( &quot;todo&quot;, &quot;id&quot; ) -%&gt;
+&lt;%= source_view_tag( @source_view ) -%&gt;
+&lt;%= &quot;&lt;INPUT TYPE=\&quot;hidden\&quot; name=\&quot;_tag_name\&quot; value=\&quot;&quot;+ @tag_name+&quot;\&quot;&gt;&quot; unless @tag_name.nil? -%&gt;
 
 &lt;label for=&quot;&lt;%= dom_id(@todo, 'description') %&gt;&quot;&gt;Description&lt;/label&gt;
 &lt;%= text_field( &quot;todo&quot;, &quot;description&quot;, &quot;size&quot; =&gt; 30, &quot;tabindex&quot; =&gt; 8) %&gt;</diff>
      <filename>app/views/todos/_edit_form.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -6,9 +6,10 @@ if @saved
   status_message = 'Added new context / ' + status_message if @new_context_created
   page.notify :notice, status_message, 5.0
   
-  # #update auto completer arrays for context and project
+  # update auto completer arrays for context and project
   page &lt;&lt; &quot;contextAutoCompleter.options.array = #{context_names_for_autocomplete}; contextAutoCompleter.changed = true&quot; if @new_context_created
   page &lt;&lt; &quot;projectAutoCompleter.options.array = #{project_names_for_autocomplete}; projectAutoCompleter.changed = true&quot; if @new_project_created
+  
   if source_view_is_one_of(:todo, :context, :tag)
     if @context_changed || @todo.deferred?
       page[@todo].remove </diff>
      <filename>app/views/todos/update.js.rjs</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4ac09ed3ae391672f4077c0991b0bb8fc6424756</id>
    </parent>
  </parents>
  <author>
    <name>Reinier Balt</name>
    <email>lrbalt@gmail.com</email>
  </author>
  <url>http://github.com/bsag/tracks/commit/4d11e156f4228dcd405c7c87ffd52b07b3cc3be2</url>
  <id>4d11e156f4228dcd405c7c87ffd52b07b3cc3be2</id>
  <committed-date>2008-08-26T07:07:35-07:00</committed-date>
  <authored-date>2008-08-26T07:07:35-07:00</authored-date>
  <message>fix moving todos from one context to another on tag view

also fix ordening on the collections on the tag view page</message>
  <tree>309163f26970355b4ed7512a8140233a37a1e2e5</tree>
  <committer>
    <name>Reinier Balt</name>
    <email>lrbalt@gmail.com</email>
  </committer>
</commit>
