From: Matthias Schmidt Date: Sun, 17 Sep 2017 12:51:09 +0000 (+0200) Subject: Fix deleting only row in media list if row belongs to upload error X-Git-Tag: 3.1.0_Alpha_4~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2c9a88aedb7d133c5cdaa7d71bdb1586b2c327ca;p=GitHub%2FWoltLab%2FWCF.git Fix deleting only row in media list if row belongs to upload error --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js index f425bc7c6d..52dd840fc3 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js @@ -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} 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(); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js index 9d309743c1..f75163306f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js @@ -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');