Replace fileName variable with data.files[0].name
There is no need to store the file name, as the "data" parameter given to all the callbacks provides a "files" attribute with all the files that the callback refers to; moreover, it will always be a single file due to the use of "singleFileUploads" in the jQuery File Upload plugin. This also fixes the loading icon not disappearing when several files were uploaded at once. "singleFileUploads" causes the "add" callback to be called once for each file to be uploaded, so "fileName" was overwritten with the name of each new file in the upload set; when "fileName" was later used in the "done" callback to find the file in the list whose loading icon replace with the MIME type icon "fileName" always had the name of the last file, and thus its icon was the only one replaced. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
b68bad45dc
commit
03c6c5bd93
|
@ -64,7 +64,7 @@
|
|||
$('#drop-upload-done-indicator').addClass('hidden');
|
||||
$('#drop-upload-progress-indicator').removeClass('hidden');
|
||||
_.each(data['files'], function(file) {
|
||||
$('#public-upload ul').append(output({isUploading: true, name: escapeHTML(file.name)}));
|
||||
$('#public-upload ul').append(output({isUploading: true, name: file.name}));
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
data.submit();
|
||||
});
|
||||
|
@ -83,14 +83,12 @@
|
|||
e.preventDefault();
|
||||
});
|
||||
var output = this.template();
|
||||
var fileName = undefined;
|
||||
$('#public-upload').fileupload({
|
||||
type: 'PUT',
|
||||
dropZone: $('#public-upload'),
|
||||
sequentialUploads: true,
|
||||
add: function(e, data) {
|
||||
Drop.addFileToUpload(e, data);
|
||||
fileName = escapeHTML(data.files[0].name);
|
||||
//we return true to keep trying to upload next file even
|
||||
//if addFileToUpload did not like the privious one
|
||||
return true;
|
||||
|
@ -98,18 +96,18 @@
|
|||
done: function(e, data) {
|
||||
// Created
|
||||
var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type);
|
||||
var fileItem = output({isUploading: false, iconSrc: mimeTypeUrl, name: fileName});
|
||||
Drop.updateFileItem(fileName, fileItem);
|
||||
var fileItem = output({isUploading: false, iconSrc: mimeTypeUrl, name: data.files[0].name});
|
||||
Drop.updateFileItem(data.files[0].name, fileItem);
|
||||
},
|
||||
fail: function(e, data) {
|
||||
OC.Notification.showTemporary(OC.L10N.translate(
|
||||
'files_sharing',
|
||||
'Could not upload "{filename}"',
|
||||
{filename: fileName}
|
||||
{filename: data.files[0].name}
|
||||
));
|
||||
var errorIconSrc = OC.imagePath('core', 'actions/error.svg');
|
||||
var fileItem = output({isUploading: false, iconSrc: errorIconSrc, name: fileName});
|
||||
Drop.updateFileItem(fileName, fileItem);
|
||||
var fileItem = output({isUploading: false, iconSrc: errorIconSrc, name: data.files[0].name});
|
||||
Drop.updateFileItem(data.files[0].name, fileItem);
|
||||
},
|
||||
progressall: function (e, data) {
|
||||
var progress = parseInt(data.loaded / data.total * 100, 10);
|
||||
|
|
Loading…
Reference in New Issue