Use `Ui/Object/Action/Delete` for attachments
authorMatthias Schmidt <gravatronics@live.com>
Sun, 21 Mar 2021 13:47:16 +0000 (14:47 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 21 Mar 2021 13:47:16 +0000 (14:47 +0100)
com.woltlab.wcf/templates/__wysiwygAttachmentFormField.tpl
com.woltlab.wcf/templates/messageFormAttachments.tpl
wcfsetup/install/files/acp/templates/__wysiwygAttachmentFormField.tpl
wcfsetup/install/files/js/WCF.Attachment.js

index a23046b3b6938fd8a58434f9eba6d422fac4531b..6af9540a33c36cb0dbecb8c98e368646515d45b9 100644 (file)
@@ -1,10 +1,11 @@
 <ul id="{@$field->getPrefixedID()}_attachmentList" {*
-       *}class="formAttachmentList"{*
+       *}class="formAttachmentList jsObjectActionContainer" {*
+       *}data-object-action-class-name="wcf\data\attachment\AttachmentAction"{*
        *}{if !$field->getAttachmentHandler()->getAttachmentList()|count} style="display: none"{/if}{*
 *}>
        {foreach from=$field->getAttachmentHandler()->getAttachmentList() item=$attachment}
-               <li class="box64" {*
-                       *}data-object-id="{@$attachment->attachmentID}" {*
+               <li class="box64 jsObjectActionObject" {*
+                       *}data-object-id="{@$attachment->getObjectID()}" {*
                        *}data-height="{@$attachment->height}" {*
                        *}data-width="{@$attachment->width}" {*
                        *}data-is-image="{@$attachment->isImage}"{*
@@ -22,7 +23,7 @@
                                </div>
                                
                                <ul class="buttonGroup">
-                                       <li><span class="button small jsDeleteButton" data-object-id="{@$attachment->attachmentID}" data-confirm-message="{lang}wcf.attachment.delete.sure{/lang}">{lang}wcf.global.button.delete{/lang}</span></li>
+                                       <li><span class="button small jsObjectAction" data-object-action="delete" data-confirm-message="{lang}wcf.attachment.delete.sure{/lang}">{lang}wcf.global.button.delete{/lang}</span></li>
                                        {if $attachment->isImage}
                                                {if $attachment->thumbnailType}
                                                        <li><span class="button small jsButtonAttachmentInsertThumbnail" data-object-id="{@$attachment->attachmentID}" data-url="{$attachment->getThumbnailLink('thumbnail')}">{lang}wcf.attachment.insertThumbnail{/lang}</span></li>
@@ -64,7 +65,6 @@
                        {@$field->getAttachmentHandler()->getMaxCount()},
                        '{@$field->getPrefixedWysiwygId()}'
                );
-               new WCF.Action.Delete('wcf\\data\\attachment\\AttachmentAction', '.formAttachmentList > li');
        });
 </script>
 
index 59fdac98ced8ef7e1f2a9b04f600afd9a5a877f6..c2bc0d30e5a8edcd8866ca11c136977f9507040a 100644 (file)
@@ -1,7 +1,7 @@
 <div class="jsOnly formAttachmentContent messageTabMenuContent" id="attachments_{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if}">
-       <ul class="formAttachmentList clearfix"{if !$attachmentHandler->getAttachmentList()|count} style="display: none"{/if}>
+       <ul class="formAttachmentList clearfix jsObjectActionContainer" data-object-action-class-name="wcf\data\attachment\AttachmentAction"{if !$attachmentHandler->getAttachmentList()|count} style="display: none"{/if}>
                {foreach from=$attachmentHandler->getAttachmentList() item=$attachment}
-                       <li class="box64" data-object-id="{@$attachment->attachmentID}" data-height="{@$attachment->height}" data-width="{@$attachment->width}" data-is-image="{@$attachment->isImage}">
+                       <li class="box64 jsObjectActionObject" data-object-id="{@$attachment->getObjectID()}" data-height="{@$attachment->height}" data-width="{@$attachment->width}" data-is-image="{@$attachment->isImage}">
                                {if $attachment->tinyThumbnailType}
                                        <img src="{$attachment->getThumbnailLink('tiny')}" alt="" class="attachmentTinyThumbnail">
                                {else}
@@ -15,7 +15,7 @@
                                        </div>
                                        
                                        <ul class="buttonGroup">
-                                               <li><span class="button small jsDeleteButton" data-object-id="{@$attachment->attachmentID}" data-confirm-message="{lang}wcf.attachment.delete.sure{/lang}">{lang}wcf.global.button.delete{/lang}</span></li>
+                                               <li><span class="button small jsObjectAction" data-object-action="delete" data-confirm-message="{lang}wcf.attachment.delete.sure{/lang}">{lang}wcf.global.button.delete{/lang}</span></li>
                                                {if $attachment->isImage}
                                                        {if $attachment->thumbnailType}<li><span class="button small jsButtonAttachmentInsertThumbnail" data-object-id="{@$attachment->attachmentID}" data-url="{$attachment->getThumbnailLink('thumbnail')}">{lang}wcf.attachment.insertThumbnail{/lang}</span></li>{/if}
                                                        <li><span class="button small jsButtonAttachmentInsertFull" data-object-id="{@$attachment->attachmentID}" data-url="{$attachment->getLink()}">{lang}wcf.attachment.insertFull{/lang}</span></li>
@@ -74,7 +74,6 @@
                                }
                        }
                );
-               new WCF.Action.Delete('wcf\\data\\attachment\\AttachmentAction', '.formAttachmentList > li');
        });
 </script>
 
index a23046b3b6938fd8a58434f9eba6d422fac4531b..6af9540a33c36cb0dbecb8c98e368646515d45b9 100644 (file)
@@ -1,10 +1,11 @@
 <ul id="{@$field->getPrefixedID()}_attachmentList" {*
-       *}class="formAttachmentList"{*
+       *}class="formAttachmentList jsObjectActionContainer" {*
+       *}data-object-action-class-name="wcf\data\attachment\AttachmentAction"{*
        *}{if !$field->getAttachmentHandler()->getAttachmentList()|count} style="display: none"{/if}{*
 *}>
        {foreach from=$field->getAttachmentHandler()->getAttachmentList() item=$attachment}
-               <li class="box64" {*
-                       *}data-object-id="{@$attachment->attachmentID}" {*
+               <li class="box64 jsObjectActionObject" {*
+                       *}data-object-id="{@$attachment->getObjectID()}" {*
                        *}data-height="{@$attachment->height}" {*
                        *}data-width="{@$attachment->width}" {*
                        *}data-is-image="{@$attachment->isImage}"{*
@@ -22,7 +23,7 @@
                                </div>
                                
                                <ul class="buttonGroup">
-                                       <li><span class="button small jsDeleteButton" data-object-id="{@$attachment->attachmentID}" data-confirm-message="{lang}wcf.attachment.delete.sure{/lang}">{lang}wcf.global.button.delete{/lang}</span></li>
+                                       <li><span class="button small jsObjectAction" data-object-action="delete" data-confirm-message="{lang}wcf.attachment.delete.sure{/lang}">{lang}wcf.global.button.delete{/lang}</span></li>
                                        {if $attachment->isImage}
                                                {if $attachment->thumbnailType}
                                                        <li><span class="button small jsButtonAttachmentInsertThumbnail" data-object-id="{@$attachment->attachmentID}" data-url="{$attachment->getThumbnailLink('thumbnail')}">{lang}wcf.attachment.insertThumbnail{/lang}</span></li>
@@ -64,7 +65,6 @@
                        {@$field->getAttachmentHandler()->getMaxCount()},
                        '{@$field->getPrefixedWysiwygId()}'
                );
-               new WCF.Action.Delete('wcf\\data\\attachment\\AttachmentAction', '.formAttachmentList > li');
        });
 </script>
 
index a00269e6b4329bb54d01f02f4a5a852b7e889e1a..a4f9acaa66896dda176754324e60b13d60fe4ba4 100644 (file)
@@ -524,6 +524,7 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                                if (attachmentData.tinyURL) {
                                        $li.children('.fa-spinner').replaceWith($('<img src="' + attachmentData.tinyURL + '" alt="" class="attachmentTinyThumbnail" />'));
                                        
+                                       $li.addClass('jsObjectActionObject');
                                        $li.data('height', attachmentData.height);
                                        $li.data('width', attachmentData.width);
                                        elData($li[0], 'is-image', attachmentData.isImage);
@@ -548,7 +549,7 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                                
                                // init buttons
                                var $buttonList = $li.find('ul').addClass('buttonGroup');
-                               var $deleteButton = $('<li><span class="button small jsDeleteButton" data-object-id="' + attachmentData.attachmentID + '" data-confirm-message="' + WCF.Language.get('wcf.attachment.delete.sure') + '" data-event-name="attachment">' + WCF.Language.get('wcf.global.button.delete') + '</span></li>');
+                               var $deleteButton = $('<li><span class="button small jsObjectAction" data-object-action="delete" data-confirm-message="' + WCF.Language.get('wcf.attachment.delete.sure') + '" data-event-name="attachment">' + WCF.Language.get('wcf.global.button.delete') + '</span></li>');
                                $buttonList.append($deleteButton);
                                
                                $li.data('objectID', attachmentData.attachmentID);