RCFilters UI: Followup Ic97c7c6aae7: Only add state message if item is selected
authorMoriel Schottlender <moriel@gmail.com>
Sat, 18 Mar 2017 18:39:36 +0000 (11:39 -0700)
committerMoriel Schottlender <moriel@gmail.com>
Sat, 18 Mar 2017 18:39:36 +0000 (11:39 -0700)
Unselected items are highlighted, and hence are not in actual conflict
or coverage or inclusion states.

Bug: T156427
Change-Id: Ie8b6020e6dc93b46e94d2bc2bebb71b56f1e3645

resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FilterItem.js

index 5f406bd..a066d9e 100644 (file)
                var messageKey, details, superset,
                        affectingItems = [];
 
-               if ( this.isConflicted() ) {
-                       // First look in filter's own conflicts
-                       details = this.getConflictDetails( this.getOwnConflicts() );
-                       if ( !details.message ) {
-                               // Fall back onto conflicts in the group
-                               details = this.getConflictDetails( this.getGroupModel().getConflicts() );
+               if ( this.isSelected() ) {
+                       if ( this.isConflicted() ) {
+                               // First look in filter's own conflicts
+                               details = this.getConflictDetails( this.getOwnConflicts() );
+                               if ( !details.message ) {
+                                       // Fall back onto conflicts in the group
+                                       details = this.getConflictDetails( this.getGroupModel().getConflicts() );
+                               }
+
+                               messageKey = details.message;
+                               affectingItems = details.names;
+                       } else if ( this.isIncluded() ) {
+                               superset = this.getSuperset();
+                               // For this message we need to collect the affecting superset
+                               affectingItems = this.getGroupModel().getSelectedItems( this )
+                                       .filter( function ( item ) {
+                                               return superset.indexOf( item.getName() ) !== -1;
+                                       } )
+                                       .map( function ( item ) {
+                                               return mw.msg( 'quotation-marks', item.getLabel() );
+                                       } );
+
+                               messageKey = 'rcfilters-state-message-subset';
+                       } else if ( this.isFullyCovered() ) {
+                               affectingItems = this.getGroupModel().getSelectedItems( this )
+                                       .map( function ( item ) {
+                                               return mw.msg( 'quotation-marks', item.getLabel() );
+                                       } );
+
+                               messageKey = 'rcfilters-state-message-fullcoverage';
                        }
-
-                       messageKey = details.message;
-                       affectingItems = details.names;
-               } else if ( this.isIncluded() ) {
-                       superset = this.getSuperset();
-                       // For this message we need to collect the affecting superset
-                       affectingItems = this.getGroupModel().getSelectedItems( this )
-                               .filter( function ( item ) {
-                                       return superset.indexOf( item.getName() ) !== -1;
-                               } )
-                               .map( function ( item ) {
-                                       return mw.msg( 'quotation-marks', item.getLabel() );
-                               } );
-
-                       messageKey = 'rcfilters-state-message-subset';
-               } else if ( this.isFullyCovered() ) {
-                       affectingItems = this.getGroupModel().getSelectedItems( this )
-                               .map( function ( item ) {
-                                       return mw.msg( 'quotation-marks', item.getLabel() );
-                               } );
-
-                       messageKey = 'rcfilters-state-message-fullcoverage';
                }
 
                if ( messageKey ) {