@osimatic/helpers-js 1.3.4 → 1.3.6
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/multi_files_input.js +11 -8
- package/package.json +1 -1
package/multi_files_input.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
class MultiFilesInput {
|
|
2
|
-
static init(fileInput,
|
|
2
|
+
static init(fileInput, setFilesList, nbMaxFiles, maxFileSize) {
|
|
3
|
+
let filesList = [];
|
|
3
4
|
const formGroup = fileInput.closest('.form-group');
|
|
4
5
|
|
|
5
6
|
if (formGroup.find('.multi_files_input_dropzone').length === 0) {
|
|
@@ -18,7 +19,7 @@ class MultiFilesInput {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
const dropzone = fileInput.parent().find('.multi_files_input_dropzone');
|
|
21
|
-
const filesPreview = fileInput.parent().find('.multi_files_input_files_preview');
|
|
22
|
+
const filesPreview = fileInput.parent().find('.multi_files_input_files_preview').empty();
|
|
22
23
|
|
|
23
24
|
fileInput.addClass('hide');
|
|
24
25
|
|
|
@@ -61,6 +62,7 @@ class MultiFilesInput {
|
|
|
61
62
|
continue;
|
|
62
63
|
}
|
|
63
64
|
filesList.push(f);
|
|
65
|
+
setFilesList(filesList);
|
|
64
66
|
renderPreview(f);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
@@ -68,12 +70,12 @@ class MultiFilesInput {
|
|
|
68
70
|
function renderPreview(file) {
|
|
69
71
|
const id = 'f_' + Math.random().toString(36).slice(2, 9);
|
|
70
72
|
const wrap = $(`
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
<div class="border rounded p-2 d-inline-flex align-items-center" data-file-id="${id}" style="background:white;">
|
|
74
|
+
<div class="me-2 preview-thumb" style="width:64px; height:48px; display:flex; align-items:center; justify-content:center; overflow:hidden;"></div>
|
|
75
|
+
<div class="small text-truncate" style="max-width:160px;">${file.name}</div>
|
|
76
|
+
<button type="button" class="btn-close btn-close-small ms-2" aria-label="Supprimer" style="margin-left:8px;"></button>
|
|
77
|
+
</div>
|
|
78
|
+
`);
|
|
77
79
|
filesPreview.append(wrap);
|
|
78
80
|
filesPreview.removeClass('hide');
|
|
79
81
|
|
|
@@ -93,6 +95,7 @@ class MultiFilesInput {
|
|
|
93
95
|
// remove by reference: find corresponding file by name+size (best-effort)
|
|
94
96
|
const name = file.name, size = file.size;
|
|
95
97
|
filesList = filesList.filter(f => !(f.name === name && f.size === size));
|
|
98
|
+
setFilesList(filesList);
|
|
96
99
|
$(this).closest('[data-file-id]').remove();
|
|
97
100
|
|
|
98
101
|
if (filesList.length === 0) {
|