Remove errors on upload
authorJoshua Rüsweg <josh@bastelstu.be>
Sun, 20 Jan 2019 18:38:21 +0000 (19:38 +0100)
committerJoshua Rüsweg <josh@bastelstu.be>
Sun, 20 Jan 2019 18:38:21 +0000 (19:38 +0100)
See #2825

wcfsetup/install/files/js/WoltLabSuite/Core/Ui/File/Upload.js

index fae2649eac854fcd7125bb827e1f54f304f42f21..25743c85da7f0e4b15e3843f649fda3cefcbae90 100644 (file)
@@ -122,6 +122,13 @@ define(['Core', 'Language', 'Dom/Util', 'WoltLabSuite/Core/Ui/File/Delete', 'Upl
                        throw new Error("Upload failed: " + data.message);
                },
                
+               _upload: function(event, file, blob) {
+                       var innerError = elBySel('small.innerError:not(.innerFileError)', this._buttonContainer.parentNode);
+                       if (innerError) elRemove(innerError);
+                       
+                       return Upload._super.prototype._upload.call(this, event, file, blob);
+               },
+               
                _success: function(uploadId, data, responseText, xhr, requestOptions) {
                        for (var i in this._fileElements[uploadId]) {
                                if (data['files'][i] !== undefined) {
@@ -199,7 +206,9 @@ define(['Core', 'Language', 'Dom/Util', 'WoltLabSuite/Core/Ui/File/Delete', 'Upl
                                        DomUtil.insertAfter(innerError, this._buttonContainer);
                                }
                                
-                               innerError.textContent = WCF.Language.get('wcf.upload.error.reachedRemainingLimit').replace(/#remaining#/, this._options.maxFiles);
+                               innerError.textContent = Language.get('wcf.upload.error.reachedRemainingLimit', {
+                                       maxFiles: this._options.maxFiles - this.countFiles()
+                               });
                                
                                return false;
                        }