Fix deleting only row in media list if row belongs to upload error
authorMatthias Schmidt <gravatronics@live.com>
Sun, 17 Sep 2017 12:51:09 +0000 (14:51 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 17 Sep 2017 12:51:09 +0000 (14:51 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js

index f425bc7c6d315a58776901bcb66fda602dc4983c..52dd840fc3a69dc41eb3c88dbc93968a49324819 100644 (file)
@@ -52,6 +52,7 @@ define([
                        });
                        
                        EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', this._clipboardAction.bind(this));
+                       EventHandler.add('com.woltlab.wcf.media.upload', 'removedErroneousUploadRow', this._deleteCallback.bind(this));
                        
                        var deleteAction = new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.jsMediaRow');
                        deleteAction.setCallback(this._deleteCallback);
@@ -87,10 +88,16 @@ define([
                /**
                 * Is triggered after media files have been deleted using the delete icon.
                 * 
-                * @param       {array<int>}    objectId
+                * @param       {int[]?}        objectIds
                 */
-               _deleteCallback: function(objectId) {
-                       if (objectId.length === elByTag('tr', _tableBody).length) {
+               _deleteCallback: function(objectIds) {
+                       var tableRowCount = elByTag('tr', _tableBody).length;
+                       if (objectIds.length === undefined) {
+                               if (!tableRowCount) {
+                                       window.location.reload();
+                               }
+                       }
+                       else if (objectIds.length === tableRowCount) {
                                // table is empty, reload page
                                window.location.reload();
                        }
index 9d309743c1542898f2dbb217f5bc665a14bec52c..f75163306fd686fa95fe4b4ad98c1d605fdedc3d 100644 (file)
@@ -281,6 +281,8 @@ define(
                                                elAttr(fileIcon, 'title', Language.get('wcf.global.button.delete'));
                                                fileIcon.addEventListener(WCF_CLICK_EVENT, function (event) {
                                                        elRemove(event.currentTarget.parentNode.parentNode.parentNode);
+                                                       
+                                                       EventHandler.fire('com.woltlab.wcf.media.upload', 'removedErroneousUploadRow');
                                                });
                                                
                                                file.classList.add('uploadFailed');