Merge pull request #10405 from agh1/crm-19612
[civicrm-core.git] / ang / crmMailing / ViewRecipCtrl.js
1 (function(angular, $, _) {
2
3 angular.module('crmMailing').controller('ViewRecipCtrl', function ViewRecipCtrl($scope) {
4 $scope.getIncludesAsString = function(mailing) {
5 var first = true;
6 var names = '';
7 _.each(mailing.recipients.groups.include, function(id) {
8 var group = _.where(CRM.crmMailing.groupNames, {id: '' + id});
9 if (group.length) {
10 if (!first) {
11 names = names + ', ';
12 }
13 names = names + group[0].title;
14 first = false;
15 }
16 });
17 _.each(mailing.recipients.mailings.include, function(id) {
18 var oldMailing = _.where(CRM.crmMailing.civiMails, {id: '' + id});
19 if (oldMailing.length) {
20 if (!first) {
21 names = names + ', ';
22 }
23 names = names + oldMailing[0].name;
24 first = false;
25 }
26 });
27 return names;
28 };
29 $scope.getExcludesAsString = function(mailing) {
30 var first = true;
31 var names = '';
32 _.each(mailing.recipients.groups.exclude, function(id) {
33 var group = _.where(CRM.crmMailing.groupNames, {id: '' + id});
34 if (group.length) {
35 if (!first) {
36 names = names + ', ';
37 }
38 names = names + group[0].title;
39 first = false;
40 }
41 });
42 _.each(mailing.recipients.mailings.exclude, function(id) {
43 var oldMailing = _.where(CRM.crmMailing.civiMails, {id: '' + id});
44 if (oldMailing.length) {
45 if (!first) {
46 names = names + ', ';
47 }
48 names = names + oldMailing[0].name;
49 first = false;
50 }
51 });
52 return names;
53 };
54 });
55
56 })(angular, CRM.$, CRM._);