X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2Fjquery%2Fjquery.crmProfileSelector.js;h=83d1cfcf3a25249ca3c0a562512c354656e33f5f;hb=8267e50954965b81ec5ce5b8950c3ad6d44e6c35;hp=b46dd499dced245a2d6c870d4d1d39d8c899b0ef;hpb=d48ed7da5868bb1cad7e1b2d83b0d3eb1bac95af;p=civicrm-core.git diff --git a/js/jquery/jquery.crmProfileSelector.js b/js/jquery/jquery.crmProfileSelector.js index b46dd499dc..83d1cfcf3a 100644 --- a/js/jquery/jquery.crmProfileSelector.js +++ b/js/jquery/jquery.crmProfileSelector.js @@ -29,10 +29,15 @@ $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 { @@ -40,7 +45,7 @@ } //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); @@ -50,7 +55,7 @@ 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'; @@ -85,7 +90,8 @@ groupTypeFilter: $(this).data('groupType'), entities: $(this).data('entities'), //CRM-15427 - allowAllSubtypes: $(this).data('default') + allowAllSubtypes: $(this).data('default'), + usedByFilter: $(this).data('usedfor') }); }); });