[ARVADOS] updated: ddfbe0de9bfc6e3d9cb0d26466ac61bb87f5d65a

git at public.curoverse.com git at public.curoverse.com
Sun Jul 27 18:16:11 EDT 2014


Summary of changes:
 .../app/assets/javascripts/infinite_scroll.js      | 34 +++++++++++++++++++---
 .../app/assets/javascripts/select_modal.js         | 19 +++++++++---
 .../app/controllers/application_controller.rb      | 26 ++++++++---------
 .../app/controllers/collections_controller.rb      | 12 +++-----
 .../app/views/application/_choose.html.erb         | 30 ++++++++++---------
 .../workbench/app/views/application/_choose.js.erb | 21 -------------
 .../views/application/_projects_tree_menu.html.erb |  2 +-
 .../app/views/collections/_choose_rows.html.erb    |  2 +-
 .../app/views/groups/_choose_rows.html.erb         |  2 +-
 .../app/views/layouts/application.html.erb         |  1 +
 .../views/pipeline_templates/_choose_rows.html.erb |  2 +-
 .../app/views/search/_choose_rows.html.erb         |  2 +-
 .../app/views/users/_choose_rows.html.erb          |  2 +-
 .../api/app/controllers/application_controller.rb  |  2 +-
 14 files changed, 85 insertions(+), 72 deletions(-)

       via  ddfbe0de9bfc6e3d9cb0d26466ac61bb87f5d65a (commit)
       via  381fb2d7435e6cde2adf9574ba82043ff2a13204 (commit)
       via  93059e2f0e5ff27bec5e088b822f505863369307 (commit)
      from  8c87d1cf55e096ce472fa9a749b60f2aab7fbb74 (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 ddfbe0de9bfc6e3d9cb0d26466ac61bb87f5d65a
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Jul 27 18:03:13 2014 -0400

    3235: Fix "no filter / all projects" option.

diff --git a/apps/workbench/app/assets/javascripts/select_modal.js b/apps/workbench/app/assets/javascripts/select_modal.js
index fc158bf..7c72323 100644
--- a/apps/workbench/app/assets/javascripts/select_modal.js
+++ b/apps/workbench/app/assets/javascripts/select_modal.js
@@ -71,10 +71,15 @@ $(document).on('click', '.selectable', function() {
                                 [data, status, jqxhr, this.action_data]);
         });
 }).on('click', '.chooser-show-project', function() {
-    $(this).attr('href', '#');
+    var params = {};
+    $(this).attr('href', '#');  // Skip normal click handler
+    if ($(this).attr('data-project-uuid')) {
+        params = {'filters[]': JSON.stringify(['owner_uuid',
+                                               '=',
+                                               $(this).attr('data-project-uuid')])};
+    }
     $($(this).closest('[data-filterable-target]').attr('data-filterable-target')).
-        data('infinite-content-params',
-             {'filters[]': JSON.stringify(['owner_uuid', '=', $(this).attr('data-project-uuid')])}).
+        data('infinite-content-params', params).
         trigger('refresh-content');
 });
 $(document).on('page-refresh', function(event, data, status, jqxhr, action_data) {

commit 381fb2d7435e6cde2adf9574ba82043ff2a13204
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Jul 27 17:58:17 2014 -0400

    3235: Fix multiple-select.

diff --git a/apps/workbench/app/assets/javascripts/select_modal.js b/apps/workbench/app/assets/javascripts/select_modal.js
index 07404d4..fc158bf 100644
--- a/apps/workbench/app/assets/javascripts/select_modal.js
+++ b/apps/workbench/app/assets/javascripts/select_modal.js
@@ -1,14 +1,14 @@
 $(document).on('click', '.selectable', function() {
     var any;
     var $this = $(this);
-    if (!$this.hasClass('multiple')) {
-        $this.closest('.selectable-container').
+    var $container = $(this).closest('.selectable-container');
+    if (!$container.hasClass('multiple')) {
+        $container.
             find('.selectable').
             removeClass('active');
     }
     $this.toggleClass('active');
-    any = ($this.
-           closest('.selectable-container').
+    any = ($container.
            find('.selectable.active').length > 0)
     $this.
         closest('.modal').
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 9eb9978..3db56f7 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -194,10 +194,7 @@ class ApplicationController < ActionController::Base
         f.json {
           render json: {
             content: render_to_string(partial: "choose_rows.html",
-                                      formats: [:html],
-                                      locals: {
-                                        multiple: params[:multiple]
-                                      }),
+                                      formats: [:html]),
             next_page_href: next_page_href(partial: params[:partial])
           }
         }
diff --git a/apps/workbench/app/views/application/_choose.html.erb b/apps/workbench/app/views/application/_choose.html.erb
index d2256ae..213890c 100644
--- a/apps/workbench/app/views/application/_choose.html.erb
+++ b/apps/workbench/app/views/application/_choose.html.erb
@@ -33,13 +33,13 @@
         </div>
         <div style="height: 1em" />
         <div class="row" style="height: 20em">
-	  <div class="col-sm-6 container arv-filterable-list selectable-container"
+	  <div class="col-sm-6 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', locals: {multiple: multiple} %>
+	    <%= render partial: 'choose_rows' %>
 	  </div>
           <div class="col-sm-6 modal-dialog-preview-pane" style="height: 100%; overflow-y: scroll">
           </div>
diff --git a/apps/workbench/app/views/collections/_choose_rows.html.erb b/apps/workbench/app/views/collections/_choose_rows.html.erb
index ab7e7ac..5a019f8 100644
--- a/apps/workbench/app/views/collections/_choose_rows.html.erb
+++ b/apps/workbench/app/views/collections/_choose_rows.html.erb
@@ -1,6 +1,6 @@
 <% @name_links.each do |name_link| %>
   <% if (object = get_object(name_link.head_uuid)) %>
-    <div class="row filterable selectable <%= 'multiple' if multiple %>" data-object-uuid="<%= name_link.uuid %>"
+    <div class="row filterable selectable" data-object-uuid="<%= name_link.uuid %>"
          data-preview-href="<%= chooser_preview_url_for object %>"
          style="margin-left: 1em; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #DDDDDD">
         <i class="fa fa-fw fa-archive"></i>
diff --git a/apps/workbench/app/views/groups/_choose_rows.html.erb b/apps/workbench/app/views/groups/_choose_rows.html.erb
index 772ef19..fca0415 100644
--- a/apps/workbench/app/views/groups/_choose_rows.html.erb
+++ b/apps/workbench/app/views/groups/_choose_rows.html.erb
@@ -1,6 +1,6 @@
 <% icon_class = fa_icon_class_for_class(Group) %>
 <% @objects.each do |object| %>
-  <div class="row filterable selectable <%= 'multiple' if multiple %>" data-object-uuid="<%= object.uuid %>">
+  <div class="row filterable selectable" data-object-uuid="<%= object.uuid %>">
     <div class="col-sm-12" style="overflow-x:hidden">
       <i class="fa fa-fw <%= icon_class %>"></i>
       <%= object.name %>
diff --git a/apps/workbench/app/views/pipeline_templates/_choose_rows.html.erb b/apps/workbench/app/views/pipeline_templates/_choose_rows.html.erb
index 9aebd69..9b96b47 100644
--- a/apps/workbench/app/views/pipeline_templates/_choose_rows.html.erb
+++ b/apps/workbench/app/views/pipeline_templates/_choose_rows.html.erb
@@ -1,5 +1,5 @@
 <% @objects.each do |object| %>
-  <div class="row filterable selectable <%= 'multiple' if multiple %>" data-object-uuid="<%= object.uuid %>" data-preview-href="<%= url_for object %>?tab_pane=chooser_preview">
+  <div class="row filterable selectable" data-object-uuid="<%= object.uuid %>" data-preview-href="<%= url_for object %>?tab_pane=chooser_preview">
     <div class="col-sm-12" style="overflow-x:hidden">
       <i class="fa fa-fw fa-gear"></i>
       <%= object.name %>
diff --git a/apps/workbench/app/views/search/_choose_rows.html.erb b/apps/workbench/app/views/search/_choose_rows.html.erb
index fdd3095..81d1f68 100644
--- a/apps/workbench/app/views/search/_choose_rows.html.erb
+++ b/apps/workbench/app/views/search/_choose_rows.html.erb
@@ -9,7 +9,7 @@
       </div>
     </div>
   <% end %>
-  <div class="row filterable selectable <%= 'multiple' if multiple %>" data-section-name="<%= object.class.to_s %>" data-object-uuid="<%= object.uuid %>" data-preview-href="<%= chooser_preview_url_for object %>">
+  <div class="row filterable selectable" data-section-name="<%= object.class.to_s %>" data-object-uuid="<%= object.uuid %>" data-preview-href="<%= chooser_preview_url_for object %>">
     <div class="col-sm-12" style="overflow-x:hidden; white-space: nowrap">
       <i class="fa fa-fw <%= icon_class %>"></i>
       <% if object.respond_to?(:name) and object.name and object.name.length > 0 %>
diff --git a/apps/workbench/app/views/users/_choose_rows.html.erb b/apps/workbench/app/views/users/_choose_rows.html.erb
index a893e5e..28f9187 100644
--- a/apps/workbench/app/views/users/_choose_rows.html.erb
+++ b/apps/workbench/app/views/users/_choose_rows.html.erb
@@ -1,6 +1,6 @@
 <% icon_class = fa_icon_class_for_class(User) %>
 <% @objects.each do |object| %>
-  <div class="row filterable selectable <%= 'multiple' if multiple %>" data-object-uuid="<%= object.uuid %>">
+  <div class="row filterable selectable" data-object-uuid="<%= object.uuid %>">
     <div class="col-sm-12" style="overflow-x:hidden">
       <i class="fa fa-fw <%= icon_class %>"></i>
       <%= object.full_name %>

commit 93059e2f0e5ff27bec5e088b822f505863369307
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Jul 27 17:48:28 2014 -0400

    3235: Make filter-by-project play nice with infinite scroll.

diff --git a/apps/workbench/app/assets/javascripts/infinite_scroll.js b/apps/workbench/app/assets/javascripts/infinite_scroll.js
index 4df689b..3e74da3 100644
--- a/apps/workbench/app/assets/javascripts/infinite_scroll.js
+++ b/apps/workbench/app/assets/javascripts/infinite_scroll.js
@@ -4,11 +4,18 @@ function maybe_load_more_content() {
     var src;                    // url for retrieving content
     var scrollHeight;
     var spinner, colspan;
+    var serial = Date.now();
     scrollHeight = scroller.scrollHeight || $('body')[0].scrollHeight;
     if ($(scroller).scrollTop() + $(scroller).height()
         >
         scrollHeight - 50) {
         container = $(this).data('infinite-container');
+        if (!$(container).attr('data-infinite-content-href0')) {
+            // Remember the first page source url, so we can refresh
+            // from page 1 later.
+            $(container).attr('data-infinite-content-href0',
+                              $(container).attr('data-infinite-content-href'));
+        }
         src = $(container).attr('data-infinite-content-href');
         if (!src)
             // Finished
@@ -29,15 +36,18 @@ function maybe_load_more_content() {
         }
         $(container).find(".spinner").detach();
         $(container).append(spinner);
+        $(container).attr('data-infinite-serial', serial);
         $.ajax(src,
                {dataType: 'json',
                 type: 'GET',
-                data: {},
-                context: {container: container, src: src}}).
-            always(function() {
-            }).
+                data: ($(container).data('infinite-content-params') || {}),
+                context: {container: container, src: src, serial: serial}}).
             fail(function(jqxhr, status, error) {
                 var $faildiv;
+                if ($(this.container).attr('data-infinite-serial') != this.serial) {
+                    // A newer request is already in progress.
+                    return;
+                }
                 if (jqxhr.readyState == 0 || jqxhr.status == 0) {
                     message = "Cancelled."
                 } else if (jqxhr.responseJSON && jqxhr.responseJSON.errors) {
@@ -54,6 +64,10 @@ function maybe_load_more_content() {
                 $(this.container).find('div.spinner').replaceWith($faildiv);
             }).
             done(function(data, status, jqxhr) {
+                if ($(this.container).attr('data-infinite-serial') != this.serial) {
+                    // A newer request is already in progress.
+                    return;
+                }
                 $(this.container).find(".spinner").detach();
                 $(this.container).append(data.content);
                 $(this.container).attr('data-infinite-content-href', data.next_page_href);
@@ -69,6 +83,18 @@ $(document).
         $retry_div.replaceWith('<div class="spinner spinner-32px spinner-h-center" />');
         $scroller.trigger('scroll');
     }).
+    on('refresh-content', '[data-infinite-scroller]', function() {
+        // Clear all rows, reset source href to initial state, and
+        // (if the container is visible) start loading content.
+        var first_page_href = $(this).attr('data-infinite-content-href0');
+        if (!first_page_href)
+            first_page_href = $(this).attr('data-infinite-content-href');
+        $(this).
+            html('').
+            attr('data-infinite-content-href', first_page_href);
+        $('.infinite-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/javascripts/select_modal.js b/apps/workbench/app/assets/javascripts/select_modal.js
index fe9132d..07404d4 100644
--- a/apps/workbench/app/assets/javascripts/select_modal.js
+++ b/apps/workbench/app/assets/javascripts/select_modal.js
@@ -70,6 +70,12 @@ $(document).on('click', '.selectable', function() {
             $(document).trigger(event_name!=null ? event_name : 'page-refresh',
                                 [data, status, jqxhr, this.action_data]);
         });
+}).on('click', '.chooser-show-project', function() {
+    $(this).attr('href', '#');
+    $($(this).closest('[data-filterable-target]').attr('data-filterable-target')).
+        data('infinite-content-params',
+             {'filters[]': JSON.stringify(['owner_uuid', '=', $(this).attr('data-project-uuid')])}).
+        trigger('refresh-content');
 });
 $(document).on('page-refresh', function(event, data, status, jqxhr, action_data) {
     window.location.reload();
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 9383e5c..9eb9978 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -103,6 +103,16 @@ class ApplicationController < ActionController::Base
       filters = params[:filters]
       if filters.is_a? String
         filters = Oj.load filters
+      elsif filters.is_a? Array
+        filters = filters.collect do |filter|
+          if filter.is_a? String
+            # Accept filters[]=["foo","=","bar"]
+            Oj.load filter
+          else
+            # Accept filters=[["foo","=","bar"]]
+            filter
+          end
+        end
       end
       @filters += filters
     end
@@ -178,16 +188,7 @@ class ApplicationController < ActionController::Base
 
   def choose
     params[:limit] ||= 40
-    if !@objects
-      if params[:project_uuid] and !params[:project_uuid].empty?
-        # We want the chooser to show objects of the controllers's model_class
-        # type within a specific project specified by project_uuid, so fetch the
-        # project and request the contents of the project filtered on the
-        # controllers's model_class kind.
-        @objects = Group.find(params[:project_uuid]).contents({:filters => [['uuid', 'is_a', "arvados\##{ArvadosApiClient.class_kind(model_class)}"]]})
-      end
-      find_objects_for_index if !@objects
-    end
+    find_objects_for_index if !@objects
     respond_to do |f|
       if params[:partial]
         f.json {
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index d0b1515..5d1c49b 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -48,16 +48,12 @@ class CollectionsController < ApplicationController
 
     params[:limit] ||= 40
 
-    filter = [['link_class','=','name'],
-              ['head_uuid','is_a','arvados#collection']]
-
-    if params[:project_uuid] and !params[:project_uuid].empty?
-      filter << ['tail_uuid', '=', params[:project_uuid]]
-    end
-
-    @objects = Link.filter(filter)
+    @filters += [['link_class','=','name'],
+                 ['head_uuid','is_a','arvados#collection']]
 
+    @objects = Link
     find_objects_for_index
+
     @name_links = @objects
 
     @objects = Collection.
diff --git a/apps/workbench/app/views/application/_choose.html.erb b/apps/workbench/app/views/application/_choose.html.erb
index f292445..d2256ae 100644
--- a/apps/workbench/app/views/application/_choose.html.erb
+++ b/apps/workbench/app/views/application/_choose.html.erb
@@ -8,35 +8,37 @@
 
       <div class="modal-body">
         <div class="input-group">
+          <input type="text" class="form-control filterable-control" placeholder="Search" data-filterable-target=".modal.arv-choose .selectable-container"/>
           <% if params[:by_project] %>
-            <div class="input-group-btn">
+            <div class="input-group-btn" data-filterable-target=".modal.arv-choose .selectable-container">
               <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
-                Projects <span class="caret"></span>
+                Filter by project <span class="caret"></span>
               </button>
               <ul class="dropdown-menu" role="menu">
+                <li>
+                  <%= link_to '#', class: 'chooser-show-project' do %>
+                    Remove filter (search all projects)
+                  <% end %>
+                </li>
+                <li class="divider" />
                 <%= render partial: "projects_tree_menu", locals: {
                       :project_link_to => Proc.new do |pnode, &block|
                         link_to "#", {"class" => "chooser-show-project", "data-project-uuid" => pnode[:object].uuid }, &block
                        end,
-                      :top_button => Proc.new do %>
-                        <% link_to "#", {"class" => "chooser-show-project btn btn-xs btn-default pull-right" } do %>
-                          All <%= controller.model_class.class_for_display.pluralize.downcase %>
-                        <% end %>
-                      <% end %>
-                <% } %>
-                <li class="divider" />
-                <li><span class="navbar-text" id="chooser-breadcrumb">All <%= controller.model_class.class_for_display.pluralize.downcase %></span></li>
+                      :top_button => nil
+                    } %>
               </ul>
             </div>
           <% end %>
-          <input type="text" class="form-control filterable-control" placeholder="Search" data-filterable-target=".modal.arv-choose .selectable-container"/>
         </div>
+        <div style="height: 1em" />
         <div class="row" style="height: 20em">
 	  <div class="col-sm-6 container arv-filterable-list selectable-container"
 	       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-href="<%= next_page_href partial: true %>"
+	       data-infinite-content-href0="<%= url_for 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/application/_choose.js.erb b/apps/workbench/app/views/application/_choose.js.erb
index b033c9b..44c2cd9 100644
--- a/apps/workbench/app/views/application/_choose.js.erb
+++ b/apps/workbench/app/views/application/_choose.js.erb
@@ -5,24 +5,3 @@ $('body > .modal-container .modal .modal-footer .btn-primary').
     attr('data-action-href', '<%= j params[:action_href] %>').
     attr('data-method', '<%= j params[:action_method] %>').
     data('action-data', <%= raw params[:action_data] %>);
-$(".chooser-show-project").on("click", function() {
-  $("#choose-scroll").html("<div class=\"spinner spinner-32px spinner-h-center\"></div>");
-  $(".modal-dialog-preview-pane").html('');
-  var t = $(this);
-  var d = {
-      partial: true,
-      multiple: <%= multiple || "false" %>
-    };
-  if (t.attr("data-project-uuid") != null) {
-    d.project_uuid = t.attr("data-project-uuid");
-  }
-  $.ajax('<%=j url_for %>', {
-    dataType: "json",
-    type: "GET",
-    data: d
-  }).done(function(data, status, jqxhr) {
-    $("#chooser-breadcrumb").text(t.text());
-    $("#choose-scroll").html(data.content);
-    $("#choose-scroll").prop("data-infinite-content-href", "next_page_href");
-  });
-});
diff --git a/apps/workbench/app/views/application/_projects_tree_menu.html.erb b/apps/workbench/app/views/application/_projects_tree_menu.html.erb
index 876b0be..3a1aa9e 100644
--- a/apps/workbench/app/views/application/_projects_tree_menu.html.erb
+++ b/apps/workbench/app/views/application/_projects_tree_menu.html.erb
@@ -1,5 +1,5 @@
               <li role="presentation" class="dropdown-header">
-                <%= top_button.call %>
+                <%= top_button.andand.call %>
                 My projects
               </li>
               <% my_project_tree.each do |pnode| %>
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 715acf9..86a6892 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -79,6 +79,7 @@
                        action: 'choose',
                        controller: 'search',
                        title: 'Search',
+                       by_project: true,
                        action_name: 'Show',
                        action_href: url_for(controller: :actions, action: :show),
                        action_method: 'get',
diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index 8464a4a..58d14fd 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -35,7 +35,7 @@ class ApplicationController < ActionController::Base
                 except: [:index, :create] + ERROR_ACTIONS)
   before_filter :load_limit_offset_order_params, only: [:index, :contents]
   before_filter :load_where_param, only: [:index, :contents]
-  before_filter :load_filters_param, only: [:index, :contents]
+  before_filter :load_filters_param, only: [:index, :contents, :choose]
   before_filter :find_objects_for_index, :only => :index
   before_filter :reload_object_before_update, :only => :update
   before_filter(:render_404_if_no_object,

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list