$select = $(this).hide().addClass('rendered');
var validTypesId = [];
+ var usedByFilter = null;
if (options.groupTypeFilter) {
matchingUfGroups = ufGroupCollection.subcollection({
filter: function(ufGroupModel) {
- return ufGroupModel.checkGroupType(options.groupTypeFilter, options.allowAllSubtypes);
+ //CRM-16915 - filter with module used by the profile
+ if (options.usedByFilter && options.usedByFilter.length) {
+ usedByFilter = options.usedByFilter;
+ }
+ return ufGroupModel.checkGroupType(options.groupTypeFilter, options.allowAllSubtypes, usedByFilter);
}
});
} else {
}
//CRM-15427 check for valid subtypes raise a warning if not valid
- if (options.allowAllSubtypes && $.isEmptyObject(validTypesId)) {
+ if (options.allowAllSubtypes && !validTypesId.length) {
validTypes = ufGroupCollection.subcollection({
filter: function(ufGroupModel) {
return ufGroupModel.checkGroupType(options.groupTypeFilter);
validTypesId.push(validTypesattr.id);
});
}
- if (!$.isEmptyObject(validTypesId) && $.inArray($select.val(), validTypesId) == -1) {
+ if (validTypesId.length && $.inArray($select.val(), validTypesId) == -1) {
var civiComponent;
if (options.groupTypeFilter.indexOf('Membership') !== -1) {
civiComponent = 'Membership';
groupTypeFilter: $(this).data('groupType'),
entities: $(this).data('entities'),
//CRM-15427
- allowAllSubtypes: $(this).data('default')
+ allowAllSubtypes: $(this).data('default'),
+ usedByFilter: $(this).data('usedfor')
});
});
});