Fixed styling of selection dropdown menu.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 7 Mar 2014 18:34:24 +0000 (13:34 -0500)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 7 Mar 2014 18:34:24 +0000 (13:34 -0500)
Menu no longer dismisses when clicking a checkbox to remove an item.
Selected files no longer have /./ in the middle.
Fixed nil error when non-file or non-collection items are in the selection list.
Fixed head_kind and tail_kind.
Made a comment about inline x-editable.

apps/workbench/app/assets/javascripts/editable.js
apps/workbench/app/assets/javascripts/selection.js
apps/workbench/app/assets/stylesheets/application.css.scss
apps/workbench/app/controllers/actions_controller.rb
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/models/collection.rb
apps/workbench/app/views/collections/_show_files.html.erb

index a74358694213fe36041d32852111741bf1581f1a..79bad15e774cf9b2b19bb034bf0bfdc34e005cac 100644 (file)
@@ -1,6 +1,14 @@
 $.fn.editable.defaults.ajaxOptions = {type: 'put', dataType: 'json'};
 $.fn.editable.defaults.send = 'always';
+
+// Default for editing is popup.  I experimented with inline which is a little
+// nicer in that it shows up right under the mouse instead of nearby.  However,
+// the inline box is taller than the regular content, which causes the page
+// layout to shift unless we make the table rows tall, which leaves a lot of
+// wasted space when not editing.  Also inline can get cut off if the page is
+// too narrow, when the popup box will just move to do the right thing.
 //$.fn.editable.defaults.mode = 'inline';
+
 $.fn.editable.defaults.params = function (params) {
     var a = {};
     var key = params.pk.key;
index c94a557f8681daaa45524f666a49451595c6322a..27d63d1b023f85939cbe9a4973379b814015eada 100644 (file)
@@ -52,14 +52,17 @@ jQuery(function($){
         var lst = get_selection_list();
         $("#persistent-selection-count").text(lst.length);
         if (lst.length > 0) {
-            $('#selection-form-content').html('<li><input type="submit" name="combine_selected_files_into_collection" id="combine_selected_files_into_collection" value="Combine selected collections and files into a new collection"/></li>'
-                                                 + '<li><a href="#" id="clear_selections_button">Clear selections</a></li>'
-                                                 + '<li class="notification"><table style="width: 100%"></table></li>');
+            $('#selection-form-content').html(
+                '<li><a href="#" id="clear_selections_button">Clear selections</a></li>'
+                    + '<li><input type="submit" name="combine_selected_files_into_collection" '
+                    + ' id="combine_selected_files_into_collection" '
+                    + ' value="Combine selected collections and files into a new collection" /></li>'
+                    + '<li class="notification"><table style="width: 100%"></table></li>');
 
             for (var i = 0; i < lst.length; i++) {
                 $('#selection-form-content > li > table').append("<tr>"
                                                        + "<td>"
-                                                       + "<input class='remove-selection' name='selection[]' type='checkbox' value='" + lst[i].uuid + "' checked='true'></input>"
+                                                       + "<input class='remove-selection' name='selection[]' type='checkbox' value='" + lst[i].uuid + "' checked='true' data-stoppropagation='true' />"
                                                        + "</td>"
 
                                                        + "<td>"
@@ -109,6 +112,10 @@ jQuery(function($){
 
 
     $(window).on('load storage', update_count);
+
+    $('#selection-form-content').on("click", function(e) {
+        e.stopPropagation();
+    });
 });
 
 add_form_selection_sources = null;
index 7a26c709ff678842597383190822b2933ec84ee4..6a57f9e969f2f91b546a6ad5148d2edf9fb7e469 100644 (file)
@@ -185,10 +185,3 @@ table.table-fixed-header-row tbody {
     overflow-y: auto;
 }
 
-#persistent-selection-list {
-    width: 500px;
-}
-
-#persistent-selection-list li table tr {
-  border-top: 1px solid rgb(221, 221, 221);
-}
index c443c2196e372414c1d6e3361dc8e12f294c9527..74e5831235cf9e881df0df18c3f7ec4c9f1c91ff 100644 (file)
@@ -1,10 +1,13 @@
 class ActionsController < ApplicationController
+
+  skip_before_filter :find_object_by_uuid, only: :post
+
   def combine_selected_files_into_collection
     lst = []
     files = []
     params["selection"].each do |s|
       m = CollectionsHelper.match(s)
-      if m[1] and m[2]
+      if m and m[1] and m[2]
         lst.append(m[1] + m[2])
         files.append(m)
       end
@@ -73,9 +76,9 @@ class ActionsController < ApplicationController
 
     chash.each do |k,v|
       l = Link.new({
-                     tail_kind: "arvados#Collection",
+                     tail_kind: "arvados#collection",
                      tail_uuid: k,
-                     head_kind: "arvados#Collection", 
+                     head_kind: "arvados#collection", 
                      head_uuid: newuuid,
                      link_class: "provenance",
                      name: "provided"
@@ -83,12 +86,12 @@ class ActionsController < ApplicationController
       l.save!
     end
 
-    '/collections/' + newc.uuid
+    redirect_to controller: 'collections', action: :show, id: newc.uuid
   end
 
   def post
     if params["combine_selected_files_into_collection"]
-      redirect_to combine_selected_files_into_collection
+      combine_selected_files_into_collection
     else
       redirect_to :back
     end
index 2790f96472f0cac1633340465bc8524bf20f6940..412f86ce07a6b874d05b7d5d796bb84a9017bf09 100644 (file)
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
   around_filter :thread_clear
   around_filter :thread_with_mandatory_api_token, :except => [:render_exception, :render_not_found]
   around_filter :thread_with_optional_api_token
-  before_filter :find_object_by_uuid, :except => [:index, :post, :render_exception, :render_not_found]
+  before_filter :find_object_by_uuid, :except => [:index, :render_exception, :render_not_found]
   before_filter :check_user_agreements, :except => [:render_exception, :render_not_found]
   before_filter :check_user_notifications, :except => [:render_exception, :render_not_found]
   theme :select_theme
index fd6b4e4efc4cf23b6d6d2f0fe18f6d0c9a027dd7..6bc55bde3d21199fda4c31fa3143800d9b03c026 100644 (file)
@@ -26,22 +26,4 @@ class Collection < ArvadosBase
     $arvados_api_client.api "collections/#{self.uuid}/", "used_by"
   end
 
-  # def selection_label
-  #   name = ''
-  #   i = 0 
-  #   if self.files.length > 3
-  #     m = 3
-  #   else
-  #     m = self.files.length 
-  #   end
-  #   while i < m
-  #     name += "#{self.files[i][1]}"
-  #     i += 1
-  #     name += ", " if i < m
-  #   end
-  #   if i < self.files.length
-  #     name += "&ellip;"
-  #   end
-  #   name
-  # end
 end
index 6600a40844cdd26bb81135810d885b05ed2d3de0..956958eddb9fe0785946eb7a36bd0f866e00996e 100644 (file)
     </tr>
   </thead><tbody>
     <% if @object then @object.files.sort_by{|f|[f[0],f[1]]}.each do |file| %>
-    <% file_path = "#{file[0]}/#{file[1]}" %>
-    <tr>
-      <td>
-        <%= check_box_tag 'uuids[]', @object.uuid+'/'+file_path, false, {
-              :class => 'persistent-selection', 
-              :friendly_type => "File",
-              :friendly_name => "#{@object.uuid}/#{file_path}",
-              :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}" 
-            } %>
-      </td>
-      <td>
-        <%= file[0] %>
-      </td>
+      <% f0 = file[0] %>
+      <% f0 = '' if f0 == '.' %>
+      <% f0 = f0[2..-1] if f0[0..1] == './' %>
+      <% f0 += '/' if not f0.empty? %>
+      <% file_path = "#{f0}#{file[1]}" %>
+      <tr>
+        <td>
+          <%= check_box_tag 'uuids[]', @object.uuid+'/'+file_path, false, {
+                :class => 'persistent-selection', 
+                :friendly_type => "File",
+                :friendly_name => "#{@object.uuid}/#{file_path}",
+                :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}" 
+              } %>
+        </td>
+        <td>
+          <%= file[0] %>
+        </td>
 
-      <td>
-        <%= link_to file[1], {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {title: 'View in browser'} %>
-      </td>
+        <td>
+          <%= link_to file[1], {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {title: 'View in browser'} %>
+        </td>
 
-      <td style="text-align:right">
-        <%= raw(human_readable_bytes_html(file[2])) %>
-      </td>
+        <td style="text-align:right">
+          <%= raw(human_readable_bytes_html(file[2])) %>
+        </td>
 
-      <td>
-        <div style="display:inline-block">
-          <%= link_to raw('<i class="glyphicon glyphicon-download-alt"></i>'), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'attachment'}, {class: 'btn btn-info btn-sm', title: 'Download'} %>
-        </div>
-      </td>
-    </tr>
+        <td>
+          <div style="display:inline-block">
+            <%= link_to raw('<i class="glyphicon glyphicon-download-alt"></i>'), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'attachment'}, {class: 'btn btn-info btn-sm', title: 'Download'} %>
+          </div>
+        </td>
+      </tr>
     <% end; end %>
   </tbody>
 </table>