Skip to content

Commit b07a5da

Browse files
committed
duplicate check support is added
1 parent f76fda3 commit b07a5da

File tree

5 files changed

+53
-22
lines changed

5 files changed

+53
-22
lines changed

dist/vue2Dropzone.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue2Dropzone.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/pages/Props.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div>
33
<h1>Props</h1>
44
<p>The following props are available for the Vue2-Dropzone component.</p>
5-
<simple-table :headers="['Prop Name', 'Type', 'Description', 'Required']" :rows="props" />
5+
<simple-table :headers="['Prop Name', 'Type', 'Default', 'Description', 'Required']" :rows="props" />
66
<edit-doc :link="'Props.vue'"></edit-doc>
77
</div>
88
</template>
@@ -15,11 +15,12 @@ export default {
1515
data: function() {
1616
return {
1717
props: [
18-
['id', 'String', 'A string by which to identify the component, can be anything', 'True'],
19-
['options', 'Object', 'A dropzone [configuration object](http://www.dropzonejs.com/#configuration-options), accepts all valid dropzone configuration', 'True'],
20-
['includeStyling', 'Boolean', 'Whether to include the dropzone and component styling, defaults to true', 'False'],
21-
['awss3', 'Object', 'Object consisting of 3 values signingURL, headers, and params. You can use the headers and params keys to send additional headers or parameters with the signing request (e.g. CSRF tokens). See [Demo and config](#/aws-s3-upload)', 'False'],
22-
['destroyDropzone', 'Boolean', 'Destroy the dropzone object when the component is destroyed. Defaults to true.', 'False'],
18+
['id', 'String','dropzone', 'A string by which to identify the component, can be anything', 'True'],
19+
['options', 'Object','{}', 'A dropzone [configuration object](http://www.dropzonejs.com/#configuration-options), accepts all valid dropzone configuration', 'True'],
20+
['includeStyling', 'Boolean','True', 'Whether to include the dropzone and component styling.', 'False'],
21+
['awss3', 'Object','{}', 'Object consisting of 3 values signingURL, headers, and params. You can use the headers and params keys to send additional headers or parameters with the signing request (e.g. CSRF tokens). See [Demo and config](#/aws-s3-upload)', 'False'],
22+
['destroyDropzone', 'Boolean','True', 'Destroy the dropzone object when the component is destroyed.', 'False'],
23+
['duplicateCheck','Boolean','False','Check if added file is duplicate, in already dropped files in dropzone','False']
2324
]
2425
}
2526
},

docs/src/pages/demo.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22
<div>
33
<h1>Demo</h1>
44
<p>Below you can see Vue2-Dropzone in action.</p>
5-
<vue-dropzone ref="myVueDropzone" id="dropzone" @vdropzone-file-added="vfileAdded" @vdropzone-success="vsuccess" @vdropzone-error="verror" @vdropzone-removed-file="vremoved" @vdropzone-sending="vsending" @vdropzone-success-multiple="vsuccessMuliple" @vdropzone-sending-multiple="vsendingMuliple" @vdropzone-queue-complete="vqueueComplete" @vdropzone-total-upload-progress="vprogress" @vdropzone-mounted="vmounted" @vdropzone-drop="vddrop" @vdropzone-drag-start="vdstart" @vdropzone-drag-end="vdend" @vdropzone-drag-enter="vdenter" @vdropzone-drag-over="vdover" @vdropzone-drag-leave="vdleave" :options="dropzoneOptions">
5+
<vue-dropzone ref="myVueDropzone" id="dropzone"
6+
@vdropzone-file-added="vfileAdded"
7+
@vdropzone-success="vsuccess"
8+
@vdropzone-error="verror"
9+
@vdropzone-removed-file="vremoved"
10+
@vdropzone-sending="vsending"
11+
@vdropzone-success-multiple="vsuccessMuliple"
12+
@vdropzone-sending-multiple="vsendingMuliple"
13+
@vdropzone-queue-complete="vqueueComplete"
14+
@vdropzone-total-upload-progress="vprogress"
15+
@vdropzone-mounted="vmounted"
16+
@vdropzone-drop="vddrop"
17+
@vdropzone-drag-start="vdstart"
18+
@vdropzone-drag-end="vdend"
19+
@vdropzone-drag-enter="vdenter"
20+
@vdropzone-drag-over="vdover"
21+
@vdropzone-drag-leave="vdleave"
22+
:options="dropzoneOptions"
23+
:duplicateCheck="true">
624
</vue-dropzone>
725

826
<h3>Events</h3>
@@ -180,9 +198,8 @@ export default {
180198
maxFilesize: 0.5,
181199
headers: { "My-Awesome-Header": "header value" },
182200
addRemoveLinks: true,
183-
autoProcessQueue: true,
201+
autoProcessQueue: false,
184202
accept(file, done) {
185-
console.log(file);
186203
done();
187204
},
188205
},

src/components/vue-dropzone.vue

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default {
1414
props: {
1515
id: {
1616
type: String,
17-
required: true
17+
required: true,
18+
default:'dropzone'
1819
},
1920
options: {
2021
type: Object,
@@ -34,7 +35,12 @@ export default {
3435
type: Boolean,
3536
default: true,
3637
required: false
37-
}
38+
},
39+
duplicateCheck:{
40+
type: Boolean,
41+
default: false,
42+
required:false
43+
},
3844
},
3945
data() {
4046
return {
@@ -213,20 +219,27 @@ export default {
213219
})
214220
215221
this.dropzone.on('addedfile', function(file) {
222+
var isDuplicate = false;
216223
if (vm.duplicateCheck) {
217224
if (this.files.length) {
218-
this.files.forEach(function(dzfile) {
219-
if (dzfile.name === file.name) {
220-
this.removeFile(file)
221-
vm.$emit('duplicate-file', file)
225+
var _i, _len;
226+
for (_i = 0, _len = this.files.length; _i < _len - 1; _i++) // -1 to exclude current file
227+
{
228+
if(this.files[_i].name === file.name && this.files[_i].size === file.size && this.files[_i].lastModifiedDate.toString() === file.lastModifiedDate.toString())
229+
{
230+
this.removeFile(file);
231+
isDuplicate = true;
232+
vm.$emit('duplicate-file', file)
233+
}
222234
}
223-
}, this)
224235
}
225236
}
226-
vm.$emit('vdropzone-file-added', file)
227-
if (vm.isS3 && vm.wasQueueAutoProcess) {
228-
vm.getSignedAndUploadToS3(file);
229-
}
237+
238+
vm.$emit('vdropzone-file-added', file)
239+
if (vm.isS3 && vm.wasQueueAutoProcess) {
240+
vm.getSignedAndUploadToS3(file);
241+
}
242+
230243
})
231244
232245
this.dropzone.on('addedfiles', function(files) {

0 commit comments

Comments
 (0)