mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-28 15:43:03 +00:00
6a9528fd11
This was broken when replacing `$.extend` by `Object.assign` in
I1e603647c161bf940690f85f676edd7ebde7917d (commit 47ea647
).
`Object.assign` fails when the first argument is `undefined`, but
`$.extend` doesn't.
Bug: T368029
Change-Id: I13025a783c7f4d173dce096efa47f659273f0dd5
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
( function () {
|
|
/**
|
|
* A select widget for notification read state: 'all', 'read' or 'unread'
|
|
*
|
|
* @class
|
|
* @extends OO.ui.ButtonSelectWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration object
|
|
*/
|
|
mw.echo.ui.ReadStateButtonSelectWidget = function MwEchoUiReadStateButtonSelectWidget( config ) {
|
|
// Parent constructor
|
|
mw.echo.ui.ReadStateButtonSelectWidget.super.call( this, Object.assign( {}, config, {
|
|
items: [
|
|
new OO.ui.ButtonOptionWidget( {
|
|
data: 'all',
|
|
label: mw.msg( 'notification-inbox-filter-all' )
|
|
} ),
|
|
new OO.ui.ButtonOptionWidget( {
|
|
data: 'read',
|
|
label: mw.msg( 'notification-inbox-filter-read' )
|
|
} ),
|
|
new OO.ui.ButtonOptionWidget( {
|
|
data: 'unread',
|
|
label: mw.msg( 'notification-inbox-filter-unread' )
|
|
} )
|
|
]
|
|
} ) );
|
|
|
|
this.connect( this, { choose: 'onChoose' } );
|
|
|
|
this.$element
|
|
.addClass( 'mw-echo-ui-readStateButtonSelectWidget' );
|
|
};
|
|
|
|
/* Initialization */
|
|
|
|
OO.inheritClass( mw.echo.ui.ReadStateButtonSelectWidget, OO.ui.ButtonSelectWidget );
|
|
|
|
/* Events */
|
|
|
|
/**
|
|
* @event mw.echo.ui.ReadStateButtonSelectWidget#filter
|
|
* @param {string} readState The chosen read state
|
|
*/
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Respond to choose event
|
|
*
|
|
* @param {OO.ui.ButtonOptionWidget} item Chosen item
|
|
* @fires mw.echo.ui.ReadStateButtonSelectWidget#filter
|
|
*/
|
|
mw.echo.ui.ReadStateButtonSelectWidget.prototype.onChoose = function ( item ) {
|
|
const data = item && item.getData();
|
|
|
|
if ( data ) {
|
|
this.emit( 'filter', data );
|
|
}
|
|
};
|
|
}() );
|