X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fdm%2Fmw.rcfilters.dm.FiltersViewModel.js;h=a8ee06bf49e7dcc448290e19c8af45e7ca0ed938;hp=a602c32d2beab7ad45c89e826c621b63759a9a48;hb=0a6240c4122dc8bd7f0543f817bf7939cb179f4b;hpb=5ff347bb044057d3cc560e860c85af26163bc979 diff --git a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js index a602c32d2b..a8ee06bf49 100644 --- a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js +++ b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js @@ -324,17 +324,12 @@ } ); // Collect views - allViews = { + allViews = $.extend( true, { 'default': { title: mw.msg( 'rcfilters-filterlist-title' ), groups: filterGroups } - }; - - if ( views && mw.config.get( 'wgStructuredChangeFiltersEnableExperimentalViews' ) ) { - // If we have extended views, add them in - $.extend( true, allViews, views ); - } + }, views ); // Go over all views $.each( allViews, function ( viewName, viewData ) { @@ -551,6 +546,58 @@ return result; }; + /** + * Get a parameter representation of all sticky parameters + * + * @return {Object} Sticky parameter values + */ + mw.rcfilters.dm.FiltersViewModel.prototype.getStickyParams = function () { + var result = {}; + + $.each( this.groups, function ( name, model ) { + if ( model.isSticky() ) { + $.extend( true, result, model.getDefaultParams() ); + } + } ); + + return result; + }; + + /** + * Get a filter representation of all sticky parameters + * + * @return {Object} Sticky filters values + */ + mw.rcfilters.dm.FiltersViewModel.prototype.getStickyFiltersState = function () { + var result = {}; + + $.each( this.groups, function ( name, model ) { + if ( model.isSticky() ) { + $.extend( true, result, model.getSelectedState() ); + } + } ); + + 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. @@ -639,7 +686,7 @@ /** * Get the highlight parameters based on current filter configuration * - * @return {Object} Object where keys are "_color" and values + * @return {Object} Object where keys are `_color` and values * are the selected highlight colors. */ mw.rcfilters.dm.FiltersViewModel.prototype.getHighlightParameters = function () { @@ -661,7 +708,7 @@ * * @param {Object} representation Object containing representation of * some or all highlight values - * @return {Object} Object where keys are "_color" and values + * @return {Object} Object where keys are `_color` and values * are the selected highlight colors. The returned object * contains all available filters either with a color value * or with null. @@ -746,7 +793,9 @@ */ 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 ) ); }; @@ -815,10 +864,13 @@ items = this.getFiltersByView( view ); // Normalize so we can search strings regardless of case and view - query = query.toLowerCase(); + query = query.trim().toLowerCase(); 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