[ARVADOS] updated: 419fb180375ea9087df1418f245581a5c4a7ba74
git at public.curoverse.com
git at public.curoverse.com
Thu Aug 28 15:21:48 EDT 2014
Summary of changes:
apps/workbench/app/assets/javascripts/selection.js | 9 +++---
.../app/controllers/projects_controller.rb | 36 +++++++++++++++++++---
.../workbench/app/views/application/_choose.js.erb | 2 +-
.../app/views/projects/_show_tab_contents.html.erb | 29 ++++++++++++-----
apps/workbench/config/routes.rb | 1 +
5 files changed, 59 insertions(+), 18 deletions(-)
via 419fb180375ea9087df1418f245581a5c4a7ba74 (commit)
from d1f510e7fa9f1b2656c54c1e9b3ea4e4466c9d1e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 419fb180375ea9087df1418f245581a5c4a7ba74
Author: radhika <radhika at curoverse.com>
Date: Thu Aug 28 15:19:05 2014 -0400
3637: add copy selected items functionality to project selection dropdown.
diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js
index a313c8b..4ab0295 100644
--- a/apps/workbench/app/assets/javascripts/selection.js
+++ b/apps/workbench/app/assets/javascripts/selection.js
@@ -57,10 +57,6 @@ jQuery(function($){
$("#persistent-selection-count").text(lst.length);
if (lst.length > 0) {
html = '<li><a href="#" class="btn btn-xs btn-info" id="clear_selections_button"><i class="fa fa-fw fa-ban"></i> Clear selections</a></li>';
- if (this_object_uuid.match('-j7d0g-')) {
- html += '<li><button class="btn btn-xs btn-info" type="submit" name="copy_selections_into_project" id="copy_selections_into_project"><i class="fa fa-fw fa-copy"></i> Copy selections into this project</button></li>';
- html += '<li><button class="btn btn-xs btn-info" type="submit" name="move_selections_into_project" id="move_selections_into_project"><i class="fa fa-fw fa-truck"></i> Move selections into this project</button></li>';
- }
html += '<li><button class="btn btn-xs btn-info" type="submit" name="combine_selected_files_into_collection" '
+ ' id="combine_selected_files_into_collection">'
+ '<i class="fa fa-fw fa-archive"></i> Combine selected collections and files into a new collection</button></li>'
@@ -212,6 +208,11 @@ function enable_disable_selection_actions() {
toggleClass('disabled',
($checked.filter('[value*=-d1hrv-]').length < 2) ||
($checked.not('[value*=-d1hrv-]').length > 0));
+ $('[data-selection-action=copy]').
+ closest('li').
+ toggleClass('disabled',
+ ($checked.filter('[value*=-j7d0g-]').length > 0) ||
+ (($checked.not('[value*=-d1hrv-]').length > 0) && ($checked.filter('[value*=-]').length < 0)));
}
$(document).
diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb
index 0b14679..e96d3dd 100644
--- a/apps/workbench/app/controllers/projects_controller.rb
+++ b/apps/workbench/app/controllers/projects_controller.rb
@@ -77,29 +77,55 @@ class ProjectsController < ApplicationController
end
end
+ def copy_items
+ move_or_copy_items :copy
+ end
+
def move_items
+ move_or_copy_items :move
+ end
+
+ def move_or_copy_items action
target_uuid = params['target']
- uuids_to_add = session[:selected_move_items]
+ uuids_to_add = session[:selected_move_or_copy_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|
+ resource_class.filter([['uuid','in',uuids_to_add]]).each do |src|
if resource_class == Collection and not Collection.attribute_info.include?(:name)
dst = Link.new(owner_uuid: target_uuid,
tail_uuid: target_uuid,
- head_uuid: dst.uuid,
+ head_uuid: src.uuid,
link_class: 'name',
- name: target_uuid)
+ name: src.uuid)
else
+ case action
+ when :copy
+ dst = src.dup
+ if dst.respond_to? :'name='
+ if dst.name
+ dst.name = "Copy of #{dst.name}"
+ else
+ dst.name = "Copy of unnamed #{dst.class_for_display.downcase}"
+ end
+ end
+ if resource_class == Collection
+ dst.manifest_text = Collection.select([:manifest_text]).where(uuid: src.uuid).first.manifest_text
+ end
+ when :move
+ dst = src
+ else
+ raise ArgumentError.new "Unsupported action #{action}"
+ end
dst.owner_uuid = target_uuid
dst.tail_uuid = target_uuid if dst.class == Link
end
dst.save!
end
end
- session[:selected_move_items] = nil
+ session[:selected_move_or_copy_items] = nil
redirect_to @object
end
diff --git a/apps/workbench/app/views/application/_choose.js.erb b/apps/workbench/app/views/application/_choose.js.erb
index c482b45..b91a619 100644
--- a/apps/workbench/app/views/application/_choose.js.erb
+++ b/apps/workbench/app/views/application/_choose.js.erb
@@ -1,4 +1,4 @@
-<% session[:selected_move_items] = params['move_items'] if params['move_items'] %>
+<% session[:selected_move_or_copy_items] = params['move_or_copy_items'] if params['move_or_copy_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').
diff --git a/apps/workbench/app/views/projects/_show_tab_contents.html.erb b/apps/workbench/app/views/projects/_show_tab_contents.html.erb
index 8fb588f..24aa0c0 100644
--- a/apps/workbench/app/views/projects/_show_tab_contents.html.erb
+++ b/apps/workbench/app/views/projects/_show_tab_contents.html.erb
@@ -9,15 +9,20 @@
'data-selection-param-name' => 'uuids[]',
'data-selection-action' => 'compare'
%></li>
- <li><%= link_to "Remove selected", '#',
- 'data-href' => url_for(action: :remove_items),
- 'data-selection-param-name' => 'item_uuids[]',
- 'data-selection-action' => 'remove',
+ <li><%= link_to "Copy selected", '#',
+ 'data-href' => choose_projects_path(
+ title: 'Copy into...',
+ editable: true,
+ action_name: 'Copy',
+ action_href: copy_items_project_path,
+ action_method: 'get',
+ action_data: {selection_param: 'target',
+ success: 'page-refresh'}.to_json),
'data-remote' => true,
- 'method' => 'delete',
- 'data-toggle' => 'dropdown'
+ 'data-selection-param-name' => 'move_or_copy_items[]',
+ 'data-selection-action' => 'copy'
%></li>
- <li><%= link_to "Move selected", '#',
+ <li><%= link_to "Move selected", '#',
'data-href' => choose_projects_path(
title: 'Move to...',
editable: true,
@@ -27,9 +32,17 @@
action_data: {selection_param: 'target',
success: 'page-refresh'}.to_json),
'data-remote' => true,
- 'data-selection-param-name' => 'move_items[]',
+ 'data-selection-param-name' => 'move_or_copy_items[]',
'data-selection-action' => 'move'
%></li>
+ <li><%= link_to "Remove selected", '#',
+ 'data-href' => url_for(action: :remove_items),
+ 'data-selection-param-name' => 'item_uuids[]',
+ 'data-selection-action' => 'remove',
+ 'data-remote' => true,
+ 'method' => 'delete',
+ 'data-toggle' => 'dropdown'
+ %></li>
</ul>
</div>
</div>
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index e58796e..7c87b59 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -70,6 +70,7 @@ ArvadosWorkbench::Application.routes.draw do
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 'copy_items', on: :member, action: :copy_items
get 'move_items', on: :member, action: :move_items
get 'choose', on: :collection
post 'share_with', on: :member
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list