Merge "RCFilters: Always put highlight values in the URL"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 15 May 2017 14:33:31 +0000 (14:33 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 15 May 2017 14:33:31 +0000 (14:33 +0000)
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js

index 81b9dc3..4a9e780 100644 (file)
                        highlightedItems[ item.getName() ] = highlightEnabled ?
                                item.getHighlightColor() : null;
                } );
-               highlightedItems.highlight = this.filtersModel.isHighlightEnabled();
+               // Stored as a string '0' or '1'
+               highlightedItems.highlight = String( Number( this.filtersModel.isHighlightEnabled() ) );
 
                // Add item
                this.savedQueriesModel.addNewQuery(
                // highlight params
                uri.query.highlight = Number( this.filtersModel.isHighlightEnabled() );
                Object.keys( highlightParams ).forEach( function ( paramName ) {
-                       if ( highlightParams[ paramName ] ) {
-                               uri.query[ paramName ] = highlightParams[ paramName ];
-                       } else {
-                               delete uri.query[ paramName ];
-                       }
+                       // Always have some value (either the color or null) so that
+                       // if we have something in the URL that doesn't have the highlight
+                       // intentionally, it can override default with highlight.
+                       // Otherwise, the $.extend will always add the highlight that
+                       // exists in the default even if the URL query that is being
+                       // refreshed has different highlights, or has highlights enabled
+                       // but no active highlights anywhere
+                       uri.query[ paramName ] = highlightParams[ paramName ] ?
+                               highlightParams[ paramName ] : null;
                } );
 
                return uri;