From da2388a42c777713da3e7f36c8dd363ef592c1c0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 19 Mar 2015 16:52:31 -0400 Subject: [PATCH] CRM-16142 - Confirm before sending test mailing to a group --- js/angular-crmMailing.js | 21 +++++++++++++++++++++ partials/crmMailing/preview.html | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/js/angular-crmMailing.js b/js/angular-crmMailing.js index 256cda54e8..57f09ba864 100644 --- a/js/angular-crmMailing.js +++ b/js/angular-crmMailing.js @@ -109,6 +109,27 @@ })); }; + $scope.previewTestGroup = function(e) { + var $dialog = $(this), + // Fixme: how to get this from the scope? + gid = $('select[name=preview_test_group]').val(); + $dialog.html('
'); + CRM.api3('contact', 'get', {group: gid, options: {limit: 0}, return: 'display_name,email'}).done(function(data) { + // Fixme: should this be in a template? + var count = 0, + markup = '
    '; + _.each(data.values, function(row) { + // Fixme: contact api doesn't seem capable of filtering out contacts with no email, so we're doing it client-side + if (row.email) { + count++; + markup += '
  1. ' + row.display_name + ' - ' + row.email + '
  2. '; + } + }); + markup += '
'; + $dialog.html('

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

' + markup).trigger('crmLoad'); + }); + }; + // @return Promise $scope.submit = function submit(options) { options = options || {}; diff --git a/partials/crmMailing/preview.html b/partials/crmMailing/preview.html index bfc7120dc1..9a514d4f40 100644 --- a/partials/crmMailing/preview.html +++ b/partials/crmMailing/preview.html @@ -52,7 +52,7 @@ Vars: mailing:obj, testContact:obj, testGroup:obj, crmMailing:FormController - +
-- 2.25.1