X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fui%2Fmw.rcfilters.ui.FilterTagMultiselectWidget.js;h=268138fbda1f8895ec475815710a7a2a95c4df11;hb=f7e1770fb832aa77bf4e16ce8cc815f2b24dd10d;hp=c52ca1fc2277dac394509efc833b5a3c3c1ffac3;hpb=212f96ec2a4f06becb4a51efe411664bd0abf856;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js index c52ca1fc22..268138fbda 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js @@ -8,11 +8,14 @@ * @constructor * @param {mw.rcfilters.Controller} controller Controller * @param {mw.rcfilters.dm.FiltersViewModel} model View model + * @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model * @param {Object} config Configuration object * @cfg {jQuery} [$overlay] A jQuery object serving as overlay for popups */ - mw.rcfilters.ui.FilterTagMultiselectWidget = function MwRcfiltersUiFilterTagMultiselectWidget( controller, model, config ) { - var title = new OO.ui.LabelWidget( { + mw.rcfilters.ui.FilterTagMultiselectWidget = function MwRcfiltersUiFilterTagMultiselectWidget( controller, model, savedQueriesModel, config ) { + var rcFiltersRow, + areSavedQueriesEnabled = mw.config.get( 'wgStructuredChangeFiltersEnableSaving' ), + title = new OO.ui.LabelWidget( { label: mw.msg( 'rcfilters-activefilters' ), classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-wrapper-content-title' ] } ), @@ -23,7 +26,10 @@ this.controller = controller; this.model = model; + this.queriesModel = savedQueriesModel; this.$overlay = config.$overlay || this.$element; + this.matchingQuery = null; + this.areSavedQueriesEnabled = areSavedQueriesEnabled; // Parent mw.rcfilters.ui.FilterTagMultiselectWidget.parent.call( this, $.extend( true, { @@ -55,11 +61,30 @@ } }, config ) ); + this.savedQueryTitle = new OO.ui.LabelWidget( { + label: '', + classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-wrapper-content-savedQueryTitle' ] + } ); + this.resetButton = new OO.ui.ButtonWidget( { framed: false, classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-resetButton' ] } ); + if ( areSavedQueriesEnabled ) { + this.saveQueryButton = new mw.rcfilters.ui.SaveFiltersPopupButtonWidget( + this.controller, + this.queriesModel + ); + + this.saveQueryButton.$element.on( 'mousedown', function ( e ) { e.stopPropagation(); } ); + + this.saveQueryButton.connect( this, { + click: 'onSaveQueryButtonClick', + saveCurrent: 'setSavedQueryVisibility' + } ); + } + this.emptyFilterMessage = new OO.ui.LabelWidget( { label: mw.msg( 'rcfilters-empty-filter' ), classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-emptyFilters' ] @@ -73,42 +98,60 @@ this.resetButton.$element.on( 'mousedown', function ( e ) { e.stopPropagation(); } ); this.model.connect( this, { initialize: 'onModelInitialize', + update: 'onModelUpdate', itemUpdate: 'onModelItemUpdate', highlightChange: 'onModelHighlightChange' } ); + this.input.connect( this, { change: 'onInputChange' } ); + this.queriesModel.connect( this, { itemUpdate: 'onSavedQueriesItemUpdate' } ); + + // The filter list and button should appear side by side regardless of how + // wide the button is; the button also changes its width depending + // on language and its state, so the safest way to present both side + // by side is with a table layout + rcFiltersRow = $( '