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).
@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
-<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>
<% 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 %>
-$(document).trigger('count-change');
<% @untrashed_uuids.each do |uuid| %>
$('[data-object-uuid=<%= uuid %>]').hide('slow', function() {
$(this).remove();
get "trash" => 'trash_items#index', :as => :trash
resources :trash_items do
- post 'untrash_item', on: :member
post 'untrash_items', on: :collection
end