Skip to content

Commit

Permalink
#4813 update messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Jul 28, 2020
1 parent 5522e5d commit 2d60309
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
39 changes: 37 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,25 @@ public void deleteMarkedAsDuplicateFiles() {

Iterator<FileMetadata> fmItr = fileMetadatas.iterator();

while (fmItr.hasNext()){
String fileNames = null;
while (fmItr.hasNext()) {
FileMetadata test = fmItr.next();
if(test.isMarkedAsDuplicate()){
if (test.isMarkedAsDuplicate()) {
if (fileNames == null) {
fileNames = test.getLabel();
} else {
fileNames = fileNames.concat(", " + test.getLabel());
}
fmItr.remove();
}
}

if (fileNames != null) {
String successMessage = getBundleString("file.deleted.upload.success");
logger.fine(successMessage);
successMessage = successMessage.replace("{0}", fileNames);
JsfHelper.addFlashMessage(successMessage);
}

if (isFileReplaceOperation()){
try {
Expand Down Expand Up @@ -988,8 +1001,12 @@ public void deleteFiles() {

}
}

if (fileNames != null) {
String successMessage = getBundleString("file.deleted.success");
if (mode == FileEditMode.UPLOAD) {
successMessage = getBundleString("file.deleted.upload.success");
}
logger.fine(successMessage);
successMessage = successMessage.replace("{0}", fileNames);
JsfHelper.addFlashMessage(successMessage);
Expand Down Expand Up @@ -1792,6 +1809,7 @@ public void uploadFinished() {
if (existingFilesWithDupeContent != null || newlyUploadedFilesWithDupeContent != null) {
setWarningMessageForAlreadyExistsPopUp(uploadWarningMessage);
setHeaderForAlreadyExistsPopUp();
setLabelForDeleteFilesPopup();
PrimeFaces.current().ajax().update("datasetForm:fileAlreadyExistsPopup");
PrimeFaces.current().executeScript("PF('fileAlreadyExistsPopup').show();");
}
Expand Down Expand Up @@ -1865,6 +1883,23 @@ public void setHeaderForAlreadyExistsPopUp(String headerForAlreadyExistsPopUp) {
this.headerForAlreadyExistsPopUp = headerForAlreadyExistsPopUp;
}

private String labelForDeleteFilesPopup;

public String getLabelForDeleteFilesPopup() {
return labelForDeleteFilesPopup;
}

public void setLabelForDeleteFilesPopup(String labelForDeleteFilesPopup) {
this.labelForDeleteFilesPopup = labelForDeleteFilesPopup;
}

public void setLabelForDeleteFilesPopup() {
this.labelForDeleteFilesPopup = ((multipleDupesExisting|| multipleDupesNew) ? BundleUtil.getStringFromBundle("file.delete.duplicate.multiple") :
BundleUtil.getStringFromBundle("file.delete.duplicate.single"));
}

//((multipleDupesExisting|| multipleDupesNew) ? BundleUtil.getStringFromBundle("file.addreplace.already_exists.header.multiple"): BundleUtil.getStringFromBundle("file.addreplace.already_exists.header"));

public void setHeaderForAlreadyExistsPopUp() {

this.headerForAlreadyExistsPopUp = ((multipleDupesExisting|| multipleDupesNew) ? BundleUtil.getStringFromBundle("file.addreplace.already_exists.header.multiple"): BundleUtil.getStringFromBundle("file.addreplace.already_exists.header"));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1507,10 +1507,12 @@ file.replaced.warning.draft.warningMessage=You can not replace a file that has b
file.replaced.warning.previous.warningMessage=You can not edit a file that has been replaced in a previous dataset version. In order to edit it you must go to the most recently published version of the file.
file.alreadyDeleted.previous.warningMessage=This file has already been deleted in current version. It may not be edited.
file.delete=Delete
file.delete.duplicate=Delete Duplicate File(s)
file.delete.duplicate.multiple=Delete Duplicate Files
file.delete.duplicate.single=Delete Duplicate File
file.metadata=Metadata
file.deleted.success=Files "{0}" will be permanently deleted from this version of this dataset once you click on the Save Changes button.
file.deleted.replacement.success=The replacement file has been deleted.
file.deleted.upload.success=Files "{0}" won\u2019t be included in this upload.
file.editAccess=Edit Access
file.restrict=Restrict
file.unrestrict=Unrestrict
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/editFilesFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@
</h:outputFormat>
</p>
<div class="button-block">
<p:commandButton styleClass="btn btn-default" value="#{bundle['file.delete.duplicate']}" onclick="PF('fileAlreadyExistsPopup').hide()" oncomplete="uploadWidgetDropMsg();"
<p:commandButton styleClass="btn btn-default" value="#{EditDatafilesPage.labelForDeleteFilesPopup}" onclick="PF('fileAlreadyExistsPopup').hide()" oncomplete="uploadWidgetDropMsg();"
action="#{EditDatafilesPage.deleteMarkedAsDuplicateFiles()}"
update=":#{p:resolveClientId('datasetForm:filesTable', view)},:messagePanel,:#{p:resolveClientId('datasetForm:fileUpload', view)},uploadMessage"/>
update=":#{p:resolveClientId('datasetForm:filesTable', view)},:messagePanel,:#{p:resolveClientId('datasetForm:fileUpload', view)},uploadMessage,@([id$=filesButtons])"/>
<button class="btn btn-default" onclick="PF('fileAlreadyExistsPopup').hide();" type="button">
#{bundle.continue}
</button>
Expand Down

0 comments on commit 2d60309

Please sign in to comment.