Added option to unmark all clipboard items per type
authorAlexander Ebert <ebert@woltlab.com>
Tue, 23 Oct 2012 20:15:29 +0000 (22:15 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 23 Oct 2012 20:15:29 +0000 (22:15 +0200)
Fixes #823

wcfsetup/install/files/acp/templates/header.tpl
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php
wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php
wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php
wcfsetup/install/lang/de.xml

index 46af20d5d9eae9068db2f9336249d7702f263e95..b9785a576f025ac707f7bcc57870d7ec0bc85d92 100644 (file)
@@ -87,8 +87,6 @@
                        new WCF.Effect.SmoothScroll();
                        new WCF.Effect.BalloonTooltip();
                        
-                       $('#sidebarContent').wcfSidebar();
-                       
                        WCF.Dropdown.init();
                        
                        new WCF.ACP.Search();
index e31a8484d774a09d08e27066297ba38617ea5952..00bc08b95f064d4b92e78426a4bd12b22eaff655 100755 (executable)
@@ -1155,6 +1155,11 @@ WCF.Clipboard = {
                        // create editor items
                        for (var $itemIndex in $editor.items) {
                                var $item = $editor.items[$itemIndex];
+                               
+                               if ($item.actionName === 'unmarkAll') {
+                                       $('<li class="dropdownDivider" />').appendTo($itemList);
+                               }
+                               
                                var $listItem = $('<li><span>' + $item.label + '</span></li>').appendTo($itemList);
                                $listItem.data('objectType', $typeName);
                                $listItem.data('actionName', $item.actionName).data('parameters', $item.parameters);
@@ -1194,29 +1199,31 @@ WCF.Clipboard = {
                        window.location.href = $url;
                }
                
-               if ($listItem.data('parameters').className && $listItem.data('parameters').actionName && $listItem.data('parameters').objectIDs) {
-                       var $confirmMessage = $listItem.data('internalData')['confirmMessage'];
-                       if ($confirmMessage) {
-                               var $template = $listItem.data('internalData')['template'];
-                               if ($template) $template = $($template);
-                               
-                               WCF.System.Confirmation.show($confirmMessage, $.proxy(function(action) {
-                                       if (action === 'confirm') {
-                                               var $data = { };
-                                               
-                                               if ($template && $template.length) {
-                                                       $('#wcfSystemConfirmationContent').find('input, select, textarea').each(function(index, item) {
-                                                               var $item = $(item);
-                                                               $data[$item.prop('name')] = $item.val();
-                                                       });
+               if ($listItem.data('parameters').className && $listItem.data('parameters').actionName) {
+                       if ($listItem.data('parameters').actionName === 'unmarkAll' || $listItem.data('parameters').objectIDs) {
+                               var $confirmMessage = $listItem.data('internalData')['confirmMessage'];
+                               if ($confirmMessage) {
+                                       var $template = $listItem.data('internalData')['template'];
+                                       if ($template) $template = $($template);
+                                       
+                                       WCF.System.Confirmation.show($confirmMessage, $.proxy(function(action) {
+                                               if (action === 'confirm') {
+                                                       var $data = { };
+                                                       
+                                                       if ($template && $template.length) {
+                                                               $('#wcfSystemConfirmationContent').find('input, select, textarea').each(function(index, item) {
+                                                                       var $item = $(item);
+                                                                       $data[$item.prop('name')] = $item.val();
+                                                               });
+                                                       }
+                                                       
+                                                       this._executeAJAXActions($listItem, $data);
                                                }
-                                               
-                                               this._executeAJAXActions($listItem, $data);
-                                       }
-                               }, this), '', $template);
-                       }
-                       else {
-                               this._executeAJAXActions($listItem, { });
+                                       }, this), '', $template);
+                               }
+                               else {
+                                       this._executeAJAXActions($listItem, { });
+                               }
                        }
                }
                
@@ -1233,9 +1240,11 @@ WCF.Clipboard = {
        _executeAJAXActions: function(listItem, data) {
                data = data || { };
                var $objectIDs = [];
-               $.each(listItem.data('parameters').objectIDs, function(index, objectID) {
-                       $objectIDs.push(parseInt(objectID));
-               });
+               if (listItem.data('parameters').actionName !== 'unmarkAll') {
+                       $.each(listItem.data('parameters').objectIDs, function(index, objectID) {
+                               $objectIDs.push(parseInt(objectID));
+                       });
+               }
                
                var $parameters = {
                        data: data
@@ -1256,7 +1265,9 @@ WCF.Clipboard = {
                                parameters: $parameters
                        },
                        success: $.proxy(function(data) {
-                               listItem.trigger('clipboardActionResponse', [ data, listItem.data('type'), listItem.data('actionName'), listItem.data('parameters') ]);
+                               if (listItem.data('parameters').actionName !== 'unmarkAll') {
+                                       listItem.trigger('clipboardActionResponse', [ data, listItem.data('type'), listItem.data('actionName'), listItem.data('parameters') ]);
+                               }
                                
                                this._loadMarkedItems();
                        }, this)
index 6dc67cc98971ff2f66c9fc8a6345b558a80827a1..d4b6f1925870ef5b9bf052ebde57c7e7afd223e0 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\data\user;
 use wcf\data\user\group\UserGroup;
 use wcf\data\AbstractDatabaseObjectAction;
 use wcf\data\ISearchAction;
+use wcf\system\clipboard\ClipboardHandler;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\ValidateActionException;
@@ -262,4 +263,16 @@ class UserAction extends AbstractDatabaseObjectAction implements ISearchAction {
                
                return $list;
        }
+       
+       /**
+        * Does nothing.
+        */
+       public function validateUnmarkAll() { }
+       
+       /**
+        * Unmarks all users.
+        */
+       public function unmarkAll() {
+               ClipboardHandler::getInstance()->removeItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user'));
+       }
 }
index 4bc2c1914037d74ef457efea2f178ef0d0c158ca..e338d333e016c23d3f75f8528d390611f9fb451f 100644 (file)
@@ -284,6 +284,14 @@ class ClipboardHandler extends SingletonFactory {
                                
                                $editorData[$typeName]['items'][$action] = $data;
                        }
+                       
+                       // append 'unmark all' item
+                       $unmarkAll = new ClipboardEditorItem();
+                       $unmarkAll->setName('unmarkAll');
+                       $unmarkAll->addParameter('actionName', 'unmarkAll');
+                       $unmarkAll->addParameter('className', $actionData['object']->getClassName());
+                       
+                       $editorData[$typeName]['items'][] = $unmarkAll;
                }
                
                return $editorData;
index 14d5d135d0d33ef8a4b373a908a575f8a1cf8274..7ac517881f8b4066a8c094bd7e5a541361c47909 100644 (file)
@@ -29,6 +29,13 @@ interface IClipboardAction {
         */
        public function execute(array $objects, $actionName, array $typeData = array());
        
+       /**
+        * Returns action class name.
+        * 
+        * @return      string
+        */
+       public function getClassName();
+       
        /**
         * Returns label for item editor.
         * 
index 6bd780cf8318c91cb05cedc5cd5e3f397349e12f..a99734a75ff84c4a98c87ceb0196549b9ec3f6bc 100644 (file)
@@ -69,6 +69,13 @@ class UserClipboardAction implements IClipboardAction {
                return $item;
        }
        
+       /**
+        * @see wcf\system\clipboard\action\IClipboardAction::getClassName()
+        */
+       public function getClassName() {
+               return 'wcf\data\user\UserAction';
+       }
+       
        /**
         * Returns the ids of the users which can be deleted.
         * 
index 2b353a6f2e2e0964a11f34389ba20e8692599fa6..1ea7d9af72fe5457217c94126ca7a7fc7dab5f73 100644 (file)
        </category>
        
        <category name="wcf.clipboard">
+               <item name="wcf.clipboard.item.unmarkAll"><![CDATA[Demarkieren]]></item>
                <item name="wcf.clipboard.item.user.assignToGroup"><![CDATA[Benutzergruppe zuweisen]]></item>
                <item name="wcf.clipboard.item.user.delete"><![CDATA[Benutzer löschen]]></item>
                <item name="wcf.clipboard.item.user.delete.confirmMessage"><![CDATA[{if $count == 1}Einen{else}{#$count}{/if} Benutzer löschen?]]></item>