From 1db007eb53d0401a7a0ba168add7c4a094790fa5 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 23 May 2014 12:04:19 -0400 Subject: [PATCH] 2044: Sharing link now shown in "Sharing and permissions" panel, no longer uses a modal popup. Produces download link that is confirmed works. --- .../app/controllers/collections_controller.rb | 6 +++ .../collections/_sharing_button.html.erb | 19 +++++++--- .../views/collections/_sharing_popup.html.erb | 37 ------------------- .../views/collections/sharing_popup.js.erb | 1 - .../app/views/collections/show.html.erb | 2 +- 5 files changed, 21 insertions(+), 44 deletions(-) delete mode 100644 apps/workbench/app/views/collections/_sharing_popup.html.erb diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index 3e981e10d8..1d710419da 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -171,6 +171,12 @@ class CollectionsController < ApplicationController end end + helper_method :download_link + + def download_link + collections_url + "/download/#{@object.uuid}/#{@search_sharing.first.api_token}" + end + def share a = ApiClientAuthorization.create(scopes: sharing_scopes) @search_sharing = search_scopes.select { |s| s.scopes != ['all'] } diff --git a/apps/workbench/app/views/collections/_sharing_button.html.erb b/apps/workbench/app/views/collections/_sharing_button.html.erb index 36952d69d0..b2ed43ab31 100644 --- a/apps/workbench/app/views/collections/_sharing_button.html.erb +++ b/apps/workbench/app/views/collections/_sharing_button.html.erb @@ -1,8 +1,17 @@ <% if @search_sharing.any? %> - <% linktext = "Shared" %> - <% btnstyle = "btn-success" %> +
Shared at: + + <%= link_to "Unshare", unshare_collection_url, { + class: 'btn-xs btn-info', + remote: true, + method: 'post' + } %> +
<%= link_to download_link, download_link %>
+
<% else %> - <% linktext = "Share" %> - <% btnstyle = "btn-info" %> + <%= link_to "Create sharing link", share_collection_url, { + class: 'btn-xs btn-info', + remote: true, + method: 'post' + } %> <% end %> -<%= link_to linktext, sharing_popup_collection_url(id: @object.uuid), {class: "btn #{btnstyle}", :remote => true, 'data-toggle' => "modal", 'data-target' => '#collection-sharing-modal-window'} %> diff --git a/apps/workbench/app/views/collections/_sharing_popup.html.erb b/apps/workbench/app/views/collections/_sharing_popup.html.erb deleted file mode 100644 index f7f0555837..0000000000 --- a/apps/workbench/app/views/collections/_sharing_popup.html.erb +++ /dev/null @@ -1,37 +0,0 @@ - - diff --git a/apps/workbench/app/views/collections/sharing_popup.js.erb b/apps/workbench/app/views/collections/sharing_popup.js.erb index 933f08ddd8..d2e0d9fc65 100644 --- a/apps/workbench/app/views/collections/sharing_popup.js.erb +++ b/apps/workbench/app/views/collections/sharing_popup.js.erb @@ -1,2 +1 @@ -$("#collection-sharing-modal-window").html("<%= escape_javascript(render partial: 'sharing_popup') %>"); $("#sharing-button").html("<%= escape_javascript(render partial: 'sharing_button') %>"); diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb index c26b74c65a..0be6705a9d 100644 --- a/apps/workbench/app/views/collections/show.html.erb +++ b/apps/workbench/app/views/collections/show.html.erb @@ -79,7 +79,7 @@ --> -
+
<%= render partial: 'sharing_button' %>
-- 2.30.2