Skip to content

Commit

Permalink
#4051 - force download all if user clicks on "all" checkbox at top of…
Browse files Browse the repository at this point in the history
… files table
  • Loading branch information
sekmiller committed Dec 6, 2017
1 parent 4648b6a commit 5605168
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2068,8 +2068,16 @@ public void validateFilesForDownload(boolean guestbookRequired){
requestContext.execute("PF('selectFilesForDownload').show()");
return;
}

List<FileMetadata> allFiles = new ArrayList<>();


if (isSelectAllFiles()){
workingVersion.getFileMetadatas().forEach((fm) -> {
allFiles.add(fm);
});
this.selectedFiles = allFiles;
}

for (FileMetadata fmd : this.selectedFiles){
if(this.fileDownloadHelper.canDownloadFile(fmd)){
getSelectedDownloadableFiles().add(fmd);
Expand Down Expand Up @@ -2109,8 +2117,16 @@ public void setSelectAllFiles(boolean selectAllFiles) {
this.selectAllFiles = selectAllFiles;
}

public void toggleSelectedFiles(){
//method for when user clicks (de-)select all files
public void toggleAllSelected(){
System.out.print("in toggle all");
this.selectAllFiles = !this.selectAllFiles;
toggleSelectedFiles(this.selectAllFiles);
}



public void toggleSelectedFiles(boolean selectAllFiles){

this.selectedFiles = new ArrayList<>();
if(this.selectAllFiles){
for (FileMetadata fmd : workingVersion.getFileMetadatas()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/filesFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
selection="#{DatasetPage.selectedFiles}" var="fileMetadata" widgetVar="filesTable"
rendered="#{empty DatasetPage.editMode and (DatasetPage.workingVersion != null)}"
emptyMessage="#{bundle['file.notFound.tip']}">
<p:ajax event="toggleSelect" listener="#{DatasetPage.toggleAllSelected()}" />
<f:facet name="header">
<div class="row form-inline" jsf:id="cloudStorageBlock" jsf:rendered="#{DatasetPage.showComputeButton()}">
<!-- Cloud Storage Access -->
Expand Down

0 comments on commit 5605168

Please sign in to comment.