From: Matthias Schmidt Date: Tue, 16 Aug 2016 17:07:37 +0000 (+0200) Subject: Fix deletion of media files via button X-Git-Tag: 3.0.0_Beta_1~733 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2b11f76db6ca172a49f0551979db9a68f4900b1b;p=GitHub%2FWoltLab%2FWCF.git Fix deletion of media files via button --- diff --git a/com.woltlab.wcf/templates/mediaJavaScript.tpl b/com.woltlab.wcf/templates/mediaJavaScript.tpl index 76d9aae80d..c929e711be 100644 --- a/com.woltlab.wcf/templates/mediaJavaScript.tpl +++ b/com.woltlab.wcf/templates/mediaJavaScript.tpl @@ -3,6 +3,7 @@ Language.addObject({ 'wcf.global.button.insert': '{lang}wcf.global.button.insert{/lang}', + 'wcf.media.delete.confirmMessage': '{lang __encode=true}wcf.media.delete.confirmMessage{/lang}', 'wcf.media.insert': '{lang}wcf.media.insert{/lang}', 'wcf.media.insert.imageSize': '{lang}wcf.media.insert.imageSize{/lang}', 'wcf.media.insert.imageSize.small': '{lang}wcf.media.insert.imageSize.small{/lang}', diff --git a/com.woltlab.wcf/templates/mediaListItems.tpl b/com.woltlab.wcf/templates/mediaListItems.tpl index e87f2937eb..b2f0c5e539 100644 --- a/com.woltlab.wcf/templates/mediaListItems.tpl +++ b/com.woltlab.wcf/templates/mediaListItems.tpl @@ -1,5 +1,5 @@ {foreach from=$mediaList item=media} -
  • +
  • {@$media->getElementTag(144)}
    @@ -18,7 +18,7 @@
  • - +
  • {/if} {if $mode == 'editor'} diff --git a/wcfsetup/install/files/acp/templates/mediaJavaScript.tpl b/wcfsetup/install/files/acp/templates/mediaJavaScript.tpl index 76d9aae80d..c929e711be 100644 --- a/wcfsetup/install/files/acp/templates/mediaJavaScript.tpl +++ b/wcfsetup/install/files/acp/templates/mediaJavaScript.tpl @@ -3,6 +3,7 @@ Language.addObject({ 'wcf.global.button.insert': '{lang}wcf.global.button.insert{/lang}', + 'wcf.media.delete.confirmMessage': '{lang __encode=true}wcf.media.delete.confirmMessage{/lang}', 'wcf.media.insert': '{lang}wcf.media.insert{/lang}', 'wcf.media.insert.imageSize': '{lang}wcf.media.insert.imageSize{/lang}', 'wcf.media.insert.imageSize.small': '{lang}wcf.media.insert.imageSize.small{/lang}', diff --git a/wcfsetup/install/files/acp/templates/mediaListItems.tpl b/wcfsetup/install/files/acp/templates/mediaListItems.tpl index 48ffdb73d9..ce2ff7e855 100644 --- a/wcfsetup/install/files/acp/templates/mediaListItems.tpl +++ b/wcfsetup/install/files/acp/templates/mediaListItems.tpl @@ -1,5 +1,5 @@ {foreach from=$mediaList item=media} -
  • +
  • {@$media->getElementTag(144)}
    @@ -18,7 +18,7 @@
  • - +
  • {/if} {if $mode == 'editor'} diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js index ee4036e929..3de3e45265 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js @@ -83,7 +83,7 @@ define( */ _clipboardAction: function(actionData) { // only consider events if the action has been executed - if (actionData.data.actionName === 'com.woltlab.wcf.media.delete' && actionData.responseData === null) { + if (actionData.data.actionName === 'com.woltlab.wcf.media.delete' && actionData.responseData !== null) { var mediaIds = actionData.responseData.objectIDs; for (var i = 0, length = mediaIds.length; i < length; i++) { this.removeMedia(~~mediaIds[i], true); @@ -137,6 +137,11 @@ define( }); EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', this._clipboardAction.bind(this)); + + var deleteAction = new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.mediaFile'); + deleteAction._didTriggerEffect = function(element) { + this.removeMedia(elData(element[0], 'object-id'), true); + }.bind(this); } this._search = new MediaManagerSearch(this); @@ -325,7 +330,12 @@ define( removeMedia: function(mediaId, checkCache) { if (this._media.has(mediaId)) { // remove list item - elRemove(this._media.get(mediaId)); + try { + elRemove(this._media.get(mediaId)); + } + catch (e) { + // ignore errors if item has already been removed like by WCF.Action.Delete + } this._media.delete(mediaId); this._mediaData.delete(mediaId); @@ -432,8 +442,9 @@ define( listItem.appendChild(a); icon = elCreate('span'); - icon.className = 'icon icon16 fa-times jsTooltip jsMediaDeleteIcon'; + icon.className = 'icon icon16 fa-times jsTooltip jsDeleteButton'; elData(icon, 'object-id', media.mediaID); + elData(icon, 'confirm-message-html', Language.get('wcf.media.delete.confirmMessage')); elAttr(icon, 'title', Language.get('wcf.global.button.delete')); a.appendChild(icon); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js index e26f6821e7..80a411f679 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js @@ -123,7 +123,7 @@ define( fileIcon.classList.add(FileUtil.getIconClassByMimeType(media.fileType)); } - file.className = 'jsClipboardObject'; + file.className = 'jsClipboardObject mediaFile'; elData(file, 'object-id', media.mediaID); if (this._mediaManager) {