inertia-bootstrap-forms 1.0.81 → 1.0.82
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
package/src/UppyInput.vue
CHANGED
|
@@ -45,6 +45,7 @@ const inputEl = ref(null);
|
|
|
45
45
|
const uppy = shallowRef(null);
|
|
46
46
|
const isResetting = ref(false);
|
|
47
47
|
const isUnmounting = ref(false);
|
|
48
|
+
const uploadingFiles = ref(0);
|
|
48
49
|
|
|
49
50
|
// Inject form and group contexts
|
|
50
51
|
const form = inject("form", {value: {}, errors: {}, getID: n => n});
|
|
@@ -76,11 +77,18 @@ uppy.value = new Uppy({
|
|
|
76
77
|
},
|
|
77
78
|
});
|
|
78
79
|
|
|
80
|
+
uppy.value.on('upload', () => {
|
|
81
|
+
uploadingFiles.value = uppy.value.getFiles().filter(f => !f.progress.uploadComplete).length;
|
|
82
|
+
emits('upload');
|
|
83
|
+
});
|
|
84
|
+
|
|
79
85
|
uppy.value.on('before-upload', (files) => {
|
|
80
86
|
emits('beforeUpload', files);
|
|
81
87
|
});
|
|
82
88
|
|
|
83
89
|
uppy.value.on('upload-success', (file, response) => {
|
|
90
|
+
uploadingFiles.value = Math.max(0, uploadingFiles.value - 1);
|
|
91
|
+
|
|
84
92
|
const result = response.body ?? response;
|
|
85
93
|
if (props.multiple) {
|
|
86
94
|
const currentValues = Array.isArray(modelValue.value) ? modelValue.value : [];
|
|
@@ -119,7 +127,15 @@ uppy.value.on('file-removed', (file) => {
|
|
|
119
127
|
});
|
|
120
128
|
|
|
121
129
|
uppy.value.on('progress', (progress) => {
|
|
122
|
-
|
|
130
|
+
if (progress <= 0) {
|
|
131
|
+
form.value['uploading'] = null;
|
|
132
|
+
} else if (progress >= 100) {
|
|
133
|
+
// هنوز منتظر جواب سرور - uploading رو null نکن
|
|
134
|
+
form.value['uploading'] = uploadingFiles.value > 0 ? 99 : null;
|
|
135
|
+
} else {
|
|
136
|
+
form.value['uploading'] = progress;
|
|
137
|
+
}
|
|
138
|
+
|
|
123
139
|
emits('progress', progress)
|
|
124
140
|
});
|
|
125
141
|
uppy.value.on('upload-progress', (file, progress) => emits('upload-progress', file, progress));
|
|
@@ -128,13 +144,20 @@ uppy.value.on('cancel-all', () => emits('cancel-all'));
|
|
|
128
144
|
uppy.value.on('retry-all', () => emits('retry-all'));
|
|
129
145
|
uppy.value.on('upload-stalled', (error, files) => emits('upload-stalled', error, files));
|
|
130
146
|
uppy.value.on('upload-retry', (file) => emits('upload-retry', file));
|
|
131
|
-
|
|
147
|
+
|
|
148
|
+
uppy.value.on('complete', (result) => {
|
|
149
|
+
uploadingFiles.value = 0;
|
|
150
|
+
form.value['uploading'] = null;
|
|
151
|
+
emits('complete', result);
|
|
152
|
+
});
|
|
132
153
|
|
|
133
154
|
uppy.value.on('error', (error) => {
|
|
134
155
|
emits('error', error)
|
|
135
156
|
});
|
|
136
157
|
|
|
137
158
|
uppy.value.on('upload-error', (file, error, response) => {
|
|
159
|
+
uploadingFiles.value = Math.max(0, uploadingFiles.value - 1);
|
|
160
|
+
|
|
138
161
|
const errorMessage = JSON.parse(response.response)?.message ?? error;
|
|
139
162
|
handleError(errorMessage);
|
|
140
163
|
emits('upload-error', file, error, response, errorMessage)
|
|
@@ -236,7 +259,7 @@ function buildRestrictionsCaption(restrictions) {
|
|
|
236
259
|
parts.push(`فقط فایلهای ${types}`);
|
|
237
260
|
}
|
|
238
261
|
|
|
239
|
-
if (maxNumberOfFiles) {
|
|
262
|
+
if (maxNumberOfFiles && maxNumberOfFiles > 1) {
|
|
240
263
|
parts.push(`امکان انتخاب حداکثر ${maxNumberOfFiles} فایل`);
|
|
241
264
|
}
|
|
242
265
|
|