3 * View model for a filter group
5 * @mixins OO.EventEmitter
6 * @mixins OO.EmitterList
9 * @param {Object} [config] Configuration options
10 * @cfg {string} [type='send_unselected_if_any'] Group type
11 * @cfg {string} [title] Group title
12 * @cfg {string} [separator='|'] Value separator for 'string_options' groups
13 * @cfg {string} [exclusionType='default'] Group exclusion type
14 * @cfg {boolean} [active] Group is active
16 mw
.rcfilters
.dm
.FilterGroup
= function MwRcfiltersDmFilterGroup( config
) {
17 config
= config
|| {};
20 OO
.EventEmitter
.call( this );
21 OO
.EmitterList
.call( this );
23 this.type
= config
.type
|| 'send_unselected_if_any';
24 this.title
= config
.title
;
25 this.separator
= config
.separator
|| '|';
26 this.exclusionType
= config
.exclusionType
|| 'default';
27 this.active
= !!config
.active
;
31 OO
.initClass( mw
.rcfilters
.dm
.FilterGroup
);
32 OO
.mixinClass( mw
.rcfilters
.dm
.FilterGroup
, OO
.EventEmitter
);
33 OO
.mixinClass( mw
.rcfilters
.dm
.FilterGroup
, OO
.EmitterList
);
40 * Group state has been updated
46 * Check the active status of the group and set it accordingly.
50 mw
.rcfilters
.dm
.FilterGroup
.prototype.checkActive = function () {
54 // Recheck group activity
55 this.getItems().forEach( function ( filterItem
) {
56 count
+= Number( filterItem
.isSelected() );
61 count
< this.getItemCount()
64 if ( this.active
!== active
) {
66 this.emit( 'update' );
71 * Get group active state
73 * @return {boolean} Active state
75 mw
.rcfilters
.dm
.FilterGroup
.prototype.isActive = function () {
82 * @return {string} Group type
84 mw
.rcfilters
.dm
.FilterGroup
.prototype.getType = function () {
91 * @return {string} Title
93 mw
.rcfilters
.dm
.FilterGroup
.prototype.getTitle = function () {
98 * Get group's values separator
100 * @return {string} Values separator
102 mw
.rcfilters
.dm
.FilterGroup
.prototype.getSeparator = function () {
103 return this.separator
;
107 * Get group exclusion type
109 * @return {string} Exclusion type
111 mw
.rcfilters
.dm
.FilterGroup
.prototype.getExclusionType = function () {
112 return this.exclusionType
;