11465: add tooltips to disabled collection file controls
authorradhika <radhika@curoverse.com>
Thu, 13 Apr 2017 18:20:32 +0000 (14:20 -0400)
committerradhika <radhika@curoverse.com>
Thu, 13 Apr 2017 18:20:32 +0000 (14:20 -0400)
apps/workbench/app/assets/javascripts/edit_collection.js
apps/workbench/app/assets/stylesheets/collections.css.scss
apps/workbench/app/views/collections/_show_files.html.erb
apps/workbench/test/integration/collections_test.rb

index 7da3e95c068e1c9d892d25f1f0eb6a495055ecd1..ba0e82c1549f5efed3da2e197311b6fdc392f9b2 100644 (file)
@@ -2,8 +2,13 @@
 // disable all file modification controls (upload, rename, delete)
 $(document).
     ready(function(event) {
-        $(".btn-collection-file-control").addClass("disabled");
+        $(".btn-collection-file-rename").addClass("disabled");
+        $(".btn-collection-file-rename").attr("title", "Unlock collection to rename file");
+        $(".btn-collection-file-remove").addClass("disabled");
+        $(".btn-collection-file-remove").attr("title", "Unlock collection to remove file");
+        $(".btn-remove-selected-files").attr("title", "Unlock collection to remove selected files");
         $(".tab-pane-Upload").addClass("disabled");
+        $(".tab-pane-Upload").attr("title", "Unlock collection to upload files");
         $("#Upload-tab").attr("data-toggle", "disabled");
     }).
     on('click', '.lock-collection-btn', function(event) {
@@ -15,8 +20,13 @@ $(document).
                 $(".lock-collection-btn").removeClass("fa-lock");
                 $(".lock-collection-btn").addClass("fa-unlock");
                 $(".lock-collection-btn").attr("title", "Lock collection to prevent editing files");
-                $(".btn-collection-file-control").removeClass("disabled");
+                $(".btn-collection-file-rename").removeClass("disabled");
+                $(".btn-collection-file-rename").attr("data-original-title", "Edit name or path or both for this file");
+                $(".btn-collection-file-remove").removeClass("disabled");
+                $(".btn-collection-file-remove").attr("data-original-title", "Remove this file");
+                $(".btn-remove-selected-files").attr("title", "");
                 $(".tab-pane-Upload").removeClass("disabled");
+                $(".tab-pane-Upload").attr("data-original-title", "");
                 $("#Upload-tab").attr("data-toggle", "tab");
             } else {
                 // User clicked "no" and so do not unlock
@@ -26,8 +36,13 @@ $(document).
             $(".lock-collection-btn").removeClass("fa-unlock");
             $(".lock-collection-btn").addClass("fa-lock");
             $(".lock-collection-btn").attr("title", "Unlock collection to edit files");
-            $(".btn-collection-file-control").addClass("disabled");
+            $(".btn-collection-file-rename").addClass("disabled");
+            $(".btn-collection-file-rename").attr("data-original-title", "Unlock collection to rename file");
+            $(".btn-collection-file-remove").addClass("disabled");
+            $(".btn-collection-file-remove").attr("data-original-title", "Unlock collection to remove file");
+            $(".btn-remove-selected-files").attr("title", "Unlock collection to remove selected files");
             $(".tab-pane-Upload").addClass("disabled");
+            $(".tab-pane-Upload").attr("data-original-title", "Unlock collection to upload files");
             $("#Upload-tab").attr("data-toggle", "disabled");
         }
     });
index 2d2d0f25d12b462aeeed99f48646f53a4ee9a06d..cfb99e73b0cda17a62d9dd6871f4bd1cdede5c0c 100644 (file)
@@ -70,3 +70,11 @@ $active-bg: #39b3d7;
     padding: .5em 2em;
     margin: 0 1em;
 }
+
+.btn-collection-file-rename.disabled {
+    pointer-events: auto;
+}
+
+.btn-collection-file-remove.disabled {
+    pointer-events: auto;
+}
index 58695ecf373ff0213dd9ab52cb6c522d6d3bc4e6..c1c7d3b4c65ac2834c558e8c78ab1e9321f35f28 100644 (file)
@@ -33,7 +33,8 @@
                     'data-href' => url_for(controller: 'collections', action: :remove_selected_files),
                     'data-selection-param-name' => 'selection[]',
                     'data-selection-action' => 'remove-selected-files',
-                    'data-toggle' => 'dropdown'
+                    'data-toggle' => 'dropdown',
+                    'class' => 'btn-remove-selected-files'
               %></li>
             <% end %>
           </ul>
             <% end %>
 
             <% if object.editable? %>
-                <%= link_to({controller: 'collections', action: 'remove_selected_files', id: object.uuid, selection: [object.portable_data_hash+'/'+file_path]}, method: :post, remote: true, data: {confirm: "Remove #{file_path}?", toggle: 'tooltip', placement: 'top'}, class: 'btn btn-sm btn-default btn-nodecorate btn-collection-file-control', title: "Remove #{file_path}") do %>
+                <%= link_to({controller: 'collections', action: 'remove_selected_files', id: object.uuid, selection: [object.portable_data_hash+'/'+file_path]}, method: :post, remote: true, data: {confirm: "Remove #{file_path}?", toggle: 'tooltip', placement: 'top'}, class: 'btn btn-sm btn-default btn-nodecorate btn-collection-file-remove') do %>
                   <i class="fa fa-fw fa-trash-o"></i>
                 <% end %>
             <% end %>
         <% if CollectionsHelper::is_image(filename) %>
             <i class="fa fa-fw fa-bar-chart-o"></i>
               <% if object.editable? %>
-                <%= render_editable_attribute object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_path' => 'rename-file-path:'+file_path}, {tiptitle: 'Edit name or directory or both for this file'} %>
+                <%= render_editable_attribute object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_path' => 'rename-file-path:'+file_path}, {btnclass: 'collection-file-rename'} %>
               <% else %>
                 <%= filename %>
               <% end %>
          </div>
         <% else %>
               <% if object.editable? %>
-                <i class="fa fa-fw fa-file"></i><%= render_editable_attribute object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_name' => 'rename-file-path:'+file_path}, {tiptitle: 'Edit name or directory or both for this file', btnclass: 'collection-file-control'}  %>
+                <i class="fa fa-fw fa-file"></i><%= render_editable_attribute object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_name' => 'rename-file-path:'+file_path}, {btnclass: 'collection-file-rename'}  %>
               <% else %>
                 <i class="fa fa-fw fa-file" href="<%=object.uuid%>/<%=file_path%>" ></i> <%= filename %>
               <% end %>
index 20a403d4b221cf50ecbe52a5e19d7014a06d939c..203d08d500cb390c2a97fe400ae941561490248f 100644 (file)
@@ -379,10 +379,8 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     assert_selector 'a[data-toggle="disabled"]', text: 'Upload'
 
     within('.collection_files') do
-      file_ctrls = page.all('.btn-collection-file-control')
-      assert_equal 2, file_ctrls.size
-      assert_equal true, file_ctrls[0]['class'].include?('disabled')
-      assert_equal true, file_ctrls[1]['class'].include?('disabled')
+      assert_equal true, page.all('.btn-collection-file-rename')[0]['class'].include?('disabled')
+      assert_equal true, page.all('.btn-collection-file-remove')[0]['class'].include?('disabled')
       find('input[type=checkbox]').click
     end
 
@@ -398,10 +396,9 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     assert_selector 'a', text: 'Upload'
 
     within('.collection_files') do
-      file_ctrls = page.all('.btn-collection-file-control')
-      assert_equal 2, file_ctrls.size
-      assert_equal false, file_ctrls[0]['class'].include?('disabled')
-      assert_equal false, file_ctrls[1]['class'].include?('disabled')
+      assert_equal false, page.all('.btn-collection-file-rename')[0]['class'].include?('disabled')
+      assert_equal false, page.all('.btn-collection-file-remove')[0]['class'].include?('disabled')
+
       # previous checkbox selection won't result in firing a new event;
       # undo and redo checkbox to fire the selection event again
       find('input[type=checkbox]').click