Cosmetics
parent
c9c78576ba
commit
3ad146de56
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div ref="content" class="p-fileupload-content" @dragenter="onDragEnter" @dragover="onDragOver" @dragleave="onDragLeave" @drop="onDrop">
|
<div ref="content" class="p-fileupload-content" @dragenter="onDragEnter" @dragover="onDragOver" @dragleave="onDragLeave" @drop="onDrop">
|
||||||
<FileUploadProgressBar :value="progress" v-if="hasFiles" />
|
<FileUploadProgressBar :value="progress" v-if="hasFiles" />
|
||||||
<FileUploadMessage v-for="msg of messages" :severity="error" :key="msg">{{msg}}</FileUploadMessage>
|
<FileUploadMessage v-for="msg of messages" severity="error" :key="msg">{{msg}}</FileUploadMessage>
|
||||||
<div class="p-fileupload-files" v-if="hasFiles">
|
<div class="p-fileupload-files" v-if="hasFiles">
|
||||||
<div class="p-fileupload-row" v-for="(file, index) of files" :key="file.name + file.type + file.size">
|
<div class="p-fileupload-row" v-for="(file, index) of files" :key="file.name + file.type + file.size">
|
||||||
<div v-if="isImage(file)">
|
<div v-if="isImage(file)">
|
||||||
|
@ -70,7 +70,7 @@ export default {
|
||||||
},
|
},
|
||||||
invalidFileSizeMessage: {
|
invalidFileSizeMessage: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '{0}: Invalid file size, maximum upload size is {1}.'
|
default: '{0}: Invalid file size, file size should be smaller than {1}.'
|
||||||
},
|
},
|
||||||
withCredentials: {
|
withCredentials: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -117,19 +117,15 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.auto) {
|
this.$emit('select', {originalEvent: event, files: files});
|
||||||
|
|
||||||
|
if (this.auto && this.hasFiles()) {
|
||||||
this.upload();
|
this.upload();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('select', {originalEvent: event, files: files});
|
|
||||||
this.clearInputElement();
|
this.clearInputElement();
|
||||||
|
|
||||||
if (this.mode === 'basic') {
|
|
||||||
this.$refs.fileInput.style.display = 'none';
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
upload() {
|
upload() {
|
||||||
this.messages = [];
|
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
|
|
||||||
|
@ -187,6 +183,7 @@ export default {
|
||||||
},
|
},
|
||||||
clear() {
|
clear() {
|
||||||
this.files = null;
|
this.files = null;
|
||||||
|
this.messages = null;
|
||||||
this.$emit('clear');
|
this.$emit('clear');
|
||||||
this.clearInputElement();
|
this.clearInputElement();
|
||||||
},
|
},
|
||||||
|
@ -208,7 +205,7 @@ export default {
|
||||||
},
|
},
|
||||||
validate(file) {
|
validate(file) {
|
||||||
if (this.maxFileSize && file.size > this.maxFileSize) {
|
if (this.maxFileSize && file.size > this.maxFileSize) {
|
||||||
this.messages.push[this.invalidFileSizeMessage.replace('{0}', file.name).replace('{0}', this.formatSize(this.maxFileSize))];
|
this.messages.push(this.invalidFileSizeMessage.replace('{0}', file.name).replace('{1}', this.formatSize(this.maxFileSize)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue