9587: untrash option
authorradhika <radhika@curoverse.com>
Wed, 31 May 2017 17:33:19 +0000 (13:33 -0400)
committerradhika <radhika@curoverse.com>
Wed, 31 May 2017 17:33:19 +0000 (13:33 -0400)
apps/workbench/app/assets/javascripts/selection.js.erb
apps/workbench/app/controllers/trash_items_controller.rb
apps/workbench/app/views/trash_items/_show_trash_items.html.erb
apps/workbench/app/views/trash_items/_untrash_item.html.erb
apps/workbench/app/views/trash_items/untrash_items.js.erb [moved from apps/workbench/app/views/trash_items/untrashed_items.js.erb with 78% similarity]
apps/workbench/config/routes.rb

index f60bef7ddb432cda137c935f395b1a46abe997ad..a8e2738fe0ed69c8f4850b1bb9fef8bb3b1b1ab2 100644 (file)
@@ -81,6 +81,10 @@ function enable_disable_selection_actions() {
         toggleClass('disabled',
                     ($checked.length < 0) ||
                     !($checked.length > 0 && collection_lock_classes && collection_lock_classes.indexOf("fa-unlock") !=-1));
+    $('[data-selection-action=untrash-selected-items]', $container).
+        closest('li').
+        toggleClass('disabled',
+                    ($checked.length < 1));
 }
 
 $(document).
index 17d334053f103a7931ac4c688731a4ef1094350b..5190474e903b7f0be113aec42d12ae449865bdd9 100644 (file)
@@ -72,23 +72,18 @@ class TrashItemsController < ApplicationController
     @request_url = request.url
   end
 
-  def untrash_item
-    params[:item_uuids] = [params[:item_uuid]]
-    untrash_items
-    render template: 'untrash_items'
-  end
-
   def untrash_items
     @untrashed_uuids = []
 
     updates = {trash_at: nil}
-    #updates[:trash_at] = nil
 
-    params[:item_uuids].collect { |uuid| ArvadosBase.find uuid }.each do |item|
+    params[:selection].collect { |uuid| ArvadosBase.find uuid }.each do |item|
       item.update_attributes updates
       @untrashed_uuids << item.uuid
     end
 
-    render_template :untrashed_items
+    respond_to do |format|
+      format.js
+    end
   end
 end
index 2b777fafd717fa45813b1994ff8dd5337cf579d2..dc615fc9ab55a4eccdcea5fe03691cdc8c27dbad 100644 (file)
@@ -1,13 +1,15 @@
-<div class="container">
+<div class="container selection-action-container">
   <div class="col-md-6 pull-left">
     <div class="btn-group btn-group-sm">
       <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Selection... <span class="caret"></span></button>
       <ul class="dropdown-menu" role="menu">
         <li><%= link_to "Un-trash selected items", '#',
                 method: :post,
+                remote: true,
+                'id' => 'untrash_selected_items',
                 'data-href' => untrash_items_trash_items_path,
                 'data-selection-param-name' => 'selection[]',
-                'data-selection-action' => 'untrash-items',
+                'data-selection-action' => 'untrash-selected-items',
                 'data-toggle' => 'dropdown'
           %></li>
       </ul>
index 7fd7af772341bc9bf5c64f8512743e6369b0565b..a40a4be7e1e74a6b6df96123b14eff54cae8ab69 100644 (file)
@@ -1,5 +1,5 @@
 <% if object.editable? %>
-  <%= link_to({action: 'untrash_item', id: object.uuid}, remote: true, data: {confirm: "Un-trash #{object.class_for_display.downcase} '#{object.friendly_link_name}'?"}) do %>
+  <%= link_to({action: 'untrash_items', selection: [object.uuid]}, remote: true, method: :post, data: {confirm: "Un-trash #{object.class_for_display.downcase} '#{object.friendly_link_name}'?"}) do %>
     <i class="fa fa-fw fa-recycle"></i>
   <% end %>
 <% end %>
similarity index 78%
rename from apps/workbench/app/views/trash_items/untrashed_items.js.erb
rename to apps/workbench/app/views/trash_items/untrash_items.js.erb
index 6d79acaef55d463f90b45a5bf1248e9df560eca0..3d266584aa8d00c00d3f6daa0fbd8c1e017ca22c 100644 (file)
@@ -1,4 +1,3 @@
-$(document).trigger('count-change');
 <% @untrashed_uuids.each do |uuid| %>
        $('[data-object-uuid=<%= uuid %>]').hide('slow', function() {
            $(this).remove();
index 8ac726c4f58eb1015d57592fd667a04830bcb7b7..badb471d64ae666924fb06a21a408237bbed3f26 100644 (file)
@@ -110,7 +110,6 @@ ArvadosWorkbench::Application.routes.draw do
 
   get "trash" => 'trash_items#index', :as => :trash
   resources :trash_items do
-    post 'untrash_item', on: :member
     post 'untrash_items', on: :collection
   end