3114: Merge branch 'master' into 3114-copy-to-project
authorTom Clegg <tom@curoverse.com>
Mon, 18 Aug 2014 22:02:47 +0000 (18:02 -0400)
committerTom Clegg <tom@curoverse.com>
Mon, 18 Aug 2014 22:02:47 +0000 (18:02 -0400)
apps/workbench/app/controllers/actions_controller.rb
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/collections/show.html.erb
apps/workbench/app/views/projects/_choose.html.erb

index d1dc0fca354b7969d77317ec161a58d5f245ea62..265cff456ce760a1c850582def2bd709d3e750fb 100644 (file)
@@ -42,6 +42,7 @@ class ActionsController < ApplicationController
 
   def move_or_copy action
     uuids_to_add = params["selection"]
+    uuids_to_add = [ uuids_to_add ] unless uuids_to_add.is_a? Array
     uuids_to_add.
       collect { |x| ArvadosBase::resource_class_for_uuid(x) }.
       uniq.
index b62636166c1081c6528f0a0e29cdb7ff2b824ef2..98bc53ae4612d5efd25ef7a6dc96287bb2857bf9 100644 (file)
@@ -202,7 +202,7 @@ class ApplicationController < ActionController::Base
       return render_not_found("object not found")
     end
     respond_to do |f|
-      f.json { render json: @object.attributes.merge(href: url_for(@object)) }
+      f.json { render json: @object.attributes.merge(href: url_for(action: :show, id: @object)) }
       f.html {
         if params['tab_pane']
           render_pane params['tab_pane']
@@ -274,7 +274,7 @@ class ApplicationController < ActionController::Base
     @object ||= model_class.new @new_resource_attrs, params["options"]
     if @object.save
       respond_to do |f|
-        f.json { render json: @object.attributes.merge(href: url_for(@object)) }
+        f.json { render json: @object.attributes.merge(href: url_for(action: :show, id: @object)) }
         f.html {
           redirect_to @object
         }
index eb07fc3757c3eef7568098f5460060246e2ca4d3..189f295f8fe097c2a2a17e8a5f41342ed254eef0 100644 (file)
@@ -5,6 +5,14 @@ class UsersController < ApplicationController
   skip_before_filter :find_object_by_uuid, only: [:welcome, :activity, :storage]
   before_filter :ensure_current_user_is_admin, only: [:sudo, :unsetup, :setup]
 
+  def show
+    if params[:uuid] == current_user.uuid
+      redirect_to project_path(params[:uuid])
+    else
+      super
+    end
+  end
+
   def welcome
     if current_user
       redirect_to (params[:return_to] || '/')
index 83dcb4511bfbc36aaae6910492c48e777bcd9cf0..0d52b088c47a91f59bc1f46092d4a73e3fc51a34 100644 (file)
@@ -1,3 +1,22 @@
+<% content_for :tab_line_buttons do %>
+  <%= link_to(
+      choose_projects_path(
+       title: 'Copy to project...',
+       my_root_selectable: true,
+       action_name: 'Copy',
+       action_href: actions_path,
+       action_method: 'post',
+       action_data: {
+         copy_selections_into_project: true,
+         selection: @name_link.andand.uuid || @object.uuid,
+         selection_param: 'uuid',
+         success: 'redirect-to-created-object'
+       }.to_json),
+      { class: "btn btn-sm btn-primary arv-move-to-project", remote: true, method: 'get' }) do %>
+    <i class="fa fa-fw fa-copy"></i> Copy to project...
+  <% end %>
+<% end %>
+
 <div class="row row-fill-height">
   <div class="col-md-6">
     <div class="panel panel-info">
index 3d55041cb8ca834db93f954406e3e5801e8a5c87..82b948545073b9c5b6e0515d6935a6cf452f1478 100644 (file)
@@ -42,7 +42,7 @@
 
       <div class="modal-footer">
         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
-        <button class="btn btn-primary" aria-hidden="true"><%= params[:action_name] || 'Select' %></button>
+        <button class="btn btn-primary" aria-hidden="true" data-enable-if-selection disabled><%= params[:action_name] || 'Select' %></button>
         <div class="modal-error hide" style="text-align: left; margin-top: 1em;">
         </div>
       </div>