end
end
+ def move_items
+ target_uuid = params['target']
+ uuids_to_add = session[:selected_move_items]
+
+ uuids_to_add.
+ collect { |x| ArvadosBase::resource_class_for_uuid(x) }.
+ uniq.
+ each do |resource_class|
+ resource_class.filter([['uuid','in',uuids_to_add]]).each do |dst|
+ if resource_class == Collection
+ dst = Link.new(owner_uuid: target_object.uuid,
+ tail_uuid: target_object.uuid,
+ head_uuid: target_uuid,
+ link_class: 'name',
+ name: target_uuid)
+ else
+ dst.owner_uuid = target_uuid
+ dst.tail_uuid = target_uuid if dst.class == Link
+ end
+ begin
+ dst.save!
+ rescue
+ dst.name += " (#{Time.now.localtime})" if dst.respond_to? :name=
+ dst.save!
+ end
+ end
+ end
+ session[:selected_move_items] = nil
+ redirect_to controller: 'projects', action: :show, id: target_uuid
+ end
+
def destroy
while (objects = Link.filter([['owner_uuid','=',@object.uuid],
['tail_uuid','=',@object.uuid]])).any?
+<% session[:selected_move_items] = params['move_items'] %>
$('body > .modal-container').html("<%= escape_javascript(render partial: 'choose.html', locals: {multiple: multiple}) %>");
$('body > .modal-container .modal').modal('show');
$('body > .modal-container .modal .modal-footer .btn-primary').
'data-remote' => true,
'method' => 'delete'
%></li>
- <li><%= link_to "Move selected", '#',
- 'data-href' => choose_projects_path(
+ <li><%= link_to "Move selected", '#',
+ 'data-href' => choose_projects_path(
title: 'Move to...',
editable: true,
action_name: 'Move',
- action_href: url_for(action: :move_selections_into_project,
- controller: 'actions'),
- action_method: 'patch',
- action_data: {selection_param: 'selection[]',
+ action_href: move_items_project_path,
+ action_method: 'get',
+ action_data: {selection_param: 'target',
success: 'page-refresh'}.to_json),
'data-remote' => true,
- 'data-selection-param-name' => 'selection[]',
- 'data-selection-action' => 'move'
+ 'data-selection-param-name' => 'move_items[]',
+ 'data-selection-action' => 'move'
%></li>
</ul>
</div>
resources :projects do
match 'remove/:item_uuid', on: :member, via: :delete, action: :remove_item
match 'remove_items', on: :member, via: :delete, action: :remove_items
+ get 'move_items', on: :member, action: :move_items
get 'choose', on: :collection
post 'share_with', on: :member
end
- match '/move_selections_into_project' => 'actions#move_selections_into_project', via: :patch
post 'actions' => 'actions#post'
get 'websockets' => 'websocket#index'