Merge "ApiQueryInfo: fix query limits for testactions"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / dm / mw.rcfilters.dm.FilterItem.js
index 4e2079d..7e35b33 100644 (file)
@@ -12,6 +12,7 @@
         *  selected, makes inactive.
         * @cfg {string[]} [subset] Defining the names of filters that are a subset of this filter
         * @cfg {Object} [conflicts] Defines the conflicts for this filter
+        * @cfg {boolean} [visible=true] The visibility of the group
         */
        mw.rcfilters.dm.FilterItem = function MwRcfiltersDmFilterItem( param, groupModel, config ) {
                config = config || {};
@@ -29,6 +30,7 @@
                this.subset = config.subset || [];
                this.conflicts = config.conflicts || {};
                this.superset = [];
+               this.visible = config.visible === undefined ? true : !!config.visible;
 
                // Interaction states
                this.included = false;
@@ -92,6 +94,7 @@
 
                key = key || 'contextDescription';
 
+               // eslint-disable-next-line no-restricted-properties
                $.each( conflicts, function ( filterName, conflict ) {
                        if ( !conflict.item.isSelected() ) {
                                return;
                                // if the item is also not highlighted. See T161273
                                superset = this.getSuperset();
                                // For this message we need to collect the affecting superset
-                               affectingItems = this.getGroupModel().getSelectedItems( this )
+                               affectingItems = this.getGroupModel().findSelectedItems( this )
                                        .filter( function ( item ) {
                                                return superset.indexOf( item.getName() ) !== -1;
                                        } )
 
                                messageKey = 'rcfilters-state-message-subset';
                        } else if ( this.isFullyCovered() && !this.isHighlighted() ) {
-                               affectingItems = this.getGroupModel().getSelectedItems( this )
+                               affectingItems = this.getGroupModel().findSelectedItems( this )
                                        .map( function ( item ) {
                                                return mw.msg( 'quotation-marks', item.getLabel() );
                                        } );
                        this.emit( 'update' );
                }
        };
+
+       /**
+        * Toggle the visibility of this item
+        *
+        * @param {boolean} [isVisible] Item is visible
+        */
+       mw.rcfilters.dm.FilterItem.prototype.toggleVisible = function ( isVisible ) {
+               isVisible = isVisible === undefined ? !this.visible : !!isVisible;
+
+               if ( this.visible !== isVisible ) {
+                       this.visible = isVisible;
+                       this.emit( 'update' );
+               }
+       };
+
+       /**
+        * Check whether the item is visible
+        *
+        * @return {boolean} Item is visible
+        */
+       mw.rcfilters.dm.FilterItem.prototype.isVisible = function () {
+               return this.visible;
+       };
+
 }( mediaWiki ) );