* is a part of.
* @cfg {boolean} [isSticky] This group is using a 'sticky' default; meaning
* that every time a value is changed, it becomes the new default
+ * @cfg {boolean} [excludedFromSavedQueries] A specific requirement to exclude
+ * this filter from saved queries. This is always true if the filter is 'sticky'
+ * but can be used for non-sticky filters as an additional requirement. Similarly
+ * to 'sticky' it works for the entire group as a whole.
* @cfg {string} [title] Group title
* @cfg {boolean} [hidden] This group is hidden from the regular menu views
* @cfg {boolean} [allowArbitrary] Allows for an arbitrary value to be added to the
this.type = config.type || 'send_unselected_if_any';
this.view = config.view || 'default';
this.sticky = !!config.isSticky;
+ this.excludedFromSavedQueries = this.sticky || !!config.excludedFromSavedQueries;
this.title = config.title || name;
this.hidden = !!config.hidden;
this.allowArbitrary = !!config.allowArbitrary;
mw.rcfilters.dm.FilterGroup.prototype.isSticky = function () {
return this.sticky;
};
+
+ /**
+ * Check whether the group value is excluded from saved queries
+ *
+ * @return {boolean} Group value is excluded from saved queries
+ */
+ mw.rcfilters.dm.FilterGroup.prototype.isExcludedFromSavedQueries = function () {
+ return this.excludedFromSavedQueries;
+ };
}( mediaWiki ) );
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.
// we should remove all sticky behavior methods completely
// See T172156
// isSticky: true,
+ excludedFromSavedQueries: true,
filters: displayConfig.limitArray.map( function ( num ) {
return controller._createFilterDataFromNumber( num, num );
} )
'default': mw.user.options.get( 'rcdays', '30' ),
// Temporarily making this not sticky while limit is not sticky, see above
// isSticky: true,
+ excludedFromSavedQueries: true,
filters: [
// Hours (1, 2, 6, 12)
0.04166, 0.0833, 0.25, 0.5
this.savedQueriesModel.initialize(
parsedSavedQueries,
this._getBaseFilterState(),
- // This is for backwards compatibility - delete all sticky filter states
- Object.keys( this.filtersModel.getStickyFiltersState() )
+ // This is for backwards compatibility - delete all excluded filter states
+ Object.keys( this.filtersModel.getExcludedFiltersState() )
);
// Check whether we need to load defaults.
// These are filter states; highlight is stored as boolean
highlightedItems.highlight = this.filtersModel.isHighlightEnabled();
- // Delete all sticky filters
- this._deleteStickyValuesFromFilterState( selectedState );
+ // Delete all excluded filters
+ this._deleteExcludedValuesFromFilterState( selectedState );
// Add item
queryID = this.savedQueriesModel.addNewQuery(
// Update model state from filters
this.filtersModel.toggleFiltersSelected(
- // Merge filters with sticky values
- $.extend( true, {}, data.filters, this.filtersModel.getStickyFiltersState() )
+ // Merge filters with excluded values
+ $.extend( true, {}, data.filters, this.filtersModel.getExcludedFiltersState() )
);
// Update namespace inverted property
} );
highlightedItems.highlight = this.filtersModel.isHighlightEnabled();
- // Remove sticky filters
- this._deleteStickyValuesFromFilterState( selectedState );
+ // Remove anything that should be excluded from the saved query
+ // this includes sticky filters and filters marked with 'excludedFromSavedQueries'
+ this._deleteExcludedValuesFromFilterState( selectedState );
return this.savedQueriesModel.findMatchingQuery(
{
*
* @param {Object} filterState Filter state
*/
- mw.rcfilters.Controller.prototype._deleteStickyValuesFromFilterState = function ( filterState ) {
- // Remove sticky filters
- $.each( this.filtersModel.getStickyFiltersState(), function ( filterName ) {
+ mw.rcfilters.Controller.prototype._deleteExcludedValuesFromFilterState = function ( filterState ) {
+ // Remove excluded filters
+ $.each( this.filtersModel.getExcludedFiltersState(), function ( filterName ) {
delete filterState[ filterName ];
} );
};