From 720c658b42e4fe51729e272f2f76ea5ce833a538 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 19 Feb 2015 20:28:36 -0800 Subject: [PATCH] CRM-15801 - crmMailing - Display the "Unsubscribe tracking group" field But only if the recipient list includes a hidden-group / search-result-group. --- CRM/Mailing/Form/Task/AdhocMailing.php | 1 + js/angular-crmMailing.js | 14 ++++++++++++++ js/angular-crmMailing/services.js | 6 +++--- partials/crmMailing/mailing.html | 13 +++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CRM/Mailing/Form/Task/AdhocMailing.php b/CRM/Mailing/Form/Task/AdhocMailing.php index 186a501260..371393640d 100644 --- a/CRM/Mailing/Form/Task/AdhocMailing.php +++ b/CRM/Mailing/Form/Task/AdhocMailing.php @@ -51,6 +51,7 @@ class CRM_Mailing_Form_Task_AdhocMailing extends CRM_Contact_Form_Task { 'groups' => array( 'include' => array($groupId), 'exclude' => array(), + 'base' => array(), ), 'mailings' => array( 'include' => array(), diff --git a/js/angular-crmMailing.js b/js/angular-crmMailing.js index cb6e6449d0..09fa277fb9 100644 --- a/js/angular-crmMailing.js +++ b/js/angular-crmMailing.js @@ -522,4 +522,18 @@ } }; }); + + 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 = []; + _.each(CRM.crmMailing.groupNames, function(grp){ + if (grp.is_hidden == "1") { + mandatoryIds.push(parseInt(grp.id)); + } + }); + + $scope.isUnsubGroupRequired = function isUnsubGroupRequired(mailing) { + return _.intersection(mandatoryIds, mailing.recipients.groups.include).length > 0; + }; + }); })(angular, CRM.$, CRM._); diff --git a/js/angular-crmMailing/services.js b/js/angular-crmMailing/services.js index 1ee3c89378..c95c57ff3b 100644 --- a/js/angular-crmMailing/services.js +++ b/js/angular-crmMailing/services.js @@ -133,7 +133,7 @@ return crmApi('MailingGroup', 'get', {mailing_id: mailing.id}) .then(function (groupResult) { mailing.recipients = {}; - mailing.recipients.groups = {include: [], exclude: []}; + mailing.recipients.groups = {include: [], exclude: [], base: []}; mailing.recipients.mailings = {include: [], exclude: []}; _.each(groupResult.values, function (mailingGroup) { var bucket = (/^civicrm_group/.test(mailingGroup.entity_table)) ? 'groups' : 'mailings'; @@ -155,8 +155,8 @@ var defaults = { jobs: {}, // {jobId: JobRecord} recipients: { - groups: {include: [], exclude: []}, - mailings: {include: [], exclude: []}, + groups: {include: [], exclude: [], base: []}, + mailings: {include: [], exclude: []} }, name: "", campaign_id: null, diff --git a/partials/crmMailing/mailing.html b/partials/crmMailing/mailing.html index 2ef321ca27..3ade3ee9f4 100644 --- a/partials/crmMailing/mailing.html +++ b/partials/crmMailing/mailing.html @@ -51,6 +51,19 @@ It could perhaps be thinned by 30-60% by making more directives.
+ +
+ +
+
-- 2.25.1