[ARVADOS] created: 1a1abfc1b6c1fbb97539cb503a81dfd678adcdf1

git at public.curoverse.com git at public.curoverse.com
Sun Aug 24 22:40:32 EDT 2014


        at  1a1abfc1b6c1fbb97539cb503a81dfd678adcdf1 (commit)


commit 1a1abfc1b6c1fbb97539cb503a81dfd678adcdf1
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Aug 24 22:40:09 2014 -0400

    3149: Do not blow up on small devices/windows.

diff --git a/apps/workbench/app/views/application/_choose.html.erb b/apps/workbench/app/views/application/_choose.html.erb
index ddad7d3..aea27f4 100644
--- a/apps/workbench/app/views/application/_choose.html.erb
+++ b/apps/workbench/app/views/application/_choose.html.erb
@@ -48,17 +48,17 @@
         <div style="height: 1em" />
 
         <% preview_pane = (params[:preview_pane].to_s != "false")
-           pane_col_class = preview_pane ? "col-sm-6" : "col-sm-12" %>
+           pane_col_class = preview_pane ? "col-md-6" : "col-md-12" %>
         <div class="row" style="height: 20em">
-          <div class="<%= pane_col_class %> container arv-filterable-list selectable-container <%= 'multiple' if multiple %>"
+          <div class="<%= pane_col_class %> arv-filterable-list selectable-container <%= 'multiple' if multiple %>"
                style="height: 100%; overflow-y: scroll"
                data-infinite-scroller="#choose-scroll"
                id="choose-scroll"
                data-infinite-content-href="<%= url_for partial: true %>">
           </div>
           <% if preview_pane %>
-          <div class="col-sm-6 visible-md visible-lg modal-dialog-preview-pane" style="height: 100%; overflow-y: scroll">
-          </div>
+            <div class="col-md-6 hidden-xs hidden-sm modal-dialog-preview-pane" style="height: 100%; overflow-y: scroll">
+            </div>
           <% end %>
         </div>
 

commit b04f78ea89893d11eee642ad1578862610643d16
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Aug 24 22:23:43 2014 -0400

    3149: Do not preload results in search dialog. Let infinite scroll do it.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 5c99c15..a92f041 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -218,10 +218,10 @@ class ApplicationController < ActionController::Base
 
   def choose
     params[:limit] ||= 40
-    find_objects_for_index if !@objects
     respond_to do |f|
       if params[:partial]
         f.json {
+          find_objects_for_index if !@objects
           render json: {
             content: render_to_string(partial: "choose_rows.html",
                                       formats: [:html]),
@@ -230,6 +230,7 @@ class ApplicationController < ActionController::Base
         }
       end
       f.js {
+        find_objects_for_index if !@objects
         render partial: 'choose', locals: {multiple: params[:multiple]}
       }
     end
diff --git a/apps/workbench/app/views/application/_choose.html.erb b/apps/workbench/app/views/application/_choose.html.erb
index 9860e27..ddad7d3 100644
--- a/apps/workbench/app/views/application/_choose.html.erb
+++ b/apps/workbench/app/views/application/_choose.html.erb
@@ -2,7 +2,7 @@
   <div class="modal-dialog" style="width:80%">
     <div class="modal-content">
       <div class="modal-header">
-        <button type="button" class="close" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">×</button>
+        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
         <h4 class="modal-title"><%= params[:title] || "Choose #{@objects.first.andand.class_for_display}" %></h4>
       </div>
 
@@ -54,9 +54,7 @@
                style="height: 100%; overflow-y: scroll"
                data-infinite-scroller="#choose-scroll"
                id="choose-scroll"
-               data-infinite-content-href="<%= next_page_href partial: true %>"
-               data-infinite-content-href0="<%= url_for partial: true %>">
-            <%= render partial: 'choose_rows' %>
+               data-infinite-content-href="<%= url_for partial: true %>">
           </div>
           <% if preview_pane %>
           <div class="col-sm-6 visible-md visible-lg modal-dialog-preview-pane" style="height: 100%; overflow-y: scroll">

commit d12257e98b7d965d6e34cdede8b90961e25489e3
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Aug 24 22:09:42 2014 -0400

    3149: Fix infinite scroll not updating after retry/refresh.

diff --git a/apps/workbench/app/assets/javascripts/infinite_scroll.js b/apps/workbench/app/assets/javascripts/infinite_scroll.js
index 8e6bbf0..74c1286 100644
--- a/apps/workbench/app/assets/javascripts/infinite_scroll.js
+++ b/apps/workbench/app/assets/javascripts/infinite_scroll.js
@@ -105,6 +105,13 @@ function maybe_load_more_content(event) {
      }
 }
 
+function ping_all_scrollers() {
+    // Send a scroll event to all scroll listeners that might need
+    // updating. Adding infinite-scroller class to the window element
+    // doesn't work, so we add it explicitly here.
+    $('.infinite-scroller').add(window).trigger('scroll');
+}
+
 $(document).
     on('click', 'div.infinite-retry button', function() {
         var $retry_div = $(this).closest('.infinite-retry');
@@ -113,7 +120,7 @@ $(document).
                         $retry_div.attr('data-infinite-content-href'));
         $retry_div.
             replaceWith('<div class="spinner spinner-32px spinner-h-center" />');
-        $('.infinite-scroller').trigger('scroll');
+        ping_all_scrollers();
     }).
     on('refresh-content', '[data-infinite-scroller]', function() {
         // Clear all rows, reset source href to initial state, and
@@ -124,8 +131,7 @@ $(document).
         $(this).
             html('').
             attr('data-infinite-content-href', first_page_href);
-        $('.infinite-scroller').
-            trigger('scroll');
+        ping_all_scrollers();
     }).
     on('ready ajax:complete', function() {
         $('[data-infinite-scroller]').each(function() {

commit c5f356f041ce97a9c506f0ed276c80e9de24b436
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Aug 24 21:36:40 2014 -0400

    3149: Fix user-controlled filters overwriting page-controlled filters.

diff --git a/apps/workbench/app/assets/javascripts/filterable.js b/apps/workbench/app/assets/javascripts/filterable.js
index 182924b..51a1060 100644
--- a/apps/workbench/app/assets/javascripts/filterable.js
+++ b/apps/workbench/app/assets/javascripts/filterable.js
@@ -24,9 +24,9 @@ $(document).
                 // characters in the search box), hide the stale
                 // content and ask the server for new results.
                 var newquery = $target.data('filterable-query-new');
-                var params = $target.data('infinite-content-params') || {};
-                params.filters = JSON.stringify([['any', 'ilike', '%' + newquery + '%']]);
-                $target.data('infinite-content-params', params);
+                var params = $target.data('infiniteContentParamsFilterable') || {};
+                params.filters = [['any', 'ilike', '%' + newquery + '%']];
+                $target.data('infiniteContentParamsFilterable', params);
                 $target.data('filterable-query', newquery);
                 $target.trigger('refresh-content');
             }, 250));
diff --git a/apps/workbench/app/assets/javascripts/infinite_scroll.js b/apps/workbench/app/assets/javascripts/infinite_scroll.js
index 84494ed..8e6bbf0 100644
--- a/apps/workbench/app/assets/javascripts/infinite_scroll.js
+++ b/apps/workbench/app/assets/javascripts/infinite_scroll.js
@@ -5,6 +5,7 @@ function maybe_load_more_content(event) {
     var scrollHeight;
     var spinner, colspan;
     var serial = Date.now();
+    var params;
     scrollHeight = scroller.scrollHeight || $('body')[0].scrollHeight;
     if ($(scroller).scrollTop() + $(scroller).height()
         >
@@ -39,10 +40,36 @@ function maybe_load_more_content(event) {
         $container.find(".spinner").detach();
         $container.append(spinner);
         $container.attr('data-infinite-serial', serial);
+
+        // Combine infiniteContentParams from multiple
+        // sources. filterable.js might put its params in
+        // infiniteContentParamsFilterable, etc.
+        params = {};
+        $.each($container.data(), function(datakey, datavalue) {
+            if (/^infiniteContentParams/.exec(datakey)) {
+                if (datavalue instanceof Object) {
+                    $.each(datavalue, function(hkey, hvalue) {
+                        if (hvalue instanceof Array) {
+                            params[hkey] = (params[hkey] || []).concat(hvalue);
+                        } else if (hvalue instanceof Object) {
+                            $.extend(params[hkey], hvalue);
+                        } else {
+                            params[hkey] = hvalue;
+                        }
+                    });
+                }
+            }
+        });
+        $.each(params, function(k,v) {
+            if (v instanceof Object) {
+                params[k] = JSON.stringify(v);
+            }
+        });
+
         $.ajax(src,
                {dataType: 'json',
                 type: 'GET',
-                data: ($container.data('infinite-content-params') || {}),
+                data: params,
                 context: {container: $container, src: src, serial: serial}}).
             fail(function(jqxhr, status, error) {
                 var $faildiv;
@@ -81,11 +108,12 @@ function maybe_load_more_content(event) {
 $(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');
+        var $container = $(this).closest('.infinite-scroller-ready')
+        $container.attr('data-infinite-content-href',
+                        $retry_div.attr('data-infinite-content-href'));
+        $retry_div.
+            replaceWith('<div class="spinner spinner-32px spinner-h-center" />');
+        $('.infinite-scroller').trigger('scroll');
     }).
     on('refresh-content', '[data-infinite-scroller]', function() {
         // Clear all rows, reset source href to initial state, and
diff --git a/apps/workbench/app/views/projects/_show_tab_contents.html.erb b/apps/workbench/app/views/projects/_show_tab_contents.html.erb
index 8ea2e6c..8fb588f 100644
--- a/apps/workbench/app/views/projects/_show_tab_contents.html.erb
+++ b/apps/workbench/app/views/projects/_show_tab_contents.html.erb
@@ -46,7 +46,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, 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="<%= {filters: filters}.to_json %>">
     </tbody>
     <thead>
       <tr>

commit cce04610bca932fcd6dec3d54ef349bd877d5c2e
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Aug 24 19:58:54 2014 -0400

    3149: Let Workbench server do all the filtering where infinite-scroll facilities exist.

diff --git a/apps/workbench/app/assets/javascripts/filterable.js b/apps/workbench/app/assets/javascripts/filterable.js
index 06362a2..182924b 100644
--- a/apps/workbench/app/assets/javascripts/filterable.js
+++ b/apps/workbench/app/assets/javascripts/filterable.js
@@ -1,16 +1,42 @@
 $(document).
     on('paste keyup input', 'input[type=text].filterable-control', function() {
-        var infinite_container = $(this).closest('[data-infinite-scroller]');
-        var q = new RegExp($(this).val(), 'i');
         var $target = $($(this).attr('data-filterable-target'));
-        $target.
-            addClass('filterable-container').
-            data('q', q).
-            trigger('refresh');
+        var currentquery = $target.data('filterable-query');
+        if (currentquery === undefined) currentquery = '';
         if ($target.is('[data-infinite-scroller]')) {
-            params = $target.data('infinite-content-params') || {};
-            params.filters = JSON.stringify([['any', 'like', '%' + $(this).val() + '%']]);
-            $target.data('infinite-content-params', params);
+            // We already know how to load content dynamically, so we
+            // can do all filtering on the server side.
+
+            if ($target.data('infinite-cooloff-timer') > 0) {
+                // Clear a stale refresh-after-delay timer.
+                clearTimeout($target.data('infinite-cooloff-timer'));
+            }
+            // Stash the new query string in the filterable container.
+            $target.data('filterable-query-new', $(this).val());
+            if (currentquery == $(this).val()) {
+                // Don't mess with existing results or queries in
+                // progress.
+                return;
+            }
+            $target.data('infinite-cooloff-timer', setTimeout(function() {
+                // If the user doesn't do any query-changing actions
+                // in the next 1/4 second (like type or erase
+                // characters in the search box), hide the stale
+                // content and ask the server for new results.
+                var newquery = $target.data('filterable-query-new');
+                var params = $target.data('infinite-content-params') || {};
+                params.filters = JSON.stringify([['any', 'ilike', '%' + newquery + '%']]);
+                $target.data('infinite-content-params', params);
+                $target.data('filterable-query', newquery);
+                $target.trigger('refresh-content');
+            }, 250));
+        } else {
+            // Target does not have infinite-scroll capability. Just
+            // filter the rows in the browser using a RegExp.
+            $target.
+                addClass('filterable-container').
+                data('q', new RegExp($(this).val(), 'i')).
+                trigger('refresh');
         }
     }).on('refresh', '.filterable-container', function() {
         var $container = $(this);
diff --git a/apps/workbench/app/assets/javascripts/infinite_scroll.js b/apps/workbench/app/assets/javascripts/infinite_scroll.js
index e70ca25..84494ed 100644
--- a/apps/workbench/app/assets/javascripts/infinite_scroll.js
+++ b/apps/workbench/app/assets/javascripts/infinite_scroll.js
@@ -105,6 +105,11 @@ $(document).
                 return;
             $(this).addClass('infinite-scroller-ready');
 
+            // $scroller is the DOM element that hears "scroll"
+            // events: sometimes it's a div, sometimes it's
+            // window. Here, "this" is the DOM element containing the
+            // result rows. We pass it to maybe_load_more_content in
+            // event.data.
             var $scroller = $($(this).attr('data-infinite-scroller'));
             if (!$scroller.hasClass('smart-scroll') &&
                 'scroll' != $scroller.css('overflow-y'))

commit 846abbca5bd9f8ed511f2960d875a228a76a6589
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Aug 24 18:46:29 2014 -0400

    3149: Propagate search string to Workbench server using filters param.

diff --git a/apps/workbench/app/assets/javascripts/filterable.js b/apps/workbench/app/assets/javascripts/filterable.js
index 7da461e..06362a2 100644
--- a/apps/workbench/app/assets/javascripts/filterable.js
+++ b/apps/workbench/app/assets/javascripts/filterable.js
@@ -1,10 +1,17 @@
 $(document).
     on('paste keyup input', 'input[type=text].filterable-control', function() {
+        var infinite_container = $(this).closest('[data-infinite-scroller]');
         var q = new RegExp($(this).val(), 'i');
-        $($(this).attr('data-filterable-target')).
+        var $target = $($(this).attr('data-filterable-target'));
+        $target.
             addClass('filterable-container').
             data('q', q).
             trigger('refresh');
+        if ($target.is('[data-infinite-scroller]')) {
+            params = $target.data('infinite-content-params') || {};
+            params.filters = JSON.stringify([['any', 'like', '%' + $(this).val() + '%']]);
+            $target.data('infinite-content-params', params);
+        }
     }).on('refresh', '.filterable-container', function() {
         var $container = $(this);
         var q = $(this).data('q');

commit c337182505d76ee11d476d7c79b09305182cba29
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Aug 24 17:22:50 2014 -0400

    3149: Untabify.

diff --git a/apps/workbench/app/views/application/_choose.html.erb b/apps/workbench/app/views/application/_choose.html.erb
index 68351a9..9860e27 100644
--- a/apps/workbench/app/views/application/_choose.html.erb
+++ b/apps/workbench/app/views/application/_choose.html.erb
@@ -50,14 +50,14 @@
         <% preview_pane = (params[:preview_pane].to_s != "false")
            pane_col_class = preview_pane ? "col-sm-6" : "col-sm-12" %>
         <div class="row" style="height: 20em">
-	  <div class="<%= pane_col_class %> container arv-filterable-list selectable-container <%= 'multiple' if multiple %>"
-	       style="height: 100%; overflow-y: scroll"
-	       data-infinite-scroller="#choose-scroll"
-	       id="choose-scroll"
-	       data-infinite-content-href="<%= next_page_href partial: true %>"
-	       data-infinite-content-href0="<%= url_for partial: true %>">
-	    <%= render partial: 'choose_rows' %>
-	  </div>
+          <div class="<%= pane_col_class %> container arv-filterable-list selectable-container <%= 'multiple' if multiple %>"
+               style="height: 100%; overflow-y: scroll"
+               data-infinite-scroller="#choose-scroll"
+               id="choose-scroll"
+               data-infinite-content-href="<%= next_page_href partial: true %>"
+               data-infinite-content-href0="<%= url_for partial: true %>">
+            <%= render partial: 'choose_rows' %>
+          </div>
           <% if preview_pane %>
           <div class="col-sm-6 visible-md visible-lg modal-dialog-preview-pane" style="height: 100%; overflow-y: scroll">
           </div>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list