Status icons for the ACP user list
authorAlexander Ebert <ebert@woltlab.com>
Sun, 6 Jan 2019 14:33:51 +0000 (15:33 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 6 Jan 2019 14:33:51 +0000 (15:33 +0100)
See #2693

wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/acp/templates/userList.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Editor.js
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index cc35dd1fd1df7f99822214b1ed4dc77699043dce..93c80b6bda2c94a00f8c5b63f8095e353fb94617 100644 (file)
@@ -1941,6 +1941,13 @@ WCF.ACP.User.BanHandler = {
         * @param       jQuery          jqXHR
         */
        _success: function(data, textStatus, jqXHR) {
+               elBySelAll('.jsUserRow', undefined, function(userRow) {
+                       var userId = parseInt(elData(userRow, 'object-id'), 10);
+                       if (data.objectIDs.indexOf(userId) !== -1) {
+                               elData(userRow, 'banned', data.actionName === 'ban');
+                       }
+               });
+               
                $('.jsBanButton').each(function(index, button) {
                        var $button = $(button);
                        if (WCF.inArray($button.data('objectID'), data.objectIDs)) {
@@ -1961,6 +1968,8 @@ WCF.ACP.User.BanHandler = {
                if (data.actionName == 'ban') {
                        this._dialog.wcfDialog('close');
                }
+               
+               WCF.System.Event.fireEvent('com.woltlab.wcf.acp.user', 'refresh', {userIds: data.objectIDs});
        }
 };
 
@@ -2102,6 +2111,13 @@ WCF.ACP.User.EnableHandler = {
         * @param       jQuery          jqXHR
         */
        _success: function(data, textStatus, jqXHR) {
+               elBySelAll('.jsUserRow', undefined, function(userRow) {
+                       var userId = parseInt(elData(userRow, 'object-id'), 10);
+                       if (data.objectIDs.indexOf(userId) !== -1) {
+                               elData(userRow, 'enabled', data.actionName === 'enable');
+                       }
+               });
+               
                $('.jsEnableButton').each(function(index, button) {
                        var $button = $(button);
                        if (WCF.inArray($button.data('objectID'), data.objectIDs)) {
@@ -2116,6 +2132,8 @@ WCF.ACP.User.EnableHandler = {
                
                var $notification = new WCF.System.Notification();
                $notification.show(function() { window.location.reload(); });
+               
+               WCF.System.Event.fireEvent('com.woltlab.wcf.acp.user', 'refresh', {userIds: data.objectIDs});
        }
 };
 
index 9ed63fc807235dd97367da4f84a97e84af292061..7bf351cdac80405e03f079c4a043b62c225b53f9 100644 (file)
@@ -31,7 +31,9 @@
                        'wcf.acp.user.ban.neverExpires': '{lang}wcf.acp.user.ban.neverExpires{/lang}',
                        'wcf.acp.user.sendNewPassword.workerTitle': '{lang}wcf.acp.user.sendNewPassword.workerTitle{/lang}',
                        'wcf.acp.worker.abort.confirmMessage': '{lang}wcf.acp.worker.abort.confirmMessage{/lang}',
-                       'wcf.acp.content.removeContent': '{lang}wcf.acp.content.removeContent{/lang}'
+                       'wcf.acp.content.removeContent': '{lang}wcf.acp.content.removeContent{/lang}',
+                       'wcf.user.status.banned': '{lang}wcf.user.status.banned{/lang}',
+                       'wcf.user.status.isDisabled': '{lang}wcf.user.status.isDisabled{/lang}'
                });
                WCF.ACP.User.BanHandler.init();
                
                                                <td class="columnID columnUserID">{@$user->userID}</td>
                                                <td class="columnIcon">{@$user->getAvatar()->getImageTag(24)}</td>
                                                <td class="columnTitle columnUsername">
-                                                       {if $user->editable}
-                                                               <a title="{lang}wcf.acp.user.edit{/lang}" href="{link controller='UserEdit' id=$user->userID}{/link}">{$user->username}</a>
-                                                       {else}
-                                                               {$user->username}
-                                                       {/if}
+                                                       <span class="username">
+                                                               {if $user->editable}
+                                                                       <a title="{lang}wcf.acp.user.edit{/lang}" href="{link controller='UserEdit' id=$user->userID}{/link}">{$user->username}</a>
+                                                               {else}
+                                                                       {$user->username}
+                                                               {/if}
+                                                       </span>
+                                                       
+                                                       <span class="userStatusIcons">
+                                                               {if $user->banned}<span class="icon icon16 fa-lock jsTooltip jsUserStatusBanned" title="{lang}wcf.user.status.banned{/lang}"></span>{/if}
+                                                               {if $user->activationCode != 0}<span class="icon icon16 fa-power-off jsTooltip jsUserStatusIsDisabled" title="{lang}wcf.user.status.isDisabled{/lang}"></span>{/if}
+                                                       </span>
+                                                       
                                                        {if MODULE_USER_RANK}
                                                                {if $user->getUserTitle()} <span class="badge userTitleBadge{if $user->getRank() && $user->getRank()->cssClassName} {@$user->getRank()->cssClassName}{/if}">{$user->getUserTitle()}</span>{/if}
                                                                {if $user->getRank() && $user->getRank()->rankImage} <span class="userRankImage">{@$user->getRank()->getImage()}</span>{/if}
index 9f5e0ea09334aac7a8d302a804af7878626887d2..24bbef91afdd42a1a65bca3351ec58e0d86eb149 100644 (file)
@@ -19,6 +19,8 @@ define(['Ajax', 'Core', 'EventHandler', 'Language', 'Ui/SimpleDropdown', 'WoltLa
                 */
                init: function () {
                        elBySelAll('.jsUserRow', undefined, this._initUser.bind(this));
+                       
+                       EventHandler.add('com.woltlab.wcf.acp.user', 'refresh', this._refreshUsers.bind(this));
                },
                
                /**
@@ -144,6 +146,39 @@ define(['Ajax', 'Core', 'EventHandler', 'Language', 'Ui/SimpleDropdown', 'WoltLa
                                        hasItem = true;
                                }
                        }
+               },
+               
+               _refreshUsers: function (data) {
+                       elBySelAll('.jsUserRow', undefined, function(userRow) {
+                               var userId = parseInt(elData(userRow, 'object-id'));
+                               if (data.userIds.indexOf(userId) !== -1) {
+                                       var userStatusIcons = elBySel('.userStatusIcons', userRow);
+                                       
+                                       var banned = elDataBool(userRow, 'banned');
+                                       var iconBanned = elBySel('.jsUserStatusBanned', userRow);
+                                       if (banned && iconBanned === null) {
+                                               iconBanned = elCreate('span');
+                                               iconBanned.className = 'icon icon16 fa-lock jsUserStatusBanned jsTooltip';
+                                               iconBanned.title = Language.get('wcf.user.status.banned');
+                                               userStatusIcons.insertBefore(iconBanned, null);
+                                       }
+                                       else if (!banned && iconBanned !== null) {
+                                               elRemove(iconBanned);
+                                       }
+                                       
+                                       var isDisabled = elDataBool(userRow, 'enabled') === false;
+                                       var iconIsDisabled = elBySel('.jsUserStatusIsDisabled', userRow);
+                                       if (isDisabled && iconIsDisabled === null) {
+                                               iconIsDisabled = elCreate('span');
+                                               iconIsDisabled.className = 'icon icon16 fa-power-off jsUserStatusIsDisabled jsTooltip';
+                                               iconIsDisabled.title = Language.get('wcf.user.status.isDisabled');
+                                               userStatusIcons.appendChild(iconIsDisabled);
+                                       }
+                                       else if (!isDisabled && iconIsDisabled !== null) {
+                                               elRemove(iconIsDisabled);
+                                       }
+                               }
+                       })
                }
        };
 });
index 5b497ab9fa6e648d5d3eb098359fe71ad81629f8..00a2655850dc74df2670a3e312cd9a19a1187488 100644 (file)
@@ -4456,6 +4456,8 @@ sich{/if} nicht bei uns registriert {if LANGUAGE_USE_INFORMAL_VARIANT}hast{else}
                <item name="wcf.user.sortField.lastActivityTime"><![CDATA[Letzte Aktivität]]></item>
                <item name="wcf.user.sortField.reactionReputation"><![CDATA[Reputation aus Reaktionen]]></item>
                <item name="wcf.user.articles"><![CDATA[Artikel]]></item>
+               <item name="wcf.user.status.banned"><![CDATA[Der Benutzer ist gesperrt.]]></item>
+               <item name="wcf.user.status.isDisabled"><![CDATA[Der Benutzer ist nicht freigeschaltet.]]></item>
        </category>
        <category name="wcf.user.menu">
                <item name="wcf.user.menu.community"><![CDATA[Community]]></item>
index 6b4d6938e90099ee1b2d4158531d0f51030b51f8..cd8096444f2687e1ccba3f66f929ac358bc59873 100644 (file)
@@ -4453,6 +4453,8 @@ not register with us.]]></item>
                <item name="wcf.user.sortField.lastActivityTime"><![CDATA[Last Activity]]></item>
                <item name="wcf.user.sortField.reactionReputation"><![CDATA[Reputation from Reactions]]></item>
                <item name="wcf.user.articles"><![CDATA[Articles]]></item>
+               <item name="wcf.user.status.banned"><![CDATA[The user has been banned.]]></item>
+               <item name="wcf.user.status.isDisabled"><![CDATA[The user has not been approved yet.]]></item>
        </category>
        <category name="wcf.user.menu">
                <item name="wcf.user.menu.community"><![CDATA[Community]]></item>