Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase from new main Repository #3

Closed
wants to merge 13 commits into from
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ Here is an example template for uploading a minimum of 5 items and a maximum of
``` html
<multiple-file-uploader postURL="http://.." successMessagePath="" errorMessagePath="" :minItems="5" :maxItems="10"></multiple-file-uploader>
```
### Events
Fires `upload-success` or `upload-error` respectively. Success handler receives axios response object. Error handler receives axios error object.
```html
<multiple-file-uploader postURL="http://.." successMessagePath="" errorMessagePath="" @upload-success='success_handler'></multiple-file-uploader>
```
```javascript
...
success_handler: function(response){

},
...
```

Fires `cancel-button` without parameters.

### Dependencies
Axios, ES6-Promise

Expand All @@ -109,7 +124,7 @@ Example:
---
The MIT License (MIT)

Copyright (c) 2017 Andrei Barta @ UPDIVISION
Copyright (c) 2017 UPDIVISION

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions dist/build.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/build.js.map

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions src/MultipleFileUploader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
<ol>
<li v-for="size in itemsSizes">{{size}}</li>
</ol>
<p><strong>{{totalFileMessage}}</strong> {{itemsAdded}}</p>
<p><strong>{{totalUploadSizeMessage}}</strong> {{itemsTotalSize}}</p>
<button @click="removeItems">{{removeFileMessage}}</button>
<p v-if="maxItems > 1"><strong>{{totalFileMessage}}</strong> {{itemsAdded}}</p>
<p v-if="maxItems > 1"><strong>{{totalUploadSizeMessage}}</strong> {{itemsTotalSize}}</p>
<button id="resetButtonId" type="button" @click="removeItems">{{removeFileMessage}}</button>
<div class="loader" v-if="isLoaderVisible">
<div class="loaderImg"></div>
</div>
</div>
<div>
<button type="submit" class="btn btn-primary btn-black btn-round" :disabled="itemsAdded < minItems || itemsAdded > maxItems">
<button id="submitButtonId" type="submit" class="btn btn-primary btn-black btn-round" :disabled="itemsAdded < minItems || itemsAdded > maxItems">
{{uploadButtonMessage}}
</button>
<button type="button" class="btn btn-default btn-round" @click="removeItems">{{cancelButtonMessage}}</button>
<button id="cancelButtonId" type="button" class="btn btn-default btn-round" @click="cancelButton">{{cancelButtonMessage}}</button>
</div>
<br>
<div class="successMsg" v-if="successMsg !== ''">{{successMsg}}</div>
Expand Down Expand Up @@ -197,7 +197,10 @@ export default {
}
this.itemsTotalSize = this.bytesToSize(fileSizes);
},

cancelButton(){
this.removeItems();
this.$emit('cancel-button');
},
removeItems() {
this.items = '';
this.itemsAdded = '';
Expand Down Expand Up @@ -229,12 +232,14 @@ export default {
if(this.showHttpMessages)
this.successMsg = response + "." + this.successMessagePath;
this.removeItems();
this.$emit('upload-success', response);
})
.catch((error) => {
this.isLoaderVisible = false;
if(this.showHttpMessages)
this.errorMsg = error + "." + this.errorMessagePath;
this.removeItems();
this.$emit('upload-error', error);
});
} else {
if(this.showHttpMessages)
Expand Down