RCFilters: Ignore 'invert' model if there are no namespaces in saved queries
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / dm / mw.rcfilters.dm.FiltersViewModel.js
index 3a6efe2..e9e495a 100644 (file)
                } );
        };
 
+       /**
+        * Check whether the invert state is a valid one. A valid invert state is one where
+        * there are actual namespaces selected.
+        *
+        * This is done to compare states to previous ones that may have had the invert model
+        * selected but effectively had no namespaces, so are not effectively different than
+        * ones where invert is not selected.
+        *
+        * @return {boolean} Invert is effectively selected
+        */
+       mw.rcfilters.dm.FiltersViewModel.prototype.areNamespacesEffectivelyInverted = function () {
+               return this.getInvertModel().isSelected() &&
+                       this.getSelectedItems().some( function ( itemModel ) {
+                               return itemModel.getGroupModel().getView() === 'namespace';
+                       } );
+       };
+
        /**
         * Get the item that matches the given name
         *
                this.getItemByName( filterName ).clearHighlightColor();
        };
 
-       /**
-        * Clear highlight for all filter items
-        */
-       mw.rcfilters.dm.FiltersViewModel.prototype.clearAllHighlightColors = function () {
-               this.getItems().forEach( function ( filterItem ) {
-                       filterItem.clearHighlightColor();
-               } );
-       };
-
        /**
         * Return a version of the given string that is without any
         * view triggers.