Added proper moderation queue dropdown handling
authorAlexander Ebert <ebert@woltlab.com>
Fri, 12 Dec 2014 12:24:46 +0000 (13:24 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 12 Dec 2014 12:24:46 +0000 (13:24 +0100)
com.woltlab.wcf/templates/moderationQueueList.tpl
com.woltlab.wcf/templates/userPanel.tpl
wcfsetup/install/files/js/WCF.Moderation.js
wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php
wcfsetup/install/files/lib/system/moderation/queue/ModerationQueueManager.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 5ba8cb0e673c14f40ec5df02d74affac9c178d0f..6c0a9818710f33cc8413ad8965b24575927a93c7 100644 (file)
@@ -1,13 +1,13 @@
 {foreach from=$queues item=queue}
-       <li>
-               <a href="{@$queue->getLink()}" class="box24">
+       <li class="moderationQueueEntry{if $queue->isNew()} interactiveDropdownItemOutstanding{/if}" data-link="{$queue->getLink()}" data-object-id="{@$queue->queueID}" data-is-read="{if $queue->isNew()}false{else}true{/if}">
+               <div class="box32">
                        <div class="framed">
-                               {@$queue->getUserProfile()->getAvatar()->getImageTag(24)}
+                               {@$queue->getUserProfile()->getAvatar()->getImageTag(32)}
                        </div>
                        <div>
-                               <h3>{$queue->getAffectedObject()->getTitle()}</h3>
-                               <small>{$queue->getAffectedObject()->getUsername()} - {@$queue->getAffectedObject()->getTime()|time}</small>
+                               <h3><a href="{@$queue->getLink()}">{$queue->getAffectedObject()->getTitle()}</a></h3>
+                               <small>{if $queue->getUserProfile()->userID}<a href="{link controller='User' object=$queue->getUserProfile()->getDecoratedObject()}{/link}">{$queue->getAffectedObject()->getUsername()}</a>{else}{$queue->getAffectedObject()->getUsername()}{/if} - {@$queue->getAffectedObject()->getTime()|time}</small>
                        </div>
-               </a>
+               </div>
        </li>
 {/foreach}
\ No newline at end of file
index d6fb8b900e38657f249ed4075c28bbc83ae61263..65e91f142d586c7d2701f38d99df910aace315b9 100644 (file)
                                <script data-relocate="true">
                                        //<![CDATA[
                                        $(function() {
-                                               WCF.Language.addObject({
+                                               /*WCF.Language.addObject({
                                                        'wcf.moderation.noMoreItems': '{lang}wcf.moderation.noMoreItems{/lang}',
                                                        'wcf.moderation.showAll': '{lang}wcf.moderation.showAll{/lang}',
                                                        'wcf.moderation.showDeletedContent': '{lang}wcf.moderation.showDeletedContent{/lang}'
-                                               });
+                                               });*/
+                                               
+                                               //new WCF.Moderation.UserPanel('{link controller='ModerationList' encode=false}{/link}', '{link controller='DeletedContentList' encode=false}{/link}');
                                                
-                                               new WCF.Moderation.UserPanel('{link controller='ModerationList' encode=false}{/link}', '{link controller='DeletedContentList' encode=false}{/link}');
+                                               new WCF.User.Panel.Moderation({
+                                                       deletedContent: '{lang}wcf.moderation.showDeletedContent{/lang}',
+                                                       deletedContentLink: '{link controller='DeletedContentList' encode=false}{/link}',
+                                                       markAllAsReadConfirmMessage: '{lang}wcf.moderation.markAllAsRead.confirmMessage{/lang}',
+                                                       noItems: '{lang}wcf.moderation.noMoreItems{/lang}',
+                                                       title: '{lang}wcf.moderation.moderation{/lang}'
+                                               });
                                        });
                                        //]]>
                                </script>
index 3e44f23c702bd80d0760de2a03437fcf84c37e3b..5e6af1f6653247790f4e9433bcd008e184a6afb2 100644 (file)
@@ -181,7 +181,7 @@ WCF.Moderation.Management = Class.extend({
                                        $('<a href="' + data.returnValues.link + '" data-user-id="' + data.returnValues.userID + '" class="userLink">' + WCF.String.escapeHTML(data.returnValues.username) + '</a>').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();
+               
+               $('<li><a href="' + this._options.deletedContentLink + '" title="' + this._options.deletedContent + '" class="jsTooltip"><span class="icon icon16 fa-trash-o" /></a></li>').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);
-               $('<li><a href="' + this._showAllLink + '">' + WCF.Language.get('wcf.moderation.showAll') + '</a></li>').appendTo(dropdownMenu);
-               this._addDivider(dropdownMenu);
-               $('<li><a href="' + this._deletedContentLink + '">' + WCF.Language.get('wcf.moderation.showDeletedContent') + '</a></li>').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);
+               }
        }
 });
index ce62822e70f0e7e069297fe361fdb2a612dec9e2..a9f182f3618f018a5965584a444ba055e62dc610 100644 (file)
@@ -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
+               );
        }
        
        /**
index f9b75ddb530364cede03dee6be3e5c25c3b9cdf0..56b04078ee55e948f5250010850cb70353d07ca0 100644 (file)
@@ -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();
                        
index 6afbbb7086d1707ab37a39806aae91e70f55c495..a3df19c60486e870a65678fe7b11e2babc92cae3 100644 (file)
@@ -2323,6 +2323,7 @@ Fehler sind beispielsweise:
                <item name="wcf.moderation.outstandingItems"><![CDATA[Ausstehende Einträge]]></item>
                <item name="wcf.moderation.doneItems"><![CDATA[Erledigte Einträge]]></item>
                <item name="wcf.moderation.lastChangeTime"><![CDATA[Letzte Änderung]]></item>
+               <item name="wcf.moderation.markAllAsRead.confirmMessage"><![CDATA[Wollen Sie wirklich alle Einträge als gelesen markieren?]]></item>
                <item name="wcf.moderation.moderation"><![CDATA[Moderation]]></item>
                <item name="wcf.moderation.noMoreItems"><![CDATA[Keine weiteren Einträge]]></item>
                <item name="wcf.moderation.status"><![CDATA[Status]]></item>
index 1dbf74ccc0e22557b5dd1e3ca0e6c58487b2945f..a04bc639a890d7a995d5a158164de92049bce126 100644 (file)
@@ -2322,6 +2322,7 @@ Errors are:
                <item name="wcf.moderation.outstandingItems"><![CDATA[Pending Items]]></item>
                <item name="wcf.moderation.doneItems"><![CDATA[Done Items]]></item>
                <item name="wcf.moderation.lastChangeTime"><![CDATA[Last Change]]></item>
+               <item name="wcf.moderation.markAllAsRead.confirmMessage"><![CDATA[Do you really want to mark all entries as read?]]></item>
                <item name="wcf.moderation.moderation"><![CDATA[Moderation]]></item>
                <item name="wcf.moderation.noMoreItems"><![CDATA[No more items]]></item>
                <item name="wcf.moderation.status"><![CDATA[Status]]></item>