Skip to content

Commit

Permalink
Fixed unnecessary duplicate file download javascript [ref #6684, #6943]
Browse files Browse the repository at this point in the history
  • Loading branch information
mheppler committed Jun 8, 2020
1 parent e7ebdd6 commit 90ac3a6
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/main/webapp/file-download-button-fragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -380,16 +380,6 @@

#{bundle['file.requestAccess']}
</p:commandLink>
<script type="text/javascript">
// NOTE... because of duplicate links for file and dataset pgs, also duplicated code from commit 73e42e24d6ed21c64a881391b03dbdc1e45361f0
function downloadFiles(url, filelist) {
filelist=filelist + ','; //Prevents last file from being dropped on server
var form = $('<form></form>').attr('action', url).attr('method', 'post').attr('enctype','text/plain');
form.append($("<input></input>").attr('type', 'hidden').attr('name', 'fileIds').attr('value', filelist));
//Submit and then remove form
form.appendTo('body').submit().remove();
}
</script>
</li>
<!-- END: FILE PG -->
<ui:fragment rendered="#{!isFilePg}">
Expand Down Expand Up @@ -424,16 +414,6 @@
<!-- 4.2.1 - TODO: retest this on a dataset with fileRequest enabled and with some files restricted to the user -->
<span class="glyphicon glyphicon-bullhorn"/><span class="sr-only">#{fileMetadata.dataFile.fileAccessRequesters.contains(dataverseSession.user) ? bundle['file.accessRequested'] : bundle['file.requestAccess']}</span>
</p:commandLink>
<script type="text/javascript">
// NOTE... because of duplicate links for file and dataset pgs, also duplicated code from commit 73e42e24d6ed21c64a881391b03dbdc1e45361f0
function downloadFiles(url, filelist) {
filelist=filelist + ','; //Prevents last file from being dropped on server
var form = $('<form></form>').attr('action', url).attr('method', 'post').attr('enctype','text/plain');
form.append($("<input></input>").attr('type', 'hidden').attr('name', 'fileIds').attr('value', filelist));
//Submit and then remove form
form.appendTo('body').submit().remove();
}
</script>
<!-- END: DATASET PG -->
</ui:fragment>
</ui:fragment>
Expand Down Expand Up @@ -570,5 +550,14 @@
<span class="glyphicon glyphicon-flash"/><span class="sr-only">#{bundle['file.compute']}</span>
</h:outputLink>
<!-- END: Compute Button *DATASET PG only*: -->


<script type="text/javascript">
function downloadFiles(url, filelist) {
filelist=filelist + ','; //Prevents last file from being dropped on server
var form = $('<form></form>').attr('action', url).attr('method', 'post').attr('enctype','text/plain');
form.append($("<input></input>").attr('type', 'hidden').attr('name', 'fileIds').attr('value', filelist));
//Submit and then remove form
form.appendTo('body').submit().remove();
}
</script>
</ui:composition>

0 comments on commit 90ac3a6

Please sign in to comment.