Mooeypoo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/310171

Change subject: Allow for count cap display in Special:Notifications sidebar
......................................................................

Allow for count cap display in Special:Notifications sidebar

Some of the counts are capped (wiki counts) and some are not (page
counts) - so we are adding a config option ('isCapped') to the
widget to make sure that capped numbers appear with the proper
i18n message ('99+' in English) and non-capped numbers appear
as-is.

Bug: T144707
Change-Id: I7332e7f5108621d0bd403edefe4feacca44b1f88
---
M modules/ui/mw.echo.ui.PageFilterWidget.js
M modules/ui/mw.echo.ui.PageNotificationsOptionWidget.js
2 files changed, 15 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/71/310171/1

diff --git a/modules/ui/mw.echo.ui.PageFilterWidget.js 
b/modules/ui/mw.echo.ui.PageFilterWidget.js
index b7eff73..f3dcd90 100644
--- a/modules/ui/mw.echo.ui.PageFilterWidget.js
+++ b/modules/ui/mw.echo.ui.PageFilterWidget.js
@@ -34,7 +34,8 @@
                this.title = new mw.echo.ui.PageNotificationsOptionWidget( {
                        label: config.title,
                        title: config.title,
-                       unreadCount: this.totalCount,
+                       count: this.totalCount,
+                       isCapped: true,
                        data: null,
                        classes: [ 'mw-echo-ui-pageFilterWidget-title' ]
                } );
@@ -48,16 +49,6 @@
        /* Initialization */
 
        OO.inheritClass( mw.echo.ui.PageFilterWidget, OO.ui.SelectWidget );
-
-       /**
-        * Set the total count of this group
-        *
-        * @param {number} count Total count
-        */
-       mw.echo.ui.PageFilterWidget.prototype.setTotalCount = function ( count 
) {
-               this.totalCount = count;
-               this.title.setCount( this.totalCount );
-       };
 
        /**
         * Set the total count of this group
@@ -82,7 +73,7 @@
                                label: isUserPage ? sourcePages[ title 
].unprefixed : title,
                                title: isUserPage ? sourcePages[ title 
].unprefixed : title,
                                icon: isUserPage ? 'userAvatar' : 'article',
-                               unreadCount: sourcePages[ title ].count,
+                               count: sourcePages[ title ].count,
                                data: title,
                                classes: [ 'mw-echo-ui-pageFilterWidget-page' ]
                        } );
diff --git a/modules/ui/mw.echo.ui.PageNotificationsOptionWidget.js 
b/modules/ui/mw.echo.ui.PageNotificationsOptionWidget.js
index 3cc4967..60fc61e 100644
--- a/modules/ui/mw.echo.ui.PageNotificationsOptionWidget.js
+++ b/modules/ui/mw.echo.ui.PageNotificationsOptionWidget.js
@@ -9,9 +9,12 @@
         *
         * @constructor
         * @param {Object} [config] Configuration object
-        * @cfg {number} [unreadCount] Number of unread notifications
+        * @cfg {number} [count] Number of unread notifications
+        * @cfg {boolean} [isCapped] The count for this widget is capped
         */
        mw.echo.ui.PageNotificationsOptionWidget = function 
MwEchoUiPageNotificationsOptionWidget( config ) {
+               var countLabel;
+
                config = config || {};
 
                // Parent
@@ -23,10 +26,16 @@
                this.$label
                        .addClass( 
'mw-echo-ui-pageNotificationsOptionWidget-title-label' );
 
+               this.count = config.count !== undefined ? config.count : 0;
+
+               countLabel = mw.language.convertNumber( this.count );
+               countLabel = config.isCapped ?
+                       mw.msg( 'echo-badge-count', countLabel ) : countLabel;
+
                this.unreadCountLabel = new OO.ui.LabelWidget( {
-                       classes: [ 
'mw-echo-ui-pageNotificationsOptionWidget-label-count' ]
+                       classes: [ 
'mw-echo-ui-pageNotificationsOptionWidget-label-count' ],
+                       label: countLabel
                } );
-               this.setCount( config.unreadCount || 0 );
 
                // Initialization
                this.$element
@@ -54,16 +63,6 @@
        OO.inheritClass( mw.echo.ui.PageNotificationsOptionWidget, 
OO.ui.OptionWidget );
        OO.mixinClass( mw.echo.ui.PageNotificationsOptionWidget, 
OO.ui.mixin.IconElement );
        OO.mixinClass( mw.echo.ui.PageNotificationsOptionWidget, 
OO.ui.mixin.TitledElement );
-
-       /**
-        * Set the page count
-        *
-        * @param {number} count Page count
-        */
-       mw.echo.ui.PageNotificationsOptionWidget.prototype.setCount = function 
( count ) {
-               this.count = count;
-               this.unreadCountLabel.setLabel( mw.language.convertNumber( 
this.count ) );
-       };
 
        /**
         * Get the page count

-- 
To view, visit https://gerrit.wikimedia.org/r/310171
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7332e7f5108621d0bd403edefe4feacca44b1f88
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to