From: Coleman Watts Date: Fri, 20 Mar 2015 04:15:26 +0000 (-0400) Subject: CRM-16142 - Disable test send if group is empty X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d3bf820be92426da941089adfdd3ec49c5f39fcb;p=civicrm-core.git CRM-16142 - Disable test send if group is empty --- diff --git a/js/angular-crmMailing/directives.js b/js/angular-crmMailing/directives.js index 2526792375..05c22cf690 100644 --- a/js/angular-crmMailing/directives.js +++ b/js/angular-crmMailing/directives.js @@ -64,7 +64,7 @@ scope.previewTestGroup = function(e) { var $dialog = $(this); - $dialog.html('
'); + $dialog.html('
').parent().find('button[data-op=yes]').prop('disabled', true); $dialog.dialog('option', 'title', ts('Send to %1', {1: _.pluck(_.where(scope.crmMailingConst.groupNames, {id: scope.testGroup.gid}), 'title')[0]})); CRM.api3('contact', 'get', {group: scope.testGroup.gid, options: {limit: 0}, return: 'display_name,email'}).done(function(data) { var count = 0, @@ -78,7 +78,16 @@ } }); markup += ''; - $dialog.html('

' + ts('A test message will be sent to %1 people:', {1: count}) + '

' + markup).trigger('crmLoad'); + markup = '

' + ts('A test message will be sent to %1 people:', {1: count}) + '

' + markup; + if (!count) { + markup = '
' + + (data.count ? ts('None of the contacts in this group have an email address.') : ts('Group is empty.')) + + '
'; + } + $dialog + .html(markup) + .trigger('crmLoad') + .parent().find('button[data-op=yes]').prop('disabled', !count); }); }; }