drupal-civicrm/sites/all/modules/civicrm/ang/crmMailing/EditUnsubGroupCtrl.js

20 lines
697 B
JavaScript
Raw Normal View History

2018-01-14 15:10:16 +02:00
(function(angular, $, _) {
angular.module('crmMailing').controller('EditUnsubGroupCtrl', function EditUnsubGroupCtrl($scope) {
// CRM.crmMailing.groupNames is a global constant - since it doesn't change, we can digest & cache.
var mandatoryIds = [];
$scope.isUnsubGroupRequired = function isUnsubGroupRequired(mailing) {
if (!_.isEmpty(CRM.crmMailing.groupNames)) {
_.each(CRM.crmMailing.groupNames, function(grp) {
if (grp.is_hidden == "1") {
mandatoryIds.push(parseInt(grp.id));
}
});
return _.intersection(mandatoryIds, mailing.recipients.groups.include).length > 0;
}
};
});
})(angular, CRM.$, CRM._);