From f2cca68b1a9c796507708595a387551a7605fab1 Mon Sep 17 00:00:00 2001 From: Patrick Huang Date: Wed, 23 Sep 2015 15:45:04 +1000 Subject: [PATCH] disable upload button when user clear upload file --- .../java/org/zanata/action/GlossaryAction.java | 4 ++++ .../java/org/zanata/action/VersionHomeAction.java | 14 +++++++++++--- .../layout/glossary/upload_glossary_modal.xhtml | 4 ++++ .../layout/version/upload_translation_modal.xhtml | 2 ++ zanata-war/src/main/webapp/iteration/view.xhtml | 7 ++++++- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/action/GlossaryAction.java b/zanata-war/src/main/java/org/zanata/action/GlossaryAction.java index c8ec7a8730..4c2848fa43 100644 --- a/zanata-war/src/main/java/org/zanata/action/GlossaryAction.java +++ b/zanata-war/src/main/java/org/zanata/action/GlossaryAction.java @@ -166,6 +166,10 @@ public void glossaryFileUploaded(FileUploadEvent event) throws IOException { glossaryFileUpload.setFileName(uploadedFile.getName()); } + public void glossaryFileCleared() { + glossaryFileUpload = new GlossaryFileUploadHelper(); + } + /** * Helper class to upload glossary files. */ diff --git a/zanata-war/src/main/java/org/zanata/action/VersionHomeAction.java b/zanata-war/src/main/java/org/zanata/action/VersionHomeAction.java index ddf5f8ffc7..9ea150b433 100644 --- a/zanata-war/src/main/java/org/zanata/action/VersionHomeAction.java +++ b/zanata-war/src/main/java/org/zanata/action/VersionHomeAction.java @@ -772,8 +772,8 @@ public String sourceExtensionOf(String docPath, String docName) { public String translationExtensionOf(String docPath, String docName) { return "." + translationFileServiceImpl.getTranslationFileExtension( - projectSlug, - versionSlug, docPath, docName); + projectSlug, + versionSlug, docPath, docName); } public boolean hasOriginal(String docPath, String docName) { @@ -973,7 +973,7 @@ public boolean needDocumentTypeSelection(String fileName) { public List getDocumentTypes(String fileName) { return Lists.newArrayList( - translationFileServiceImpl.getDocumentTypes(fileName)); + translationFileServiceImpl.getDocumentTypes(fileName)); } public void setDefaultTranslationDocType(String fileName) { @@ -1067,12 +1067,20 @@ public void sourceFileUploaded(FileUploadEvent event) throws IOException { } + public void sourceFileCleared() { + sourceFileUpload = new SourceFileUploadHelper(); + } + public void transFileUploaded(FileUploadEvent event) throws IOException { UploadedFile uploadedFile = event.getUploadedFile(); translationFileUpload.setFileName(uploadedFile.getName()); translationFileUpload.setFileContents(uploadedFile.getInputStream()); } + public void transFileCleared() { + translationFileUpload = new TranslationFileUploadHelper(); + } + private class DocumentFilter extends InMemoryListFilter { private DocumentDAO documentDAO = ServiceLocator.instance().getInstance(DocumentDAO.class); diff --git a/zanata-war/src/main/webapp/WEB-INF/layout/glossary/upload_glossary_modal.xhtml b/zanata-war/src/main/webapp/WEB-INF/layout/glossary/upload_glossary_modal.xhtml index cb95fc2ac6..25cb607f02 100644 --- a/zanata-war/src/main/webapp/WEB-INF/layout/glossary/upload_glossary_modal.xhtml +++ b/zanata-war/src/main/webapp/WEB-INF/layout/glossary/upload_glossary_modal.xhtml @@ -2,6 +2,7 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsf/core" xmlns:rich="http://richfaces.org/rich" + xmlns:a4j="http://richfaces.org/a4j" xmlns:zanata="http://java.sun.com/jsf/composite/zanata" class="modal" id="glossaryUploadDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> @@ -106,12 +107,15 @@
#{msgs['jsf.Glossary.supportedFileFormat']}
+ +
diff --git a/zanata-war/src/main/webapp/WEB-INF/layout/version/upload_translation_modal.xhtml b/zanata-war/src/main/webapp/WEB-INF/layout/version/upload_translation_modal.xhtml index 6e419d6677..2f39e551a8 100644 --- a/zanata-war/src/main/webapp/WEB-INF/layout/version/upload_translation_modal.xhtml +++ b/zanata-war/src/main/webapp/WEB-INF/layout/version/upload_translation_modal.xhtml @@ -105,12 +105,14 @@
+
diff --git a/zanata-war/src/main/webapp/iteration/view.xhtml b/zanata-war/src/main/webapp/iteration/view.xhtml index 8769dadfc5..f9a25fc51a 100644 --- a/zanata-war/src/main/webapp/iteration/view.xhtml +++ b/zanata-war/src/main/webapp/iteration/view.xhtml @@ -74,6 +74,8 @@ . show(); checkIfFileSelected(); + + setUploadSourceButtonEnabled(false); } function hideUploadSourcePanel() { @@ -454,11 +456,14 @@ + +