Skip to content

Commit

Permalink
Merge pull request #22830 from kurund/entityRef-enhancements
Browse files Browse the repository at this point in the history
dev/core#3082 enhance EntityRef to show create new link when contact listing is fil…
  • Loading branch information
demeritcowboy authored Mar 9, 2022
2 parents b5b3c5b + 8e767b9 commit 8316756
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion js/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,20 @@ if (!CRM.vars) CRM.vars = {};
return '';
}
if (createLinks === true) {
createLinks = params.contact_type ? _.where(CRM.config.entityRef.links[entity], {type: params.contact_type}) : CRM.config.entityRef.links[entity];
if (!params.contact_type) {
createLinks = CRM.config.entityRef.links[entity];
}
else if (typeof params.contact_type === 'string') {
createLinks = _.where(CRM.config.entityRef.links[entity], {type: params.contact_type});
} else {
// lets assume it's an array with filters such as IN etc
createLinks = [];
_.each(params.contact_type, function(types) {
_.each(types, function(type) {
createLinks.push(_.findWhere(CRM.config.entityRef.links[entity], {type: type}));
});
});
}
}
_.each(createLinks, function(link) {
markup += ' <a class="crm-add-entity crm-hover-button" href="' + link.url + '">' +
Expand Down

0 comments on commit 8316756

Please sign in to comment.