From 89f476c43edb52c29e8040b5e970777780063fb9 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 12 Feb 2015 11:45:55 -0800 Subject: [PATCH] CRM-15856 - Required tokens - Display rich dialog --- js/angular-crmMailing.js | 51 +++++++++----- partials/crmMailing/body_html.html | 3 +- partials/crmMailing/body_text.html | 3 +- partials/crmMailing/dialog/tokenAlert.html | 82 ++++++++++++++++++++++ partials/crmMailing/headerFooter.html | 4 +- 5 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 partials/crmMailing/dialog/tokenAlert.html diff --git a/js/angular-crmMailing.js b/js/angular-crmMailing.js index f75cdf450e..3077d4d11b 100644 --- a/js/angular-crmMailing.js +++ b/js/angular-crmMailing.js @@ -433,32 +433,49 @@ }); var lastEmailTokenAlert = null; - angular.module('crmMailing').controller('EmailBodyCtrl', function EmailBodyCtrl($scope, crmMailingMgr) { + angular.module('crmMailing').controller('EmailBodyCtrl', function EmailBodyCtrl($scope, crmMailingMgr, crmUiAlert, $timeout) { var ts = CRM.ts(null); - $scope.hasAllTokens = function hasMissingTokens(mailing, field) { + // ex: if (!hasAllTokens(myMailing, 'body_text)) alert('Oh noes!'); + $scope.hasAllTokens = function hasAllTokens(mailing, field) { return _.isEmpty(crmMailingMgr.findMissingTokens(mailing, field)); }; - $scope.checkTokens = function checkTokens(mailing) { + // ex: checkTokens(myMailing, 'body_text', 'insert:body_text') + // ex: checkTokens(myMailing, '*') + $scope.checkTokens = function checkTokens(mailing, field, insertEvent) { if (lastEmailTokenAlert) { lastEmailTokenAlert.close(); } - var missing = angular.extend( - {}, - crmMailingMgr.findMissingTokens(mailing, 'body_html'), - crmMailingMgr.findMissingTokens(mailing, 'body_text') - ); - if (! _.isEmpty(missing)) { - var buf = '

' + - ts('Before submitting this mailing, you must include an address token and an action token as part of the mailing body, mailing header, or mailing footer.') + - '

'; - lastEmailTokenAlert = CRM.alert(buf, undefined, 'error'); } }; }); diff --git a/partials/crmMailing/body_html.html b/partials/crmMailing/body_html.html index 9fd7469b77..e1d23a8949 100644 --- a/partials/crmMailing/body_html.html +++ b/partials/crmMailing/body_html.html @@ -13,7 +13,8 @@ Required vars: mailing crm-ui-richtext name="body_html" crm-ui-insert-rx="insert:body_html" ng-model="mailing.body_html" - ng-blur="checkTokens(mailing)"> + ng-blur="checkTokens(mailing, 'body_html', 'insert:body_html')" + > diff --git a/partials/crmMailing/body_text.html b/partials/crmMailing/body_text.html index 1e2ad5cda3..f3ac7c7598 100644 --- a/partials/crmMailing/body_text.html +++ b/partials/crmMailing/body_text.html @@ -13,7 +13,8 @@ Required vars: mailing, crmMailingConst crm-ui-insert-rx="insert:body_text" name="body_text" ng-model="mailing.body_text" - ng-blur="checkTokens(mailing)"> + ng-blur="checkTokens(mailing, 'body_text', 'insert:body_text')" + > diff --git a/partials/crmMailing/dialog/tokenAlert.html b/partials/crmMailing/dialog/tokenAlert.html new file mode 100644 index 0000000000..dc32303ab5 --- /dev/null +++ b/partials/crmMailing/dialog/tokenAlert.html @@ -0,0 +1,82 @@ +

+ {{ts('The mailing must include the street address of the organization. Please insert the %1 token.', {1: + '{domain.address}'})}} +

+ +
+ {{ts('Address')}} + +
+
+ +

+ {{ts('The mailing must allow recipients to (a) unsubscribe from the mailing-list or (b) completely opt-out from all + mailings. Please insert an unsubscribe or opt-out token.')}} +

+ +
+ + + + + + + + + + + + + + + + + +
{{ts('Via Web')}}{{ts('Via Email')}}
+ {{ts('Unsubscribe')}} + + {{ts('Unsubscribe')}} +
+ {{ts('Opt-out')}} + + {{ts('Opt-out')}} +
+
+ +
+ + + + + + + + + + + + + + + + + +
{{ts('Via Web')}}{{ts('Via Email')}}
+ {action.optOutUrl} + + {action.optOut} +
+ {action.unsubscribeUrl} + + {action.unsubscribe} +
+
+ +

+ {{ts('Alternatively, you may select a header or footer which includes the required tokens.')}} +

diff --git a/partials/crmMailing/headerFooter.html b/partials/crmMailing/headerFooter.html index 11a2910760..5446b7e7d9 100644 --- a/partials/crmMailing/headerFooter.html +++ b/partials/crmMailing/headerFooter.html @@ -10,7 +10,7 @@ Required vars: mailing, crmMailingConst name="header_id" ui-jq="select2" ui-options="{dropdownAutoWidth : true, allowClear: true}" - ng-change="checkTokens(mailing)" + ng-change="checkTokens(mailing, '*')" ng-model="mailing.header_id" ng-options="mc.id as mc.name for mc in crmMailingConst.headerfooterList | filter:{component_type: 'Header'}"> @@ -22,7 +22,7 @@ Required vars: mailing, crmMailingConst name="footer_id" ui-jq="select2" ui-options="{dropdownAutoWidth : true, allowClear: true}" - ng-change="checkTokens(mailing)" + ng-change="checkTokens(mailing, '*')" ng-model="mailing.footer_id" ng-options="mc.id as mc.name for mc in crmMailingConst.headerfooterList | filter:{component_type: 'Footer'}"> -- 2.25.1