From 2c9a88aedb7d133c5cdaa7d71bdb1586b2c327ca Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 17 Sep 2017 14:51:09 +0200 Subject: [PATCH] Fix deleting only row in media list if row belongs to upload error --- .../js/WoltLabSuite/Core/Controller/Media/List.js | 13 ++++++++++--- .../files/js/WoltLabSuite/Core/Media/Upload.js | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) 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'); -- 2.20.1