From 49c164a81811c709e52b919e448e41f7f9f890cd Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 23 Oct 2012 22:15:29 +0200 Subject: [PATCH] Added option to unmark all clipboard items per type Fixes #823 --- .../install/files/acp/templates/header.tpl | 2 - wcfsetup/install/files/js/WCF.js | 63 +++++++++++-------- .../files/lib/data/user/UserAction.class.php | 13 ++++ .../clipboard/ClipboardHandler.class.php | 8 +++ .../action/IClipboardAction.class.php | 7 +++ .../action/UserClipboardAction.class.php | 7 +++ wcfsetup/install/lang/de.xml | 1 + 7 files changed, 73 insertions(+), 28 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/header.tpl b/wcfsetup/install/files/acp/templates/header.tpl index 46af20d5d9..b9785a576f 100644 --- a/wcfsetup/install/files/acp/templates/header.tpl +++ b/wcfsetup/install/files/acp/templates/header.tpl @@ -87,8 +87,6 @@ new WCF.Effect.SmoothScroll(); new WCF.Effect.BalloonTooltip(); - $('#sidebarContent').wcfSidebar(); - WCF.Dropdown.init(); new WCF.ACP.Search(); diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index e31a8484d7..00bc08b95f 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -1155,6 +1155,11 @@ WCF.Clipboard = { // create editor items for (var $itemIndex in $editor.items) { var $item = $editor.items[$itemIndex]; + + if ($item.actionName === 'unmarkAll') { + $('
  • ' + $item.label + '
  • ').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) diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index 6dc67cc989..d4b6f19258 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -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')); + } } diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index 4bc2c19140..e338d333e0 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -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; diff --git a/wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php index 14d5d135d0..7ac517881f 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php @@ -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. * diff --git a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php index 6bd780cf83..a99734a75f 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php @@ -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. * diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 2b353a6f2e..1ea7d9af72 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -449,6 +449,7 @@ + -- 2.20.1