From b2e0e0cd51560f45713194b64fb9114a71aae505 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 12 Dec 2014 13:24:46 +0100 Subject: [PATCH] Added proper moderation queue dropdown handling --- .../templates/moderationQueueList.tpl | 12 +-- com.woltlab.wcf/templates/userPanel.tpl | 14 +++- wcfsetup/install/files/js/WCF.Moderation.js | 79 ++++++++++++------- .../queue/ModerationQueueAction.class.php | 13 +++ .../queue/ModerationQueueManager.class.php | 5 +- wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 7 files changed, 86 insertions(+), 39 deletions(-) diff --git a/com.woltlab.wcf/templates/moderationQueueList.tpl b/com.woltlab.wcf/templates/moderationQueueList.tpl index 5ba8cb0e67..6c0a981871 100644 --- a/com.woltlab.wcf/templates/moderationQueueList.tpl +++ b/com.woltlab.wcf/templates/moderationQueueList.tpl @@ -1,13 +1,13 @@ {foreach from=$queues item=queue} -
  • - +
  • +
  • {/foreach} \ No newline at end of file diff --git a/com.woltlab.wcf/templates/userPanel.tpl b/com.woltlab.wcf/templates/userPanel.tpl index d6fb8b900e..65e91f142d 100644 --- a/com.woltlab.wcf/templates/userPanel.tpl +++ b/com.woltlab.wcf/templates/userPanel.tpl @@ -191,13 +191,21 @@ diff --git a/wcfsetup/install/files/js/WCF.Moderation.js b/wcfsetup/install/files/js/WCF.Moderation.js index 3e44f23c70..5e6af1f665 100644 --- a/wcfsetup/install/files/js/WCF.Moderation.js +++ b/wcfsetup/install/files/js/WCF.Moderation.js @@ -181,7 +181,7 @@ WCF.Moderation.Management = Class.extend({ $('' + WCF.String.escapeHTML(data.returnValues.username) + '').appendTo($span); } else { - $span.append(data.returnValues.username) + $span.append(data.returnValues.username); } $span.append(' '); @@ -614,51 +614,74 @@ WCF.Moderation.Report.Management = WCF.Moderation.Management.extend({ }); /** - * Provides a dropdown for user panel. + * User Panel implementation for moderation queues. * - * @see WCF.UserPanel + * @see WCF.User.Panel.Abstract */ -WCF.Moderation.UserPanel = WCF.UserPanel.extend({ +WCF.User.Panel.Moderation = WCF.User.Panel.Abstract.extend({ /** - * link to show all outstanding queues - * @var string + * @see WCF.User.Panel.Abstract.init() */ - _showAllLink: '', + init: function(options) { + options.enableMarkAsRead = true; + + this._super($('#outstandingModeration'), 'outstandingModeration', options); + }, /** - * link to deleted content list - * @var string + * @see WCF.User.Panel.Abstract._initDropdown() */ - _deletedContentLink: '', + _initDropdown: function() { + var $dropdown = this._super(); + + $('
  • ').appendTo($dropdown.getLinkList()); + + return $dropdown; + }, /** - * @see WCF.UserPanel.init() + * @see WCF.User.Panel.Abstract._load() */ - init: function(showAllLink, deletedContentLink) { - this._noItems = 'wcf.moderation.noMoreItems'; - this._showAllLink = showAllLink; - this._deletedContentLink = deletedContentLink; - - this._super('outstandingModeration'); + _load: function() { + this._proxy.setOption('data', { + actionName: 'getOutstandingQueues', + className: 'wcf\\data\\moderation\\queue\\ModerationQueueAction' + }); + this._proxy.sendRequest(); }, /** - * @see WCF.UserPanel._addDefaultItems() + * @see WCF.User.Panel.Abstract._markAsRead() */ - _addDefaultItems: function(dropdownMenu) { - this._addDivider(dropdownMenu); - $('
  • ' + WCF.Language.get('wcf.moderation.showAll') + '
  • ').appendTo(dropdownMenu); - this._addDivider(dropdownMenu); - $('
  • ' + WCF.Language.get('wcf.moderation.showDeletedContent') + '
  • ').appendTo(dropdownMenu); + _markAsRead: function(event, objectID) { + this._proxy.setOption('data', { + actionName: 'markAsRead', + className: 'wcf\\data\\moderation\\queue\\ModerationQueueAction', + objectIDs: [ objectID ] + }); + this._proxy.sendRequest(); }, /** - * @see WCF.UserPanel._getParameters() + * @see WCF.User.Panel.Abstract._markAllAsRead() */ - _getParameters: function() { - return { - actionName: 'getOutstandingQueues', + _markAllAsRead: function(event) { + this._proxy.setOption('data', { + actionName: 'markAllAsRead', className: 'wcf\\data\\moderation\\queue\\ModerationQueueAction' - }; + }); + this._proxy.sendRequest(); + }, + + /** + * @see WCF.User.Panel.Abstract._success() + */ + _success: function(data) { + this._super(data); + + if (data.actionName === 'markAllAsConfirmed') { + this.resetItems(); + this.updateBadge(0); + } } }); diff --git a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php index ce62822e70..a9f182f361 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php @@ -257,6 +257,15 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction { // reset storage UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadModerationCount'); + + if (count($this->objects) == 1) { + $queue = reset($this->objects); + + return array( + 'markAsRead' => $queue->queueID, + 'totalCount' => ModerationQueueManager::getInstance()->getUnreadModerationCount(true) + ); + } } /** @@ -282,6 +291,10 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction { // reset storage UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadModerationCount'); + + return array( + 'markAllAsRead' => true + ); } /** diff --git a/wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php b/wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php index f9b75ddb53..56b04078ee 100644 --- a/wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php +++ b/wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php @@ -243,14 +243,15 @@ class ModerationQueueManager extends SingletonFactory { /** * Returns the count of unread moderation queue items. * + * @param boolean $skipCache * @return integer */ - public function getUnreadModerationCount() { + public function getUnreadModerationCount($skipCache = false) { // get count $count = UserStorageHandler::getInstance()->getField('unreadModerationCount'); // cache does not exist or is outdated - if ($count === null) { + if ($count === null || $skipCache) { // force update of non-tracked queues for this user $this->forceUserAssignment(); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 6afbbb7086..a3df19c604 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2323,6 +2323,7 @@ Fehler sind beispielsweise: + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 1dbf74ccc0..a04bc639a8 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2322,6 +2322,7 @@ Errors are: + -- 2.20.1