4091: pass limit parameter from project tabs.
authorradhika <radhika@curoverse.com>
Thu, 23 Oct 2014 13:37:40 +0000 (09:37 -0400)
committerradhika <radhika@curoverse.com>
Thu, 23 Oct 2014 13:37:40 +0000 (09:37 -0400)
apps/workbench/app/controllers/projects_controller.rb
apps/workbench/app/views/projects/_show_data_collections.html.erb
apps/workbench/app/views/projects/_show_jobs_and_pipelines.html.erb
apps/workbench/app/views/projects/_show_other_objects.html.erb
apps/workbench/app/views/projects/_show_pipeline_templates.html.erb
apps/workbench/app/views/projects/_show_subprojects.html.erb
apps/workbench/app/views/projects/_show_tab_contents.html.erb

index b77a48973f5a32f3a33685e6d0dc749f3c6c5027..56bcd0a8f183141a59e767d5c5ec430716ad5b11 100644 (file)
@@ -205,11 +205,33 @@ class ProjectsController < ApplicationController
       @next_page_filters = @filters.reject do |attr,op,val|
         attr == 'created_at' and op == nextpage_operator
       end
+
+      # We are using created_at time slightly greater/lower than the last object created_at (see next block comment).
+      # This would mean that the server would now return the previous last item(s) with matching created_at again.
+      # Hence, we need to remove the previous last item (last_uuid) from results before displaying the rest of the
+      # results to prevent "infinite" infinite scrolling.
+      if params['last_uuid'] and @objects.any?
+        @objects.each do |obj|
+          @objects.delete obj if obj.uuid.eql?(params['last_uuid'])
+        end
+      end
+
       if @objects.any?
+        last_created_at = @objects.last.created_at
+
+        # In order to prevent losing item(s) that have the same created_at time as the current page last item,
+        # next page should look for objects with created_at time slightly greater/lower than the current last.
+        if nextpage_operator == '<'
+          last_created_at += 1
+        else
+          last_created_at -= 1
+        end
+
         @next_page_filters += [['created_at',
                                 nextpage_operator,
-                                @objects.last.created_at]]
+                                last_created_at]]
         @next_page_href = url_for(partial: :contents_rows,
+                                  last_uuid: @objects.last.uuid,
                                   filters: @next_page_filters.to_json)
       else
         @next_page_href = nil
index e56321dde8a55b4137e082882b8afe77244d7e80..f2995c9e4db6b81bdf5c0d22256f540e6ffb0085 100644 (file)
@@ -1,3 +1,4 @@
 <%= render_pane 'tab_contents', to_string: true, locals: {
+    limit: 200,
     filters: [['uuid', 'is_a', "arvados#collection"]]
     }.merge(local_assigns) %>
index df31fec8ee0bf19df7058fa358d0330636d06798..3007857758fd3da0efe3ce3a3846f4fae7f6a992 100644 (file)
@@ -1,3 +1,4 @@
 <%= render_pane 'tab_contents', to_string: true, locals: {
+    limit: 100,
     filters: [['uuid', 'is_a', ["arvados#job", "arvados#pipelineInstance"]]]
     }.merge(local_assigns) %>
index af6fbd1a92ab9b5049e64d635741f4295e7a46a5..155391530b327d88b843542357ed01b35a0ce998 100644 (file)
@@ -1,3 +1,4 @@
 <%= render_pane 'tab_contents', to_string: true, locals: {
+    limit: 200,
     filters: [['uuid', 'is_a', ["arvados#human", "arvados#specimen", "arvados#trait"]]]
     }.merge(local_assigns) %>
index b875b086ec3e1528a1a29fb35df40ba1b239dd7c..6d8cd7584651343578aeb4246cdd4d5a873c6888 100644 (file)
@@ -1,3 +1,4 @@
 <%= render_pane 'tab_contents', to_string: true, locals: {
+    limit: 200,
     filters: [['uuid', 'is_a', ["arvados#pipelineTemplate"]]]
     }.merge(local_assigns) %>
index 2c0ba6017831b5cab5c2361a98aa5a49ed9f1e1a..556b7bd13f42b1162e45884b5bdc771b1dfc2325 100644 (file)
@@ -1,3 +1,4 @@
 <%= render_pane 'tab_contents', to_string: true, locals: {
+    limit: 200,
     filters: [['uuid', 'is_a', ["arvados#group"]]]
     }.merge(local_assigns) %>
index 0f9901aa0ad417356dd27b63a5d9b82ccfcec321..fa0578cef2f9e0a711d91e69b9e01fcfd59c9525 100644 (file)
@@ -75,7 +75,7 @@
       <col width="60%" style="width: 60%;" />
       <col width="40%" style="width: 40%;" />
     </colgroup>
-    <tbody data-infinite-scroller="#<%= tab_pane %>-scroll" data-infinite-content-href="<%= url_for partial: :contents_rows %>" data-infinite-content-params-projecttab="<%= {filters: filters}.to_json %>">
+    <tbody data-infinite-scroller="#<%= tab_pane %>-scroll" data-infinite-content-href="<%= url_for partial: :contents_rows %>" data-infinite-content-params-projecttab="<%= {limit: limit, filters: filters}.to_json %>">
     </tbody>
     <thead>
       <tr>