Merge "Show a warning in edit preview when a template loop is detected"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.FilterTagMultiselectWidget.js
index 89c6f27..b15b034 100644 (file)
@@ -15,7 +15,6 @@
         */
        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' ]
@@ -30,7 +29,7 @@
                this.queriesModel = savedQueriesModel;
                this.$overlay = config.$overlay || this.$element;
                this.matchingQuery = null;
-               this.areSavedQueriesEnabled = areSavedQueriesEnabled;
+               this.currentView = this.model.getCurrentView();
 
                // Parent
                mw.rcfilters.ui.FilterTagMultiselectWidget.parent.call( this, $.extend( true, {
@@ -86,7 +85,7 @@
                        classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-resetButton' ]
                } );
 
-               if ( areSavedQueriesEnabled ) {
+               if ( !mw.user.isAnon() ) {
                        this.saveQueryButton = new mw.rcfilters.ui.SaveFiltersPopupButtonWidget(
                                this.controller,
                                this.queriesModel
@@ -98,6 +97,7 @@
                                click: 'onSaveQueryButtonClick',
                                saveCurrent: 'setSavedQueryVisibility'
                        } );
+                       this.queriesModel.connect( this, { itemUpdate: 'onSavedQueriesItemUpdate' } );
                }
 
                this.emptyFilterMessage = new OO.ui.LabelWidget( {
                        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
                                        .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-filters' )
                        );
 
-               if ( areSavedQueriesEnabled ) {
+               if ( !mw.user.isAnon() ) {
                        rcFiltersRow.append(
                                $( '<div>' )
                                        .addClass( 'mw-rcfilters-ui-cell' )
                this.viewsSelectWidget = new OO.ui.ButtonSelectWidget( {
                        classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-views-select-widget' ],
                        items: [
+                               new OO.ui.ButtonOptionWidget( {
+                                       framed: false,
+                                       data: '',
+                                       disabled: true,
+                                       classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-views-select-widget-label' ],
+                                       label: mw.msg( 'rcfilters-view-advanced-filters-label' )
+                               } ),
                                new OO.ui.ButtonOptionWidget( {
                                        framed: false,
                                        data: 'namespaces',
 
                // Update input
                this.input.setValue( inputValue );
+
+               if ( this.currentView !== view ) {
+                       this.scrollToTop( this.$element );
+                       this.currentView = view;
+               }
        };
 
        /**
         * Set the visibility of the saved query button
         */
        mw.rcfilters.ui.FilterTagMultiselectWidget.prototype.setSavedQueryVisibility = function () {
-               if ( this.areSavedQueriesEnabled ) {
-                       this.matchingQuery = this.controller.findQueryMatchingCurrentState();
+               if ( mw.user.isAnon() ) {
+                       return;
+               }
 
-                       this.savedQueryTitle.setLabel(
-                               this.matchingQuery ? this.matchingQuery.getLabel() : ''
-                       );
-                       this.savedQueryTitle.toggle( !!this.matchingQuery );
-                       this.saveQueryButton.toggle(
-                               !this.isEmpty() &&
-                               !this.matchingQuery
-                       );
+               this.matchingQuery = this.controller.findQueryMatchingCurrentState();
 
-                       if ( this.matchingQuery ) {
-                               this.emphasize();
-                       }
+               this.savedQueryTitle.setLabel(
+                       this.matchingQuery ? this.matchingQuery.getLabel() : ''
+               );
+               this.savedQueryTitle.toggle( !!this.matchingQuery );
+               this.saveQueryButton.toggle(
+                       !this.isEmpty() &&
+                       !this.matchingQuery
+               );
+
+               if ( this.matchingQuery ) {
+                       this.emphasize();
                }
        };