Debian Codegraph @

resources/src/mediawiki.rcfilters/ui/MarkSeenButtonWidget.js

raw symbols SCIP
1 /**
2 * Button for marking all changes as seen on the Watchlist.
3 *
4 * @class mw.rcfilters.ui.MarkSeenButtonWidget
5 * @ignore
6 * @extends OO.ui.ButtonWidget
7 *
8 * @param {mw.rcfilters.Controller} controller
9 * @param {mw.rcfilters.dm.ChangesListViewModel} model Changes list view model
10 * @param {Object} [config] Configuration object
11 */
12 const MarkSeenButtonWidget = function MwRcfiltersUiMarkSeenButtonWidget( controller, model, config ) {
13 config = config || {};
14
15 // Parent
16 MarkSeenButtonWidget.super.call( this, Object.assign( {
17 label: mw.msg( 'rcfilters-watchlist-markseen-button' ),
18 icon: 'checkAll'
19 }, config ) );
20
21 this.controller = controller;
22 this.model = model;
23
24 // Events
25 this.connect( this, { click: 'onClick' } );
26 this.model.connect( this, { update: 'onModelUpdate' } );
27
28 this.$element.addClass( 'mw-rcfilters-ui-markSeenButtonWidget' );
29
30 this.onModelUpdate();
31 };
32
33 /* Initialization */
34
35 OO.inheritClass( MarkSeenButtonWidget, OO.ui.ButtonWidget );
36
37 /* Methods */
38
39 /**
40 * Respond to the button being clicked
41 */
42 MarkSeenButtonWidget.prototype.onClick = function () {
43 this.controller.markAllChangesAsSeen();
44 // assume there's no more unseen changes until the next model update
45 this.setDisabled( true );
46 };
47
48 /**
49 * Respond to the model being updated with new changes
50 */
51 MarkSeenButtonWidget.prototype.onModelUpdate = function () {
52 this.setDisabled( !this.model.hasUnseenWatchedChanges() );
53 };
54
55 module.exports = MarkSeenButtonWidget;