@enso-ui/uploader 2.0.8 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enso-ui/uploader",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "File Uploader",
|
|
5
5
|
"main": "bulma/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"homepage": "https://github.com/enso-ui/uploader#readme",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@fortawesome/fontawesome-svg-core": "^1.2.2",
|
|
25
|
-
"@fortawesome/free-solid-svg-icons": "^5.2
|
|
25
|
+
"@fortawesome/free-solid-svg-icons": "^5.11.2",
|
|
26
26
|
"@fortawesome/vue-fontawesome": "3.0.0-5",
|
|
27
27
|
"bulma": "^0.9.0",
|
|
28
28
|
"vue": "^3.0"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<uploader v-bind="$attrs"
|
|
3
|
-
:
|
|
3
|
+
:http="http"
|
|
4
|
+
:i18n="i18n"
|
|
4
5
|
ref="uploader"/>
|
|
5
6
|
</template>
|
|
6
7
|
|
|
@@ -12,7 +13,7 @@ export default {
|
|
|
12
13
|
|
|
13
14
|
components: { Uploader },
|
|
14
15
|
|
|
15
|
-
inject: ['i18n'],
|
|
16
|
+
inject: ['http', 'i18n'],
|
|
16
17
|
|
|
17
18
|
methods: {
|
|
18
19
|
browseFiles() {
|
|
@@ -6,6 +6,8 @@ export default {
|
|
|
6
6
|
|
|
7
7
|
inject: ['errorHandler', 'toastr'],
|
|
8
8
|
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
|
|
9
11
|
props: {
|
|
10
12
|
compact: {
|
|
11
13
|
default: false,
|
|
@@ -19,8 +21,12 @@ export default {
|
|
|
19
21
|
default: 20 * 1024 * 1024,
|
|
20
22
|
type: Number,
|
|
21
23
|
},
|
|
24
|
+
http: {
|
|
25
|
+
required: true,
|
|
26
|
+
type: Function,
|
|
27
|
+
},
|
|
22
28
|
i18n: {
|
|
23
|
-
default:
|
|
29
|
+
default: v => v,
|
|
24
30
|
type: Function,
|
|
25
31
|
},
|
|
26
32
|
label: {
|
|
@@ -50,8 +56,6 @@ export default {
|
|
|
50
56
|
'upload-successful', 'upload-error',
|
|
51
57
|
],
|
|
52
58
|
|
|
53
|
-
inheritAttrs: false,
|
|
54
|
-
|
|
55
59
|
data: () => ({
|
|
56
60
|
formData: new FormData(),
|
|
57
61
|
succesfull: 0,
|
|
@@ -98,17 +102,17 @@ export default {
|
|
|
98
102
|
return;
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
|
|
105
|
+
this.http.post(this.url, this.formData).then(response => {
|
|
102
106
|
this.reset();
|
|
103
107
|
this.$emit('upload-successful', response.data);
|
|
104
|
-
}).catch(
|
|
108
|
+
}).catch(error => {
|
|
105
109
|
this.reset();
|
|
106
110
|
this.$emit('upload-error');
|
|
107
111
|
const { data, status } = error.response;
|
|
108
112
|
|
|
109
113
|
if (status === 422) {
|
|
110
114
|
Object.keys(data.errors)
|
|
111
|
-
.forEach(
|
|
115
|
+
.forEach(key => this.toastr.error(data.errors[key][0]));
|
|
112
116
|
return;
|
|
113
117
|
}
|
|
114
118
|
|
|
@@ -185,7 +189,7 @@ export default {
|
|
|
185
189
|
},
|
|
186
190
|
inputEvents: {
|
|
187
191
|
change: this.onChange,
|
|
188
|
-
input:
|
|
192
|
+
input: event => this.$emit('input', event.target.value),
|
|
189
193
|
},
|
|
190
194
|
label: this.displayLabel,
|
|
191
195
|
multiple: this.multiple,
|