From 323f9fe5cb6fdf8b526e774e8f8e97ff6a833b83 Mon Sep 17 00:00:00 2001 From: Lema Date: Mon, 26 Feb 2018 18:43:26 +0300 Subject: [PATCH] CRM-21779 - ang\crmMailing - Fix adding empty mailing to recipients field --- ang/crmMailing/Recipients.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ang/crmMailing/Recipients.js b/ang/crmMailing/Recipients.js index ceae2db871..759fd4c91a 100644 --- a/ang/crmMailing/Recipients.js +++ b/ang/crmMailing/Recipients.js @@ -229,6 +229,11 @@ page_num: rcpAjaxState.page_i, params: filterParams, }; + + if('civicrm_mailing' === rcpAjaxState.entity) { + params["api.MailingRecipients.getcount"] = {}; + } + return params; }, transport: function(params) { @@ -246,12 +251,18 @@ results: function(data) { results = { children: $.map(data.values, function(obj) { - return { id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, - text: obj.label }; + if('civicrm_mailing' === rcpAjaxState.entity) { + return obj["api.MailingRecipients.getcount"] > 0 ? { id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, + text: obj.label } : ''; + } + else { + return { id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, + text: obj.label }; + } }) }; - if (rcpAjaxState.page_i == 1 && data.count) { + if (rcpAjaxState.page_i == 1 && data.count && results.children.length > 0) { results.text = ts((rcpAjaxState.type == 'include'? 'Include ' : 'Exclude ') + (rcpAjaxState.entity == 'civicrm_group'? 'Group' : 'Mailing')); } -- 2.25.1