RCFilters: Ignore sticky filters when emptying all filters
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / dm / mw.rcfilters.dm.FiltersViewModel.js
index a6a22ef..a8ee06b 100644 (file)
                return result;
        };
 
+       /**
+        * Get a filter representation of all parameters that are marked
+        * as being excluded from saved query.
+        *
+        * @return {Object} Excluded filters values
+        */
+       mw.rcfilters.dm.FiltersViewModel.prototype.getExcludedFiltersState = function () {
+               var result = {};
+
+               $.each( this.groups, function ( name, model ) {
+                       if ( model.isExcludedFromSavedQueries() ) {
+                               $.extend( true, result, model.getSelectedState() );
+                       }
+               } );
+
+               return result;
+       };
+
        /**
         * Analyze the groups and their filters and output an object representing
         * the state of the parameters they represent.
         */
        mw.rcfilters.dm.FiltersViewModel.prototype.emptyAllFilters = function () {
                this.getItems().forEach( function ( filterItem ) {
-                       this.toggleFilterSelected( filterItem.getName(), false );
+                       if ( !filterItem.getGroupModel().isSticky() ) {
+                               this.toggleFilterSelected( filterItem.getName(), false );
+                       }
                }.bind( this ) );
        };
 
                if ( view !== 'default' ) {
                        query = query.substr( 1 );
                }
+               // Trim again to also intercept cases where the spaces were after the trigger
+               // eg: '#   str'
+               query = query.trim();
 
                // Check if the search if actually empty; this can be a problem when
                // we use prefixes to denote different views