3 * List displaying all filter groups
5 * @extends OO.ui.Widget
6 * @mixins OO.ui.mixin.PendingElement
9 * @param {mw.rcfilters.Controller} controller Controller
10 * @param {mw.rcfilters.dm.FiltersViewModel} model View model
11 * @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model
12 * @param {Object} [config] Configuration object
13 * @cfg {Object} [filters] A definition of the filter groups in this list
14 * @cfg {jQuery} [$overlay] A jQuery object serving as overlay for popups
16 mw
.rcfilters
.ui
.FilterWrapperWidget
= function MwRcfiltersUiFilterWrapperWidget( controller
, model
, savedQueriesModel
, config
) {
17 config
= config
|| {};
20 mw
.rcfilters
.ui
.FilterWrapperWidget
.parent
.call( this, config
);
22 OO
.ui
.mixin
.PendingElement
.call( this, config
);
24 this.controller
= controller
;
26 this.queriesModel
= savedQueriesModel
;
27 this.$overlay
= config
.$overlay
|| this.$element
;
29 this.filterTagWidget
= new mw
.rcfilters
.ui
.FilterTagMultiselectWidget(
33 { $overlay
: this.$overlay
}
36 this.namespaceButton
= new OO
.ui
.ButtonWidget( {
37 label
: mw
.msg( 'namespaces' ),
39 classes
: [ 'mw-rcfilters-ui-filterWrapperWidget-namespaceToggle' ]
41 this.namespaceButton
.setActive( this.model
.getCurrentView() === 'namespaces' );
44 this.model
.connect( this, { update
: 'onModelUpdate' } );
45 this.namespaceButton
.connect( this, { click
: 'onNamespaceToggleClick' } );
49 .addClass( 'mw-rcfilters-ui-filterWrapperWidget' );
51 if ( mw
.config
.get( 'wgStructuredChangeFiltersEnableSaving' ) ) {
52 this.savedLinksListWidget
= new mw
.rcfilters
.ui
.SavedLinksListWidget(
55 { $overlay
: this.$overlay
}
59 this.savedLinksListWidget
.$element
65 this.filterTagWidget
.$element
,
66 this.namespaceButton
.$element
68 this.namespaceButton
.toggle( !!mw
.config
.get( 'wgStructuredChangeFiltersEnableExperimentalViews' ) );
73 OO
.inheritClass( mw
.rcfilters
.ui
.FilterWrapperWidget
, OO
.ui
.Widget
);
74 OO
.mixinClass( mw
.rcfilters
.ui
.FilterWrapperWidget
, OO
.ui
.mixin
.PendingElement
);
79 * Respond to model update event
81 mw
.rcfilters
.ui
.FilterWrapperWidget
.prototype.onModelUpdate = function () {
82 // Synchronize the state of the toggle button with the current view
83 this.namespaceButton
.setActive( this.model
.getCurrentView() === 'namespaces' );
87 * Respond to namespace toggle button click
89 mw
.rcfilters
.ui
.FilterWrapperWidget
.prototype.onNamespaceToggleClick = function () {
90 this.controller
.switchView( 'namespaces' );
91 this.filterTagWidget
.focus();