Add clipboard for media page
authorMatthias Schmidt <gravatronics@live.com>
Fri, 25 Dec 2015 08:45:37 +0000 (09:45 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 25 Dec 2015 08:45:37 +0000 (09:45 +0100)
com.woltlab.wcf/clipboardAction.xml
wcfsetup/install/files/acp/templates/mediaList.tpl
wcfsetup/install/files/lib/acp/page/MediaListPage.class.php

index cbe7ec5302b164836ebff29b7f62d5b4df15c132..8e0eea694a8ab081765372d6bd5ca878b2b92ab3 100644 (file)
                        <actionclassname><![CDATA[wcf\system\clipboard\action\MediaClipboardAction]]></actionclassname>
                        <showorder>2</showorder>
                        <pages>
+                               <page><![CDATA[wcf\acp\page\MediaListPage]]></page>
                                <page><![CDATA[menuManagerDialog-editor]]></page>
                                <page><![CDATA[menuManagerDialog-select]]></page>
                        </pages>
index f1ef8a9a9eccc94e2743650d0052514c2d8cf733..75d296d3237aa20495005634115f3894520e8aea 100644 (file)
@@ -1,5 +1,42 @@
 {include file='header' pageTitle='wcf.acp.media.list'}
 
+<script data-relocate="true">
+       require(['EventHandler', 'WoltLab/WCF/Controller/Clipboard'], function(EventHandler, Clipboard) {
+               Clipboard.setup({
+                       hasMarkedItems: {if $hasMarkedItems}true{else}false{/if},
+                       pageClassName: 'wcf\\acp\\page\\MediaListPage'
+               });
+               
+               EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', function(actionData) {
+                       // only consider events if the action has been executed
+                       if (actionData.responseData === null) {
+                               return;
+                       }
+                       
+                       if (actionData.data.actionName === 'com.woltlab.wcf.media.delete') {
+                               var mediaIds = actionData.responseData.objectIDs;
+                               
+                               var mediaRows = elByClass('jsMediaRow');
+                               for (var i = 0; i < mediaRows.length; i++) {
+                                       var media = mediaRows[i];
+                                       var mediaID = ~~elData(elByClass('jsClipboardItem', media)[0], 'object-id');
+                                       
+                                       if (mediaIds.indexOf(mediaID) !== -1) {
+                                               elRemove(media);
+                                               i--;
+                                       }
+                               }
+                               
+                               if (!mediaRows.length) {
+                                       window.location.reload();
+                               }
+                       }
+               });
+               
+               new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.jsMediaRow');
+       });
+</script>
+
 <header class="boxHeadline">
        <h1>{lang}wcf.acp.media.list{/lang}</h1>
        <p>{lang}wcf.acp.media.stats{/lang}</p>
@@ -72,9 +109,10 @@ TODO: add file search
                        <h2>{lang}wcf.acp.media.list{/lang} <span class="badge badgeInverse">{#$items}</span></h2>
                </header>
                
-               <table class="table">
+               <table class="table jsClipboardContainer" data-type="com.woltlab.wcf.media">
                        <thead>
                                <tr>
+                                       <th class="columnMark"><label><input type="checkbox" class="jsClipboardMarkAll" /></label></th>
                                        <th class="columnID columnMediaID{if $sortField == 'mediaID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='MediaList'}pageNo={@$pageNo}&sortField=mediaID&sortOrder={if $sortField == 'mediaID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
                                        <th class="columnTitle columnFilename{if $sortField == 'filename'} active {@$sortOrder}{/if}"><a href="{link controller='MediaList'}pageNo={@$pageNo}&sortField=filename&sortOrder={if $sortField == 'filename' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.media.filename{/lang}</a></th>
                                        <th class="columnDate columnUploadTime{if $sortField == 'uploadTime'} active {@$sortOrder}{/if}"><a href="{link controller='MediaList'}pageNo={@$pageNo}&sortField=uploadTime&sortOrder={if $sortField == 'uploadTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.media.uploadTime{/lang}</a></th>
@@ -86,9 +124,10 @@ TODO: add file search
                        
                        <tbody>
                                {foreach from=$objects item=media}
-                                       <tr class="jsMediaRow">
+                                       <tr class="jsMediaRow jsClipboardObject">
+                                               <td class="columnMark"><input type="checkbox" class="jsClipboardItem" data-object-id="{@$media->mediaID}" /></td>
                                                <td class="columnIcon">
-                                                       <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$media->media}" data-confirm-message="{lang}wcf.media.delete.confirmMessage{/lang}"></span>
+                                                       <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$media->mediaID}" data-confirm-message="{lang}wcf.media.delete.confirmMessage{/lang}"></span>
                                                        
                                                        {event name='rowButtons'}
                                                </td>
@@ -123,6 +162,8 @@ TODO: add file search
                                {event name='contentNavigationButtonsBottom'}
                        </ul>
                </nav>
+
+               <nav class="jsClipboardEditor" data-types="[ 'com.woltlab.wcf.media' ]"></nav>
        </div>
 {else}
        <p class="info">{lang}wcf.global.noItems{/lang}</p>
index 3e62846610aec1956acb582ac7eac82e795869f1..6bd76684332fbaaeae6528aa2749d5943a71ccc3 100644 (file)
@@ -2,6 +2,8 @@
 namespace wcf\acp\page;
 use wcf\data\media\ViewableMediaList;
 use wcf\page\SortablePage;
+use wcf\system\clipboard\ClipboardHandler;
+use wcf\system\WCF;
 
 /**
  * Shows the list of media entries.
@@ -16,32 +18,32 @@ use wcf\page\SortablePage;
  */
 class MediaListPage extends SortablePage {
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        public $activeMenuItem = 'wcf.acp.menu.link.media.list';
        
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        public $defaultSortField = 'uploadTime';
        
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        public $defaultSortOrder = 'DESC';
        
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        public $neededPermissions = ['admin.content.cms.canManageMedia'];
        
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        public $objectListClassName = ViewableMediaList::class;
        
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        public $validSortFields = [
                'filename',
@@ -52,7 +54,16 @@ class MediaListPage extends SortablePage {
        ];
        
        /**
-        * @inheritdoc
+        * @inheritDoc
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign('hasMarkedItems', ClipboardHandler::getInstance()->hasMarkedItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.media')));
+       }
+       
+       /**
+        * @inheritDoc
         */
        protected function readObjects() {
                if ($this->sqlOrderBy && $this->sortField == 'mediaID') {