drupal-civicrm/sites/all/modules/civicrm/ang/crmMailing/EditUnsubGroupCtrl.js
2018-01-14 13:10:16 +00:00

20 lines
697 B
JavaScript

(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._);