|
150 | 150 | }, |
151 | 151 | getQueuedFiles: function () { |
152 | 152 | return this.dropzone.getQueuedFiles(); |
153 | | - } |
| 153 | + }, |
| 154 | + getProp:function(attribute_prop,object_prop){ |
| 155 | + if (!this.useCustomDropzoneOptions) |
| 156 | + return attribute_prop; |
| 157 | +
|
| 158 | + if (object_prop !== undefined && object_prop !== null && object_prop !== '') |
| 159 | + return object_prop; |
| 160 | + else |
| 161 | + return attribute_prop; |
| 162 | + }, |
| 163 | +
|
154 | 164 | }, |
155 | 165 | computed: { |
156 | 166 | languageSettings () { |
157 | 167 | let defaultValues = { |
158 | | - dictDefaultMessage: '<br>Drop files here to upload', |
159 | | - dictCancelUpload: 'Cancel upload', |
| 168 | + dictDefaultMessage : '<br>Drop files here to upload', |
| 169 | + dictCancelUpload : 'Cancel upload', |
160 | 170 | dictCancelUploadConfirmation: 'Are you sure you want to cancel this upload?', |
161 | | - dictFallbackMessage: 'Your browser does not support drag and drop file uploads.', |
162 | | - dictFallbackText: 'Please use the fallback form below to upload your files like in the olden days.', |
163 | | - dictFileTooBig: 'File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.', |
164 | | - dictInvalidFileType: `You can't upload files of this type.`, |
165 | | - dictMaxFilesExceeded: 'You can not upload any more files. (max: {{maxFiles}})', |
166 | | - dictRemoveFile: 'Remove', |
167 | | - dictRemoveFileConfirmation: null, |
168 | | - dictResponseError: 'Server responded with {{statusCode}} code.' |
169 | | - }; |
| 171 | + dictFallbackMessage : 'Your browser does not support drag and drop file uploads.', |
| 172 | + dictFallbackText : 'Please use the fallback form below to upload your files like in the olden days.', |
| 173 | + dictFileTooBig : 'File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.', |
| 174 | + dictInvalidFileType : `You can't upload files of this type.`, |
| 175 | + dictMaxFilesExceeded : 'You can not upload any more files. (max: {{maxFiles}})', |
| 176 | + dictRemoveFile : 'Remove', |
| 177 | + dictRemoveFileConfirmation : null, |
| 178 | + dictResponseError : 'Server responded with {{statusCode}} code.' |
| 179 | + }; |
170 | 180 |
|
171 | 181 | for (let attrname in this.language) { |
172 | 182 | defaultValues[attrname] = this.language[attrname] |
173 | 183 | } |
174 | 184 |
|
| 185 | + if (this.useCustomDropzoneOptions) { |
| 186 | + if (this.dropzoneOptions.language) { |
| 187 | + for (let attrname in this.dropzoneOptions.language) { |
| 188 | + defaultValues[attrname] = this.dropzoneOptions.language[attrname] |
| 189 | + } |
| 190 | + } |
| 191 | + } |
| 192 | +
|
175 | 193 | return defaultValues |
176 | 194 | }, |
177 | 195 | cloudIcon: function () { |
|
202 | 220 | } |
203 | 221 | let Dropzone = require('dropzone'); |
204 | 222 | Dropzone.autoDiscover = false; |
205 | | - let element = document.getElementById(this.id); |
206 | | -
|
207 | | - if (!this.useCustomDropzoneOptions) { |
208 | | - this.dropzone = new Dropzone(element, { |
209 | | - clickable: this.clickable, |
210 | | - paramName: this.paramName, |
211 | | - thumbnailWidth: this.thumbnailWidth, |
212 | | - thumbnailHeight: this.thumbnailHeight, |
213 | | - maxFiles: this.maxNumberOfFiles, |
214 | | - maxFilesize: this.maxFileSizeInMB, |
215 | | - addRemoveLinks: this.showRemoveLink, |
216 | | - acceptedFiles: this.acceptedFileTypes, |
217 | | - autoProcessQueue: this.autoProcessQueue, |
218 | | - headers: this.headers, |
219 | | - previewTemplate: this.previewTemplate(this), |
220 | | - dictDefaultMessage: this.cloudIcon + this.languageSettings.dictDefaultMessage, |
221 | | - dictCancelUpload: this.languageSettings.dictCancelUpload, |
222 | | - dictCancelUploadConfirmation: this.languageSettings.dictCancelUploadConfirmation, |
223 | | - dictFallbackMessage: this.languageSettings.dictFallbackMessage, |
224 | | - dictFallbackText: this.languageSettings.dictFallbackText, |
225 | | - dictFileTooBig: this.languageSettings.dictFileTooBig, |
226 | | - dictInvalidFileType: this.languageSettings.dictInvalidFileType, |
227 | | - dictMaxFilesExceeded: this.languageSettings.dictMaxFilesExceeded, |
228 | | - dictRemoveFile: this.languageSettings.dictRemoveFile, |
229 | | - dictRemoveFileConfirmation: this.languageSettings.dictRemoveFileConfirmation, |
230 | | - dictResponseError: this.languageSettings.dictResponseError, |
231 | | - resizeWidth:this.resizeWidth, |
232 | | - resizeHeight:this.resizeHeight, |
233 | | - resizeMimeType:this.resizeMimeType, |
234 | | - resizeQuality:this.resizeQuality, |
235 | | - resizeMethod:this.resizeMethod, |
236 | | - }) |
237 | | - } else { |
238 | | - this.dropzone = new Dropzone(element, this.dropzoneOptions); |
239 | | - } |
| 223 | + let element = document.getElementById(this.id); |
| 224 | + this.dropzone = new Dropzone(element, { |
| 225 | + clickable : this.getProp(this.clickable,this.dropzoneOptions.clickable), |
| 226 | + paramName : this.getProp(this.paramName,this.dropzoneOptions.paramName), |
| 227 | + thumbnailWidth : this.getProp(this.thumbnailWidth,this.dropzoneOptions.thumbnailWidth), |
| 228 | + thumbnailHeight : this.getProp(this.thumbnailHeight,this.dropzoneOptions.thumbnailHeight), |
| 229 | + maxFiles : this.getProp(this.maxNumberOfFiles,this.dropzoneOptions.maxNumberOfFiles), |
| 230 | + maxFilesize : this.getProp(this.maxFileSizeInMB,this.dropzoneOptions.maxFileSizeInMB), |
| 231 | + addRemoveLinks : this.getProp(this.showRemoveLink,this.dropzoneOptions.showRemoveLink), |
| 232 | + acceptedFiles : this.getProp(this.acceptedFileTypes,this.dropzoneOptions.acceptedFileTypes), |
| 233 | + autoProcessQueue : this.getProp(this.autoProcessQueue,this.dropzoneOptions.autoProcessQueue), |
| 234 | + headers : this.getProp(this.headers,this.dropzoneOptions.headers), |
| 235 | + previewTemplate : this.previewTemplate(this), |
| 236 | + dictDefaultMessage : this.cloudIcon + this.languageSettings.dictDefaultMessage, |
| 237 | + dictCancelUpload : this.languageSettings.dictCancelUpload, |
| 238 | + dictCancelUploadConfirmation: this.languageSettings.dictCancelUploadConfirmation, |
| 239 | + dictFallbackMessage : this.languageSettings.dictFallbackMessage, |
| 240 | + dictFallbackText : this.languageSettings.dictFallbackText, |
| 241 | + dictFileTooBig : this.languageSettings.dictFileTooBig, |
| 242 | + dictInvalidFileType : this.languageSettings.dictInvalidFileType, |
| 243 | + dictMaxFilesExceeded : this.languageSettings.dictMaxFilesExceeded, |
| 244 | + dictRemoveFile : this.languageSettings.dictRemoveFile, |
| 245 | + dictRemoveFileConfirmation : this.languageSettings.dictRemoveFileConfirmation, |
| 246 | + dictResponseError : this.languageSettings.dictResponseError, |
| 247 | + resizeWidth : this.getProp(this.resizeWidth,this.dropzoneOptions.resizeWidth), |
| 248 | + resizeHeight : this.getProp(this.resizeHeight,this.dropzoneOptions.resizeHeight), |
| 249 | + resizeMimeType : this.getProp(this.resizeMimeType,this.dropzoneOptions.resizeMimeType), |
| 250 | + resizeQuality : this.getProp(this.resizeQuality,this.dropzoneOptions.resizeQuality), |
| 251 | + resizeMethod : this.getProp(this.resizeMethod,this.dropzoneOptions.resizeMethod) |
| 252 | + }) |
240 | 253 |
|
241 | 254 | // Handle the dropzone events |
242 | 255 | let vm = this; |
|
0 commit comments