]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use showBusyState for upload into folder
authorVincent Petry <pvince81@owncloud.com>
Thu, 17 Dec 2015 11:00:29 +0000 (12:00 +0100)
committerVincent Petry <pvince81@owncloud.com>
Fri, 18 Dec 2015 17:09:54 +0000 (18:09 +0100)
This makes sure that the original icon will be restored properly in case
it's not the default folder icon

apps/files/js/filelist.js

index ec82117c2b36153f2d8431c01f2fc026b124f503..0f38d15739d3c0c157106e49ebf528e8e4574f50 100644 (file)
                 */
                showFileBusyState: function(files, state) {
                        var self = this;
-                       if (!_.isArray(files)) {
+                       if (!_.isArray(files) && !files.is) {
                                files = [files];
                        }
 
                                state = true;
                        }
 
-                       _.each(files, function($tr) {
+                       _.each(files, function(fileName) {
                                // jquery element already ?
-                               if (!$tr.is) {
-                                       $tr = self.findFileEl($tr);
+                               var $tr;
+                               if (_.isString(fileName)) {
+                                       $tr = self.findFileEl(fileName);
+                               } else {
+                                       $tr = $(fileName);
                                }
 
                                var $thumbEl = $tr.find('.thumbnail');
                                }
                        });
                        fileUploadStart.on('fileuploadadd', function(e, data) {
+                               console.log('XXXXXXX');
                                OC.Upload.log('filelist handle fileuploadadd', e, data);
 
                                //finish delete if we are uploading a deleted file
 
                                        var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads);
                                        if (currentUploads === 1) {
-                                               var img = OC.imagePath('core', 'loading.gif');
-                                               data.context.find('.thumbnail').css('background-image', 'url(' + img + ')');
+                                               self.showFileBusyState(uploadText.closest('tr'), true);
                                                uploadText.text(translatedText);
                                                uploadText.show();
                                        } else {
                                                uploadText.attr('currentUploads', currentUploads);
                                                var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads);
                                                if (currentUploads === 0) {
-                                                       var img = OC.imagePath('core', 'filetypes/folder');
-                                                       data.context.find('.thumbnail').css('background-image', 'url(' + img + ')');
+                                                       self.showFileBusyState(uploadText.closest('tr'), false);
                                                        uploadText.text(translatedText);
                                                        uploadText.hide();
                                                } else {
                                        }
                                }
                        });
-                       fileUploadStart.on('fileuploadstop', function(e, data) {
-                               OC.Upload.log('filelist handle fileuploadstop', e, data);
+                       fileUploadStart.on('fileuploadstop', function() {
+                               OC.Upload.log('filelist handle fileuploadstop');
+
+                               //cleanup uploading to a dir
+                               var uploadText = self.$fileList.find('tr .uploadtext');
+                               self.showFileBusyState(uploadText.closest('tr'), false);
+                               uploadText.fadeOut();
+                               uploadText.attr('currentUploads', 0);
 
-                               //if user pressed cancel hide upload chrome
-                               if (data.errorThrown === 'abort') {
-                                       //cleanup uploading to a dir
-                                       var uploadText = $('tr .uploadtext');
-                                       var img = OC.imagePath('core', 'filetypes/folder');
-                                       uploadText.parents('td.filename').find('.thumbnail').css('background-image', 'url(' + img + ')');
-                                       uploadText.fadeOut();
-                                       uploadText.attr('currentUploads', 0);
-                               }
                                self.updateStorageStatistics();
                        });
                        fileUploadStart.on('fileuploadfail', function(e, data) {
                                //if user pressed cancel hide upload chrome
                                if (data.errorThrown === 'abort') {
                                        //cleanup uploading to a dir
-                                       var uploadText = $('tr .uploadtext');
-                                       var img = OC.imagePath('core', 'filetypes/folder');
-                                       uploadText.parents('td.filename').find('.thumbnail').css('background-image', 'url(' + img + ')');
+                                       var uploadText = self.$fileList.find('tr .uploadtext');
+                                       self.showFileBusyState(uploadText.closest('tr'), false);
                                        uploadText.fadeOut();
                                        uploadText.attr('currentUploads', 0);
                                }