7008da85a22b840e1a1827b47d08daf5f464695f
2 var ufGroupCollection
= new CRM
.UF
.UFGroupCollection(_
.sortBy(CRM
.initialProfileList
.values
, 'title'));
3 //var ufGroupCollection = new CRM.UF.UFGroupCollection(CRM.initialProfileList.values, {
4 // comparator: 'title' // no point, this doesn't work with subcollections
6 ufGroupCollection
.unshift(new CRM
.UF
.UFGroupModel({
8 title
: ts('- select -')
13 * <input type="text" value="{$profileId}" class="crm-profile-selector" />
15 * cj('.crm-profile-selector').crmProfileSelector({
16 * groupTypeFilter: "Contact,Individual,Activity;;ActivityType:7",
17 * entities: "contact_1:IndividualModel,activity_1:ActivityModel"
20 * Note: The system does not currently support dynamic entities -- it only supports
21 * a couple of entities named "contact_1" and "activity_1". See also
22 * CRM.UF.guessEntityName().
24 $.fn
.crmProfileSelector = function(options
) {
25 return this.each(function() {
26 // Hide the existing <SELECT> and instead construct a ProfileSelector view.
27 // Keep them synchronized.
31 if (options
.groupTypeFilter
) {
32 matchingUfGroups
= ufGroupCollection
.subcollection({
33 filter: function(ufGroupModel
) {
34 return ufGroupModel
.checkGroupType(options
.groupTypeFilter
);
38 matchingUfGroups
= ufGroupCollection
;
41 var view
= new CRM
.ProfileSelector
.View({
42 ufGroupId
: $(select
).val(),
43 ufGroupCollection
: matchingUfGroups
,
44 ufEntities
: options
.entities
46 view
.on('change:ufGroupId', function() {
47 $(select
).val(view
.getUfGroupId()).change();
50 $(select
).after(view
.el
);
51 setTimeout(function() {
57 $('#crm-container').on('crmLoad', function() {
58 $('.crm-profile-selector:not(.rendered)', this).addClass('rendered').each(function() {
59 $(this).crmProfileSelector({
60 groupTypeFilter
: $(this).attr('data-group-type'),
61 entities
: $(this).data('entities')