Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #89 from zanata/disable-null-upload
Browse files Browse the repository at this point in the history
Fix for rhbz990373 - disables source upload buttons when no file specified
  • Loading branch information
Patrick Huang committed Aug 2, 2013
2 parents 07bb8cf + 9620e5e commit c8d4e99
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
32 changes: 28 additions & 4 deletions zanata-war/src/main/webapp/iteration/source_files.xhtml
Expand Up @@ -15,13 +15,15 @@
<script type="text/javascript">
function openUploadDocPanel() {
#{rich:component('uploadDocPanel')}.show();
checkIfGeneralFileSelected()
return false;
}

function openUploadPanel(docId) {
#{rich:element('uploadPanelHeader')}.innerHTML = '#{messages['jsf.iteration.files.UploadDocument']}: ' + docId;
#{rich:element('uploadDocId')}.value = docId;
#{rich:component('uploadPanel')}.show();
checkIfSpecificFileSelected();
}

function hideUploadPanel() {
Expand All @@ -37,6 +39,22 @@
function focusNameFilterInput() {
#{rich:element('name_filter_input')}.focus();
}

function checkIfFileSelected(fileInput, submitButton) {
var noFileSelected = fileInput.value === undefined || fileInput.value === "";
submitButton.disabled = noFileSelected;
}

function checkIfSpecificFileSelected() {
checkIfFileSelected(#{rich:element('specificDocFileInput')},
#{rich:element('specificDocSubmitUploadButton')});
}

function checkIfGeneralFileSelected() {
checkIfFileSelected(#{rich:element('generalDocFileUpload')},
#{rich:element('generalDocSubmitUploadButton')});
}

</script>
</ui:define>

Expand Down Expand Up @@ -228,7 +246,9 @@
<h:outputText id="uploadPanelHeader"/>
</f:facet>
<h:form id="uploadForm" enctype="multipart/form-data">
<s:fileUpload accept="*"
<s:fileUpload id="specificDocFileInput"
accept="*"
onchange="checkIfSpecificFileSelected();"
data="#{projectIterationFilesAction.documentFileUpload.fileContents}"
fileName="#{projectIterationFilesAction.documentFileUpload.fileName}"/>
<h:inputHidden id="uploadDocId" value="#{projectIterationFilesAction.documentFileUpload.docId}"/>
Expand Down Expand Up @@ -256,7 +276,8 @@
</a>
</rich:collapsiblePanel>
<div align="right">
<h:commandButton value="#{messages['jsf.Upload']}"
<h:commandButton id="specificDocSubmitUploadButton"
value="#{messages['jsf.Upload']}"
action="#{projectIterationFilesAction.uploadDocumentFile}"/>
<h:commandButton value="#{messages['jsf.Cancel']}"
onclick="return hideUploadPanel();"/>
Expand All @@ -274,7 +295,9 @@
<h:outputText value="#{messages['jsf.iteration.files.UploadDocument']}"/>
</f:facet>
<h:form id="uploadDocForm" enctype="multipart/form-data">
<s:fileUpload accept="*"
<s:fileUpload id="generalDocFileUpload"
accept="*"
onchange="checkIfGeneralFileSelected();"
data="#{projectIterationFilesAction.documentFileUpload.fileContents}"
fileName="#{projectIterationFilesAction.documentFileUpload.fileName}"/>
<br/>
Expand Down Expand Up @@ -306,7 +329,8 @@
</a>
</rich:collapsiblePanel>
<div align="right">
<h:commandButton value="#{messages['jsf.Upload']}"
<h:commandButton id="generalDocSubmitUploadButton"
value="#{messages['jsf.Upload']}"
action="#{projectIterationFilesAction.uploadDocumentFile}"/>
<h:commandButton value="#{messages['jsf.Cancel']}"
onclick="return hideDocUploadPanel();"/>
Expand Down
5 changes: 5 additions & 0 deletions zanata-war/src/main/webapp/resources/css/zanata.css
Expand Up @@ -130,6 +130,11 @@ input[readonly] {
color:#545454;
}

input[disabled] {
opacity: 0.5;
cursor: default;
}

button:hover,input[type="reset"]:hover,input[type="submit"]:hover,input[type="button"]:hover
{
background: #CCC;
Expand Down

0 comments on commit c8d4e99

Please sign in to comment.