Skip to content

Commit 23ac35e

Browse files
authored
Merge pull request #30 from dachcom-digital/feature/filetype
Adds filetype to dropzone preview-element
2 parents d2d481a + c47f1c4 commit 23ac35e

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ npm i js-pimcore-formbuilder
2222

2323
## Upgrade Notes
2424

25+
### 1.3.1
26+
- **[ENHANCEMENT]**: Adds filetype to dropzone preview-element [#30](https://github.com/dachcom-digital/js-pimcore-formbuilder/pull/30)
27+
2528
### 1.3.0
2629
- **[NEW FEATURE]**: Bootstrap 5 layout support
2730

@@ -79,4 +82,4 @@ npm i js-pimcore-formbuilder
7982
[dachcom.com](https://www.dachcom.com), [email protected]
8083
Copyright © 2025 DACHCOM.DIGITAL. All rights reserved.
8184

82-
For licensing details please visit [LICENSE.md](LICENSE.md)
85+
For licensing details please visit [LICENSE.md](LICENSE.md)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-pimcore-formbuilder",
3-
"version": "1.2.0",
3+
"version": "1.3.1",
44
"description": "Dependency free js plugins for Pimcore Formbuilder",
55
"author": "DACHCOM.DIGITAL",
66
"license": "GPL-3.0-or-later",

src/js/dynamicMultiFileHandlers/dropzoneHandler.js

+32-16
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,20 @@ export default class DropzoneHandler {
6262
element.classList.add('dropzone');
6363

6464
new Dropzone(element, dropzoneConfiguration)
65-
.on('removedfile', (file) => {
65+
.on('addedfile', (file) => {
66+
const elType = file.previewElement.querySelector('[data-dz-type]');
67+
68+
if (!elType || !file.type || !file.type.includes('/')) {
69+
return;
70+
}
71+
72+
const splittedType = file.type.split('/');
6673

74+
if (splittedType.length > 1) {
75+
elType.textContent = splittedType[1];
76+
}
77+
})
78+
.on('removedfile', (file) => {
6779
if (this.suspendFileRemoval) {
6880
return;
6981
}
@@ -81,22 +93,26 @@ export default class DropzoneHandler {
8193
id: data.uuid,
8294
});
8395
});
84-
}).on('sending', (file, xhr, formData) => {
85-
submitButton.setAttribute('disabled', 'disabled');
86-
formData.append('uuid', file.upload.uuid);
87-
}).on('complete', () => {
88-
submitButton.removeAttribute('disabled');
89-
}).on('success', (file, response) => {
90-
this.addToStorageField(storageField, {
91-
id: response.uuid,
92-
fileName: response.fileName,
96+
})
97+
.on('sending', (file, xhr, formData) => {
98+
submitButton.setAttribute('disabled', 'disabled');
99+
formData.append('uuid', file.upload.uuid);
100+
})
101+
.on('complete', () => {
102+
submitButton.removeAttribute('disabled');
103+
})
104+
.on('success', (file, response) => {
105+
this.addToStorageField(storageField, {
106+
id: response.uuid,
107+
fileName: response.fileName,
108+
});
109+
})
110+
.on('cancel', () => {
111+
submitButton.removeAttribute('disabled');
112+
})
113+
.on('reset', () => {
114+
this.suspendFileRemoval = false;
93115
});
94-
}).on('cancel', () => {
95-
submitButton.removeAttribute('disabled');
96-
}).on('reset', () => {
97-
this.suspendFileRemoval = false;
98-
});
99-
100116
}
101117

102118
addToStorageField(storage, newData) {

0 commit comments

Comments
 (0)