Skip to content

Commit

Permalink
https://github.com/parttio/easyuploads/issues/25
Browse files Browse the repository at this point in the history
fix bounds check for maxFileCount to allow for uploading 1 file
  • Loading branch information
WoozyG committed Mar 2, 2017
1 parent 0ca416e commit d0769ee
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/org/vaadin/easyuploads/client/ui/VMultiUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ public static final native VHtml5File[] getFiles(Element el)
private String receiverUri;

private ReadyStateChangeHandler readyStateChangeHandler = new ReadyStateChangeHandler() {
public void onReadyStateChange(XMLHttpRequest xhr) {
@Override
public void onReadyStateChange(XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
xhr.clearOnReadyStateChange();
VConsole.log("Ready state + " + xhr.getReadyState());

Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
@Override
public void execute() {
if (isAttached() && !fileQueue.isEmpty()) {
client.updateVariable(paintableId, "ready", true,
true);
Expand All @@ -144,7 +146,8 @@ public VMultiUpload() {
panel.add(fu);
submitButton = new VButton();
submitButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
@Override
public void onClick(ClickEvent event) {
// fire click on upload (eg. focused button and hit space)
fireNativeClick(fu.getElement());
}
Expand All @@ -157,7 +160,8 @@ public void onClick(ClickEvent event) {
addStyleName(CLASSNAME + "-immediate");
}

public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
if (client.updateComponent(this, uidl, true)) {
return;
}
Expand Down Expand Up @@ -292,7 +296,7 @@ private void submit() {
} else if (!AcceptUtil.accepted(file.getName(), file.getType(),
accepted)) {
noMatches.add(file);
} else if (maxFileCount != null && filedetails.size() >= maxFileCount) {
} else if (maxFileCount != null && filedetails.size() > maxFileCount) {
tooMany.add(file);
} else {
queueFilePost(file);
Expand Down

0 comments on commit d0769ee

Please sign in to comment.