3 * View model for a filter group
5 * @mixins OO.EventEmitter
6 * @mixins OO.EmitterList
9 * @param {Object} [config] Configuration options
10 * @cfg {string} [name] Group name
11 * @cfg {string} [type='send_unselected_if_any'] Group type
12 * @cfg {string} [title] Group title
13 * @cfg {string} [separator='|'] Value separator for 'string_options' groups
14 * @cfg {string} [exclusionType='default'] Group exclusion type
15 * @cfg {boolean} [active] Group is active
17 mw
.rcfilters
.dm
.FilterGroup
= function MwRcfiltersDmFilterGroup( config
) {
18 config
= config
|| {};
21 OO
.EventEmitter
.call( this );
22 OO
.EmitterList
.call( this );
24 this.name
= config
.name
;
25 this.type
= config
.type
|| 'send_unselected_if_any';
26 this.title
= config
.title
;
27 this.separator
= config
.separator
|| '|';
28 this.exclusionType
= config
.exclusionType
|| 'default';
29 this.active
= !!config
.active
;
33 OO
.initClass( mw
.rcfilters
.dm
.FilterGroup
);
34 OO
.mixinClass( mw
.rcfilters
.dm
.FilterGroup
, OO
.EventEmitter
);
35 OO
.mixinClass( mw
.rcfilters
.dm
.FilterGroup
, OO
.EmitterList
);
42 * Group state has been updated
48 * Check the active status of the group and set it accordingly.
52 mw
.rcfilters
.dm
.FilterGroup
.prototype.checkActive = function () {
56 // Recheck group activity
57 this.getItems().forEach( function ( filterItem
) {
58 count
+= Number( filterItem
.isSelected() );
63 count
< this.getItemCount()
66 if ( this.active
!== active
) {
68 this.emit( 'update' );
73 * Get group active state
75 * @return {boolean} Active state
77 mw
.rcfilters
.dm
.FilterGroup
.prototype.isActive = function () {
84 * @return {string} Group name
86 mw
.rcfilters
.dm
.FilterGroup
.prototype.getName = function () {
93 * @return {string} Group type
95 mw
.rcfilters
.dm
.FilterGroup
.prototype.getType = function () {
102 * @return {string} Title
104 mw
.rcfilters
.dm
.FilterGroup
.prototype.getTitle = function () {
109 * Get group's values separator
111 * @return {string} Values separator
113 mw
.rcfilters
.dm
.FilterGroup
.prototype.getSeparator = function () {
114 return this.separator
;
118 * Get group exclusion type
120 * @return {string} Exclusion type
122 mw
.rcfilters
.dm
.FilterGroup
.prototype.getExclusionType = function () {
123 return this.exclusionType
;