[ARVADOS] updated: 4bbd2177505ff09d6d9e77d1a1ea80523fcfd395

git at public.curoverse.com git at public.curoverse.com
Sun Jul 27 15:22:46 EDT 2014


Summary of changes:
 .../app/assets/javascripts/infinite_scroll.js        | 20 +++++++++++++++++---
 .../app/assets/stylesheets/application.css.scss      |  4 ++++
 .../app/controllers/application_controller.rb        |  9 ++++++++-
 .../app/controllers/collections_controller.rb        |  2 --
 apps/workbench/app/controllers/search_controller.rb  |  4 ++++
 .../workbench/app/views/application/_choose.html.erb |  2 +-
 .../workbench/app/views/search/_choose_rows.html.erb |  6 +++---
 7 files changed, 37 insertions(+), 10 deletions(-)

       via  4bbd2177505ff09d6d9e77d1a1ea80523fcfd395 (commit)
       via  22193a19dd10c71ae11cba977a76c9259735ad3c (commit)
      from  8f2cb724f85d77a3ef7365d6a2a4feba58e6f0f9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 4bbd2177505ff09d6d9e77d1a1ea80523fcfd395
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Jul 27 15:22:38 2014 -0400

    3235: Fix infinite scroll in Search chooser.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 83cb261..9383e5c 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -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
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index 8547819..d0b1515 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -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.
diff --git a/apps/workbench/app/controllers/search_controller.rb b/apps/workbench/app/controllers/search_controller.rb
index 510ba6f..2b0ad7e 100644
--- a/apps/workbench/app/controllers/search_controller.rb
+++ b/apps/workbench/app/controllers/search_controller.rb
@@ -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
diff --git a/apps/workbench/app/views/application/_choose.html.erb b/apps/workbench/app/views/application/_choose.html.erb
index 8b31bb8..f292445 100644
--- a/apps/workbench/app/views/application/_choose.html.erb
+++ b/apps/workbench/app/views/application/_choose.html.erb
@@ -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">
diff --git a/apps/workbench/app/views/search/_choose_rows.html.erb b/apps/workbench/app/views/search/_choose_rows.html.erb
index 53b0d7e..59b15ce 100644
--- a/apps/workbench/app/views/search/_choose_rows.html.erb
+++ b/apps/workbench/app/views/search/_choose_rows.html.erb
@@ -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 %>

commit 22193a19dd10c71ae11cba977a76c9259735ad3c
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Jul 27 15:19:49 2014 -0400

    3235: Infinite scroll error handling: Show error message and "Retry" button
    instead of immediately repeating the failed request ad infinitum.

diff --git a/apps/workbench/app/assets/javascripts/infinite_scroll.js b/apps/workbench/app/assets/javascripts/infinite_scroll.js
index a17b446..4df689b 100644
--- a/apps/workbench/app/assets/javascripts/infinite_scroll.js
+++ b/apps/workbench/app/assets/javascripts/infinite_scroll.js
@@ -27,6 +27,7 @@ function maybe_load_more_content() {
                        spinner +
                        '</td></tr>');
         }
+        $(container).find(".spinner").detach();
         $(container).append(spinner);
         $.ajax(src,
                {dataType: 'json',
@@ -34,9 +35,9 @@ function maybe_load_more_content() {
                 data: {},
                 context: {container: container, src: src}}).
             always(function() {
-                $(this.container).find(".spinner").detach();
             }).
             fail(function(jqxhr, status, error) {
+                var $faildiv;
                 if (jqxhr.readyState == 0 || jqxhr.status == 0) {
                     message = "Cancelled."
                 } else if (jqxhr.responseJSON && jqxhr.responseJSON.errors) {
@@ -44,17 +45,30 @@ function maybe_load_more_content() {
                 } else {
                     message = "Request failed.";
                 }
-                // TODO: report this to the user.
+                // TODO: report the message to the user.
                 console.log(message);
-                $(this.container).attr('data-infinite-content-href', this.src);
+                $faildiv = $('<div />').
+                    attr('data-infinite-content-href', this.src).
+                    addClass('infinite-retry').
+                    append('<span class="fa fa-warning" /> Oops, request failed. <button class="btn btn-xs btn-primary">Retry</button>');
+                $(this.container).find('div.spinner').replaceWith($faildiv);
             }).
             done(function(data, status, jqxhr) {
+                $(this.container).find(".spinner").detach();
                 $(this.container).append(data.content);
                 $(this.container).attr('data-infinite-content-href', data.next_page_href);
             });
     }
 }
 $(document).
+    on('click', 'div.infinite-retry button', function() {
+        var $retry_div = $(this).closest('.infinite-retry');
+        var $scroller = $(this).closest('.infinite-scroller')
+        $scroller.attr('data-infinite-content-href',
+                       $retry_div.attr('data-infinite-content-href'));
+        $retry_div.replaceWith('<div class="spinner spinner-32px spinner-h-center" />');
+        $scroller.trigger('scroll');
+    }).
     on('ready ajax:complete', function() {
         $('[data-infinite-scroller]').each(function() {
             var $scroller = $($(this).attr('data-infinite-scroller'));
diff --git a/apps/workbench/app/assets/stylesheets/application.css.scss b/apps/workbench/app/assets/stylesheets/application.css.scss
index e3f4f0a..a62bedd 100644
--- a/apps/workbench/app/assets/stylesheets/application.css.scss
+++ b/apps/workbench/app/assets/stylesheets/application.css.scss
@@ -146,6 +146,10 @@ nav.navbar-fixed-top .navbar-nav.navbar-right > li > a:hover {
     margin-bottom: -15px;
 }
 
+.infinite-scroller .fa-warning {
+    color: #800;
+}
+
 .inline-progress-container div.progress {
     margin-bottom: 0;
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list