3661: Added buttons for Copy and Move to the general #show page, showing them if...
authorPhil Hodgson <bitbucket@philhodgson.net>
Wed, 10 Sep 2014 16:48:54 +0000 (12:48 -0400)
committerPhil Hodgson <bitbucket@philhodgson.net>
Wed, 10 Sep 2014 16:48:54 +0000 (12:48 -0400)
apps/workbench/app/views/application/show.html.erb
apps/workbench/app/views/collections/show.html.erb
apps/workbench/app/views/projects/show.html.erb
services/api/app/models/arvados_model.rb

index 490e7e4e12cd8fcc982cf2f60f50549d3fa4b8eb..264e019dc0b004e579f1805c97c4bf39f63c3376 100644 (file)
@@ -6,6 +6,43 @@
 
 <% content_for :content_top do %>
 
+<% if @object.class.goes_in_projects? && @object.uuid != current_user.uuid # Not the "Home" project %>
+  <% content_for :tab_line_buttons do %>
+    <%= link_to(
+        choose_projects_path(
+         title: 'Copy to project...',
+         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", remote: true, method: 'get' }) do %>
+      <i class="fa fa-fw fa-copy"></i> Copy to project...
+    <% end %>
+    <% if @object.owner_uuid == current_user.uuid or (Group.find(@object.owner_uuid).writable_by.include?(current_user.uuid) rescue nil) %>
+      <%= link_to(
+          choose_projects_path(
+           title: 'Move to project...',
+           action_name: 'Move',
+           action_href: actions_path,
+           action_method: 'post',
+           action_data: {
+             move_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", remote: true, method: 'get' }) do %>
+        <i class="fa fa-fw fa-truck"></i> Move to project...
+      <% end %>
+    <% end %>
+  <% end %>
+<% end %>
+
 <% if @object.respond_to? :properties and !@object.properties.nil? %>
   <% if @object.properties[:page_content] %>
     <% content_for :page_content do %>
index 94b099a25c8c7256a3a63430080a0778d7f9d7c9..41458f7909a92db3fcb036806d07c75691a091d9 100644 (file)
@@ -1,21 +1,3 @@
-<% content_for :tab_line_buttons do %>
-  <%= link_to(
-      choose_projects_path(
-       title: 'Copy to project...',
-       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 2551760ff2e5ad15dee9457d526bffee3579cdea..a67f2addf61a38ccd3106602af40bd827a2266d4 100644 (file)
       Add a subproject
     <% end %>
   <% end %>
-  <% if @object.owner_uuid == current_user.uuid or (Group.find(@object.owner_uuid).writable_by.include?(current_user.uuid) rescue nil) %>
-    <% if @object.uuid != current_user.uuid # Not the "Home" project %>
-      <%= link_to(
-          choose_projects_path(
-           title: 'Move this project to...',
-           editable: true,
-           action_name: 'Move',
-           action_href: project_path(@object.uuid),
-           action_method: 'put',
-           action_data: {selection_param: 'project[owner_uuid]', success: 'page-refresh'}.to_json),
-          { class: "btn btn-sm btn-primary arv-move-to-project", remote: true, method: 'get' }) do %>
-        <i class="fa fa-fw fa-truck"></i> Move project...
-      <% end %>
-      <%= link_to(project_path(id: @object.uuid), method: 'delete', class: 'btn btn-sm btn-primary', data: {confirm: "Really delete project '#{@object.name}'?"}) do %>
-        <i class="fa fa-fw fa-trash-o"></i> Delete project
-      <% end %>
-    <% end %>
-  <% end %>
 <% end %>
 
 <%= render file: 'application/show.html.erb', locals: local_assigns %>
index 1138bd2b9b4f8412336e3c9f41dd23355dbf460c..4ef62c99c7b33445840aefdc470f12f7c73d8e9f 100644 (file)
@@ -205,6 +205,12 @@ class ArvadosModel < ActiveRecord::Base
                head_uuid: target_uuid).any?
   end
 
+  # can this class of object go into a project?
+  # default to false, override to true on individual model classes
+  def self.goes_in_projects?
+    false
+  end
+
   protected
 
   def ensure_ownership_path_leads_to_user