From da27d58a3386b05dca4d345cee47d9632d6252d6 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 19 Mar 2012 16:54:55 +0100 Subject: [PATCH] Adds the possibility to auto-trigger action effects in WCF.Clipboard If a clipboard item has the following parameters: * actionName * className * objectIDs (ids of the marked objects which would be affected by the action) the following things happen: * An AJAX action with actionName and className is executed (if additionally a confirm message is given, the user has to handle that first before the action is executed). * It's checked if an action object for the relevant object type and actionName exists in WCF.Clipboard exists and for each object id in objectIDs triggerEffect(objectID) on the action object is called. This way deleted objects are also removed from the table or toggled objects get updated toggle "buttons". To achieve the second part, WCF.Action.Delete and WCF.Action.Toggle have a new method: triggerEffect() which is basically the content of _success but can now be called from WCF.Clipboard with the relevant object ids. Furthermore UserClipboardAction returns the relevant user ids if the delete action is active. --- Additionally, I update the javascript handling of the user list in the acp: * The deletion button works and uses WCF.Action.Delete. * The new WCF.Table.EmptyTablerHandler is in use. * The above mentioned WCF.Clipboard changed are implemented which is mainly adding a few javascript lines and removing several obsolete lines from WCF.ACP. --- wcfsetup/install/files/acp/js/WCF.ACP.js | 43 --------- .../install/files/acp/templates/userList.tpl | 20 +++- wcfsetup/install/files/js/WCF.js | 94 +++++++++++++++---- .../files/lib/acp/page/UserListPage.class.php | 2 +- .../files/lib/data/user/UserEditor.class.php | 11 +++ .../action/UserClipboardAction.class.php | 27 ++---- 6 files changed, 113 insertions(+), 84 deletions(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 66478f30fb..7daa572a40 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -656,49 +656,6 @@ WCF.ACP.Options.prototype = { } } } - - -}; - -/** - * Namespace for WCF.ACP.User - */ -WCF.ACP.User = {}; - -/** - * UserList clipboard API - */ -WCF.ACP.User.List = function() { this.init(); }; -WCF.ACP.User.List.prototype = { - /** - * Initializes the UserList clipboard API. - */ - init: function() { - $('body').bind('clipboardAction', $.proxy(this.handleClipboardEvent, this)); - }, - - /** - * Event handler for clipboard editor item actions. - */ - handleClipboardEvent: function(event, type, actionName) { - // ignore unrelated events - if ((type != 'com.woltlab.wcf.user') || (actionName != 'user.delete')) return; - - var $item = $(event.target); - this._delete($item); - }, - - /** - * Handle delete action. - * - * @param jQuery item - */ - _delete: function(item) { - var $confirmMessage = item.data('internalData')['confirmMessage']; - WCF.System.Confirmation.show($confirmMessage, function() { - WCF.Clipboard.sendRequest(item); - }); - } }; /** diff --git a/wcfsetup/install/files/acp/templates/userList.tpl b/wcfsetup/install/files/acp/templates/userList.tpl index a882400ccc..55f00e66c3 100644 --- a/wcfsetup/install/files/acp/templates/userList.tpl +++ b/wcfsetup/install/files/acp/templates/userList.tpl @@ -3,8 +3,18 @@ @@ -34,7 +44,7 @@ -
+