From: Kurund Jalmi Date: Fri, 25 Feb 2022 11:48:01 +0000 (+0000) Subject: enhance EntityRef to show create new link when contact listing is filtered by multipl... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8e767b90876e2d63f482b8ab6fa2b79dfdbd8bb8;p=civicrm-core.git enhance EntityRef to show create new link when contact listing is filtered by multiple contact types --- diff --git a/js/Common.js b/js/Common.js index fb9d0c3d8a..07eb96b84a 100644 --- a/js/Common.js +++ b/js/Common.js @@ -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 += ' ' +