-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
51 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/assets/javascripts/curation_concerns/single_use_links.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Blacklight.onLoad(function () { | ||
|
||
function updateLinkRows() { | ||
var url = $('table.single-use-links tbody').data('url') | ||
$.get(url).done(function(data) { | ||
$('table.single-use-links tbody').html(data); | ||
}); | ||
} | ||
|
||
$('.generate-single-use-link').click(function(event) { | ||
event.preventDefault(); | ||
$.post($(this).attr('href')).done(function(data) { | ||
updateLinkRows(); | ||
}); | ||
return false; | ||
}); | ||
|
||
$('table.single-use-links').on('click', '.delete-single-use-link', function(event) { | ||
event.preventDefault(); | ||
$.ajax({ | ||
url: $(this).attr('href'), | ||
type: 'DELETE', | ||
done: $(this).parent('td').parent('tr').remove() | ||
}); | ||
return false; | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/views/curation_concerns/file_sets/_single_use_link_rows.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% single_use_links.each_with_index do |link, index| %> | ||
<tr> | ||
<td><%= link.path =~ /downloads/ ? 'Download' : 'Show' %></td> | ||
<td><%= link.downloadKey %></td> | ||
<td><%= link.expires %></td> | ||
<td> | ||
<%= link_to "Copy to Clipboard", "/", class: 'btn btn-xs btn-default' %> | ||
<%= link_to "Delete", curation_concerns.delete_single_use_link_path(params[:id], link), | ||
class: 'btn btn-xs btn-danger delete-single-use-link' %> | ||
</td> | ||
</tr> | ||
<% end %> |
21 changes: 5 additions & 16 deletions
21
app/views/curation_concerns/file_sets/_single_use_links.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,20 @@ | ||
<table class="table table-striped <%= dom_class(presenter) %> single_use_links"> | ||
<table class="table table-striped <%= dom_class(presenter) %> single-use-links"> | ||
<caption class="table-heading"><h2>Single-Use Links</h2></caption> | ||
<thead> | ||
<tr><th>Link</th><th>Key</th><th>Expires</th><th>Actions</th></tr> | ||
</thead> | ||
<tbody> | ||
<tbody data-url="<%= curation_concerns.generated_single_use_links_path(presenter) %>"> | ||
<% if presenter.single_use_links.empty? %> | ||
<tr><td>No links have been genereated</td></tr> | ||
<% else %> | ||
<% presenter.single_use_links.each do |link| %> | ||
<tr> | ||
<td><%= link.path =~ /downloads/ ? 'Download' : 'Show' %></td> | ||
<td><%= link.downloadKey %></td> | ||
<td><%= link.expires %></td> | ||
<td> | ||
<%= link_to "Copy to Clipboard", "/", class: 'btn btn-xs btn-default' %> | ||
<%= link_to "Delete", delete_single_use_link_path(presenter, link), | ||
method: :delete, class: 'btn btn-xs btn-danger' %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
<%= render partial: 'single_use_link_rows', locals: { single_use_links: presenter.single_use_links } %> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<div class="form_actions"> | ||
<%= link_to "Generate Download Link", curation_concerns.generate_download_single_use_link_path(presenter), | ||
method: :post, class: 'btn btn-default' %> | ||
class: 'btn btn-default generate-single-use-link' %> | ||
<%= link_to "Generate Show Link", curation_concerns.generate_show_single_use_link_path(presenter), | ||
method: :post, class: 'btn btn-default' %> | ||
class: 'btn btn-default generate-single-use-link' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters