9587: sort the trash page rows by trash_at timestamp
authorradhika <radhika@curoverse.com>
Tue, 6 Jun 2017 00:40:46 +0000 (20:40 -0400)
committerradhika <radhika@curoverse.com>
Tue, 6 Jun 2017 00:40:46 +0000 (20:40 -0400)
apps/workbench/app/controllers/trash_items_controller.rb
apps/workbench/app/views/trash_items/_show_recent.html.erb
apps/workbench/app/views/trash_items/_show_trash_rows.html.erb

index 31581bb8461f37d618674cfa535e296fc51bffee..7d60f50f1c5b0af27267a425c43228f3e0864f1d 100644 (file)
@@ -16,7 +16,7 @@ class TrashItemsController < ApplicationController
     trashed_items
 
     if @objects.any?
-      @objects = @objects.sort_by { |obj| obj.created_at }.reverse
+      @objects = @objects.sort_by { |obj| obj.trash_at }.reverse
       @next_page_filters = next_page_filters('<=')
       @next_page_href = url_for(partial: :trash_rows,
                                 filters: @next_page_filters.to_json)
@@ -29,6 +29,27 @@ class TrashItemsController < ApplicationController
     @next_page_href
   end
 
+  def next_page_filters nextpage_operator
+    next_page_filters = @filters.reject do |attr, op, val|
+      (attr == 'trash_at' and op == nextpage_operator) or
+      (attr == 'uuid' and op == 'not in')
+    end
+
+    if @objects.any?
+      last_trash_at = @objects.last.trash_at
+
+      last_uuids = []
+      @objects.each do |obj|
+        last_uuids << obj.uuid if obj.trash_at.eql?(last_trash_at)
+      end
+
+      next_page_filters += [['trash_at', nextpage_operator, last_trash_at]]
+      next_page_filters += [['uuid', 'not in', last_uuids]]
+    end
+
+    next_page_filters
+  end
+
   def trashed_items
     # API server index doesn't return manifest_text by default, but our
     # callers want it unless otherwise specified.
index 6776e7a815fb96fbe60f83e0186c58afda4404fe..4d9be07dea3814fc2dc1d86114ded31eb544b4d5 100644 (file)
@@ -38,8 +38,8 @@
         <tr class="contain-align-left">
           <th></th>
           <th>Name</th>
-          <th>Created at</th>
           <th>Trashed at</th>
+          <th>Created at</th>
           <th>Owner</th>
           <th>Contents</th>
           <th></th>
index 8db21ed75a10aa2fd213d282ee0859d5ca2b0555..4cc16f6202004dc157c69b2fc9c58a1a62e5234d 100644 (file)
@@ -7,10 +7,10 @@
       </td>
       <td>
         <%= if !obj.name.blank? then obj.name else obj.uuid end %>
-      <td>
-        <%= render_localized_date(obj.created_at) if obj.created_at %>
       <td>
         <%= render_localized_date(obj.trash_at) if obj.trash_at %>
+      <td>
+        <%= render_localized_date(obj.created_at) if obj.created_at %>
       </td>
       <td>
         <%= link_to_if_arvados_object obj.owner_uuid, friendly_name: true %>