3235: Fix infinite scroll in Search chooser.
authorTom Clegg <tom@curoverse.com>
Sun, 27 Jul 2014 19:22:38 +0000 (15:22 -0400)
committerTom Clegg <tom@curoverse.com>
Sun, 27 Jul 2014 19:22:38 +0000 (15:22 -0400)
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/controllers/search_controller.rb
apps/workbench/app/views/application/_choose.html.erb
apps/workbench/app/views/search/_choose_rows.html.erb

index 83cb261381f508ebb4250f0d633be0d69719685c..9383e5cd56f57eab9cf2b51df84161df876d01ac 100644 (file)
@@ -148,6 +148,13 @@ class ApplicationController < ActionController::Base
     end
   end
 
+  helper_method :next_page_href
+  def next_page_href with_params={}
+    if next_page_offset
+      url_for with_params.merge(offset: next_page_offset)
+    end
+  end
+
   def show
     if !@object
       return render_not_found("object not found")
@@ -190,7 +197,7 @@ class ApplicationController < ActionController::Base
                                       locals: {
                                         multiple: params[:multiple]
                                       }),
-            next_page_href: @next_page_href
+            next_page_href: next_page_href(partial: params[:partial])
           }
         }
       end
index 85478190907e7d22851c641586e983dd8a0519b7..d0b15154a9cfd136c5c7433983cf61fda1b1fe14 100644 (file)
@@ -58,8 +58,6 @@ class CollectionsController < ApplicationController
     @objects = Link.filter(filter)
 
     find_objects_for_index
-    @next_page_href = (next_page_offset and
-                       url_for(offset: next_page_offset, partial: true))
     @name_links = @objects
 
     @objects = Collection.
index 510ba6f35f0ef3066c3674450585bd96fdac09e7..2b0ad7e57aac5bbf935caac978aad1c864439021 100644 (file)
@@ -3,4 +3,8 @@ class SearchController < ApplicationController
     @objects = Group.contents(limit: @limit, offset: @offset, filters: @filters)
     super
   end
+
+  def next_page_href with_params={}
+    super with_params.merge(last_object_class: @objects.last.class.to_s)
+  end
 end
index 8b31bb88325865b143b22f50a660b2ec41aec0b0..f292445895bf44ac36d449ea2412b2e49fb01f39 100644 (file)
@@ -36,7 +36,7 @@
               style="height: 100%; overflow-y: scroll"
               data-infinite-scroller="#choose-scroll"
               id="choose-scroll"
-              data-infinite-content-href="<%= @next_page_href %>">
+              data-infinite-content-href="<%= next_page_href partial: true %>">
            <%= render partial: 'choose_rows', locals: {multiple: multiple} %>
          </div>
           <div class="col-sm-6 modal-dialog-preview-pane" style="height: 100%; overflow-y: scroll">
index 53b0d7ef471a9adf14261d77990563b6946e4dee..59b15cecfd2eff82f5190f25550e5309c17f2ef3 100644 (file)
@@ -1,8 +1,8 @@
-<% current_class = nil %>
+<% current_class = params[:last_object_class] %>
 <% @objects.each do |object| %>
   <% icon_class = fa_icon_class_for_class(object.class) %>
-  <% if object.class != current_class %>
-    <% current_class = object.class %>
+  <% if object.class.to_s != current_class %>
+    <% current_class = object.class.to_s %>
     <div class="row class-separator">
       <div class="col-sm-12">
         <%= object.class_for_display.pluralize.downcase %>