[MediaWiki-commits] [Gerrit] Allow notification model and widget to show combined notific... - change (mediawiki...Echo)

2015-11-06 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Allow notification model and widget to show combined 
notifications
..


Allow notification model and widget to show combined notifications

Make sure it's possible to create a combined notification widget
that features both alerts and messages.

Change-Id: I4b3f263039f54430a61acc1a261d8aca8e894a90
---
M modules/viewmodel/mw.echo.dm.APIHandler.js
M modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js
M modules/viewmodel/mw.echo.dm.NotificationsModel.js
3 files changed, 62 insertions(+), 35 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/viewmodel/mw.echo.dm.APIHandler.js 
b/modules/viewmodel/mw.echo.dm.APIHandler.js
index f7f9380..7818daa 100644
--- a/modules/viewmodel/mw.echo.dm.APIHandler.js
+++ b/modules/viewmodel/mw.echo.dm.APIHandler.js
@@ -46,10 +46,14 @@
/**
 * @inheritdoc
 */
-   mw.echo.dm.APIHandler.prototype.updateSeenTime = function () {
+   mw.echo.dm.APIHandler.prototype.updateSeenTime = function ( type ) {
+   type = type || this.type;
+
return this.api.postWithToken( 'edit', {
action: 'echomarkseen',
-   type: this.type
+   // TODO: The API should also work with piped types like
+   // getting notification lists
+   type: $.isArray( type ) ? 'all' : type
} )
.then( function ( data ) {
return data.query.echomarkseen.timestamp;
diff --git a/modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js 
b/modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js
index 2c0204b..1ce0a38 100644
--- a/modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js
+++ b/modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js
@@ -51,6 +51,8 @@
/**
 * Update the seen timestamp
 *
+* @param {string|string[]} [type] Notification type 'message', 'alert' 
or
+*  an array of both.
 * @return {jQuery.Promise} A promise that resolves with the seen 
timestamp
 */
mw.echo.dm.AbstractAPIHandler.prototype.updateSeenTime = null;
diff --git a/modules/viewmodel/mw.echo.dm.NotificationsModel.js 
b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
index 2e57476..28f70ea 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationsModel.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
@@ -8,7 +8,8 @@
 * @constructor
 * @param {mw.echo.dm.AbstractAPIHandler} apiHandler API handler
 * @param {Object} [config] Configuration object
-* @cfg {string} [type='alert'] Notification type 'alert', 'message' or 
'all'
+* @cfg {string|string[]} [type='alert'] Notification type 'alert', 
'message'
+*  or an array [ 'alert', 'message' ]
 * @cfg {number} [limit=25] Notification limit
 * @cfg {string} [userLang] User language
 */
@@ -150,9 +151,9 @@
 
/**
 * Get the type of the notifications that this model deals with.
-* Notifications type are given from the API: 'alert', 'message', 'all'
+* Notifications types can be 'alert', 'message' or an array of both.
 *
-* @return {string} Notifications type
+* @return {string|string[]} Notifications type
 */
mw.echo.dm.NotificationsModel.prototype.getType = function () {
return this.type;
@@ -183,27 +184,39 @@
 * @param {string} Mediawiki seen timestamp in Mediawiki timestamp 
format
 */
mw.echo.dm.NotificationsModel.prototype.setSeenTime = function ( time ) 
{
-   this.seenTime[ this.type ] = time;
+   var i,
+   type = $.isArray( this.type ) ? this.type : [ this.type 
];
+
+   for ( i = 0; i < type.length; i++ ) {
+   // Update all types
+   this.seenTime[ type[ i ] ] = time;
+   }
};
 
/**
 * Get the system seen time
 *
+* @param {string} [type] Notification type
 * @return {string} Mediawiki seen timestamp in Mediawiki timestamp 
format
 */
-   mw.echo.dm.NotificationsModel.prototype.getSeenTime = function () {
-   return this.seenTime[ this.type ];
+   mw.echo.dm.NotificationsModel.prototype.getSeenTime = function ( type ) 
{
+   type = type || ( $.isArray( this.type ) ? this.type[ 0 ] : 
this.type );
+
+   return this.seenTime[ type ];
};
 
/**
 * Update the seen timestamp
 *
+* @param {string|string[]} [type] Notification type
 * @return {jQuery.Promise} A promise that resolves with the seen 
timestamp
 * @fires updateSeenTime
 */
-   

[MediaWiki-commits] [Gerrit] Allow notification model and widget to show combined notific... - change (mediawiki...Echo)

2015-10-26 Thread Mooeypoo (Code Review)
Mooeypoo has uploaded a new change for review.

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

Change subject: Allow notification model and widget to show combined 
notifications
..

Allow notification model and widget to show combined notifications

Make sure it's possible to create a combined notification widget
that features both alerts and messages.

Change-Id: I4b3f263039f54430a61acc1a261d8aca8e894a90
---
M modules/viewmodel/mw.echo.dm.APIHandler.js
M modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js
M modules/viewmodel/mw.echo.dm.NotificationsModel.js
3 files changed, 74 insertions(+), 38 deletions(-)


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

diff --git a/modules/viewmodel/mw.echo.dm.APIHandler.js 
b/modules/viewmodel/mw.echo.dm.APIHandler.js
index 66abc6b..147fcd2 100644
--- a/modules/viewmodel/mw.echo.dm.APIHandler.js
+++ b/modules/viewmodel/mw.echo.dm.APIHandler.js
@@ -46,10 +46,14 @@
/**
 * @inheritdoc
 */
-   mw.echo.dm.APIHandler.prototype.updateSeenTime = function () {
+   mw.echo.dm.APIHandler.prototype.updateSeenTime = function ( type ) {
+   type = type || this.type;
+
return this.api.postWithToken( 'edit', {
action: 'echomarkseen',
-   type: this.type
+   // TODO: The API should also work with piped types like
+   // getting notification lists
+   type: $.isArray( type ) ? 'all' : type
} )
.then( function ( data ) {
return data.query.echomarkseen.timestamp;
diff --git a/modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js 
b/modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js
index 5ab45c0..bd9c6bd 100644
--- a/modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js
+++ b/modules/viewmodel/mw.echo.dm.AbstractAPIHandler.js
@@ -48,6 +48,7 @@
/**
 * Update the seen timestamp
 *
+* @param {string} [type] Notification type
 * @return {jQuery.Promise} A promise that resolves with the seen 
timestamp
 */
mw.echo.dm.AbstractAPIHandler.prototype.updateSeenTime = null;
diff --git a/modules/viewmodel/mw.echo.dm.NotificationsModel.js 
b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
index 47bff42..c165194 100644
--- a/modules/viewmodel/mw.echo.dm.NotificationsModel.js
+++ b/modules/viewmodel/mw.echo.dm.NotificationsModel.js
@@ -8,7 +8,8 @@
 * @constructor
 * @param {mw.echo.dm.AbstractAPIHandler} apiHandler API handler
 * @param {Object} [config] Configuration object
-* @cfg {string} [type='alert'] Notification type 'alert', 'message' or 
'all'
+* @cfg {string|string[]} [type='alert'] Notification type 'alert', 
'message'
+*  or an array [ 'alert', 'message' ]
 * @cfg {number} [limit=25] Notification limit
 * @cfg {string} [userLang] User language
 */
@@ -150,9 +151,9 @@
 
/**
 * Get the type of the notifications that this model deals with.
-* Notifications type are given from the API: 'alert', 'message', 'all'
+* Notifications types can be 'alert', 'message' or an array of both.
 *
-* @return {string} Notifications type
+* @return {string|string[]} Notifications type
 */
mw.echo.dm.NotificationsModel.prototype.getType = function () {
return this.type;
@@ -183,27 +184,41 @@
 * @param {string} Mediawiki seen timestamp in Mediawiki timestamp 
format
 */
mw.echo.dm.NotificationsModel.prototype.setSeenTime = function ( time ) 
{
+   var i;
+
+   if ( $.isArray( this.type ) ) {
+   for ( i = 0; i < this.type.length; i++ ) {
+   // Update all types
+   this.seenTime[ this.type[ i ] ] = time;
+   }
+   }
this.seenTime[ this.type ] = time;
};
 
/**
 * Get the system seen time
 *
+* @param {string} [type] Notification type
 * @return {string} Mediawiki seen timestamp in Mediawiki timestamp 
format
 */
-   mw.echo.dm.NotificationsModel.prototype.getSeenTime = function () {
-   return this.seenTime[ this.type ];
+   mw.echo.dm.NotificationsModel.prototype.getSeenTime = function ( type ) 
{
+   type = type || $.isArray( this.type ) ? this.type[ 0 ] : 
this.type;
+
+   return this.seenTime[ type ];
};
 
/**
 * Update the seen timestamp
 *
+* @param {string} [type] Notification type
 * @return {jQuery.Promise} A promise that resolves with the seen 
timestamp
 * @fires updateSeenTime
 */
-