| 1 | (function(angular, $, _) { |
| 2 | |
| 3 | angular.module('crmMailing').controller('EditUnsubGroupCtrl', function EditUnsubGroupCtrl($scope) { |
| 4 | // CRM.crmMailing.groupNames is a global constant - since it doesn't change, we can digest & cache. |
| 5 | var mandatoryIds = []; |
| 6 | |
| 7 | $scope.isUnsubGroupRequired = function isUnsubGroupRequired(mailing) { |
| 8 | if (!_.isEmpty(CRM.crmMailing.groupNames)) { |
| 9 | _.each(CRM.crmMailing.groupNames, function(grp) { |
| 10 | if (grp.is_hidden == "1") { |
| 11 | mandatoryIds.push(parseInt(grp.id)); |
| 12 | } |
| 13 | }); |
| 14 | return _.intersection(mandatoryIds, mailing.recipients.groups.include).length > 0; |
| 15 | } |
| 16 | }; |
| 17 | }); |
| 18 | |
| 19 | })(angular, CRM.$, CRM._); |