From 47bacc20550752ebb0357351bcb2b2e4cc49b0b7 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 29 Nov 2014 17:58:08 -0800 Subject: [PATCH] CRM-15578 - crmMailing2 - Implement "review.html" --- css/angular-crmMailing2.css | 7 +- js/angular-crmMailing2-directives.js | 25 +++++++ js/angular-crmMailing2.js | 66 +++++++++++++++++++ .../crmMailing2/dialog/previewComponent.html | 28 ++++++++ partials/crmMailing2/review.html | 51 +++++++++++++- 5 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 partials/crmMailing2/dialog/previewComponent.html diff --git a/css/angular-crmMailing2.css b/css/angular-crmMailing2.css index c672f83f67..6d5d98ee9e 100644 --- a/css/angular-crmMailing2.css +++ b/css/angular-crmMailing2.css @@ -57,4 +57,9 @@ input[name=preview_test_email]::-webkit-input-placeholder { } input[name=preview_test_email]:-ms-input-placeholder { text-align: center; -} \ No newline at end of file +} +.crmMailing2-active { +} +.crmMailing2-inactive { + text-decoration: line-through; +} diff --git a/js/angular-crmMailing2-directives.js b/js/angular-crmMailing2-directives.js index d3e8089269..3ca02671e4 100644 --- a/js/angular-crmMailing2-directives.js +++ b/js/angular-crmMailing2-directives.js @@ -5,6 +5,31 @@ var crmMailing2 = angular.module('crmMailing2'); + crmMailing2.directive('crmMailingReviewBool', function(){ + return { + scope: { + crmOn: '@', + crmTitle: '@' + }, + template: '{{crmTitle}} ', + link: function(scope, element, attrs){ + function refresh() { + if (scope.$parent.$eval(attrs.crmOn)) { + scope.spanClasses = {'crmMailing2-active': true}; + scope.iconClasses = {'ui-icon-check': true}; + } else { + scope.spanClasses = {'crmMailing2-inactive': true}; + scope.iconClasses = {'ui-icon-close': true}; + } + scope.crmTitle = scope.$parent.$eval(attrs.crmTitle); + } + refresh(); + scope.$parent.$watch(attrs.crmOn, refresh); + scope.$parent.$watch(attrs.crmTitle, refresh); + } + }; + }); + // example: // WISHLIST: Instead of global CRM.crmMailing.mailTokens, accept token list as an input crmMailing2.directive('crmMailingToken', function () { diff --git a/js/angular-crmMailing2.js b/js/angular-crmMailing2.js index afc2a42705..ceabf5a2e5 100644 --- a/js/angular-crmMailing2.js +++ b/js/angular-crmMailing2.js @@ -132,6 +132,41 @@ return ts('>%1 recipients', {1: RECIPIENTS_PREVIEW_LIMIT}); return ts('~%1 recipients', {1: $scope.recipients.length}); }; + $scope.getIncludesAsString = function() { + var first = true; + var names = ''; + _.each($scope.mailing.groups.include, function(id){ + if (!first) names = names + ', '; + var group = _.where(CRM.crmMailing.groupNames, {id: ''+id}); + names = names + group[0].title; + first = false; + }); + _.each($scope.mailing.mailings.include, function(id){ + if (!first) names = names + ', '; + var oldMailing = _.where(CRM.crmMailing.civiMails, {id: ''+id}); + names = names + oldMailing[0].name; + first = false; + }); + return names; + }; + $scope.getExcludesAsString = function() { + var first = true; + var names = ''; + _.each($scope.mailing.groups.exclude, function(id){ + if (!first) names = names + ', '; + var group = _.where(CRM.crmMailing.groupNames, {id: ''+id}); + names = names + group[0].title; + first = false; + }); + _.each($scope.mailing.mailings.exclude, function(id){ + if (!first) names = names + ', '; + var oldMailing = _.where(CRM.crmMailing.civiMails, {id: ''+id}); + names = names + oldMailing[0].name; + first = false; + }); + return names; + }; + // We monitor four fields -- use debounce so that changes across the // four fields can settle-down before AJAX. var refreshRecipients = _.debounce(function () { @@ -232,4 +267,35 @@ $scope.ts = CRM.ts('CiviMail'); }); + // Controller for the "Preview Mailing Component" segment + // which displays header/footer/auto-responder + crmMailing2.controller('PreviewComponentCtrl', function PreviewMailingDialogCtrl($scope, dialogService) { + $scope.ts = CRM.ts('CiviMail'); + $scope.previewComponent = function previewComponent(title, componentId) { + var component = _.where(CRM.crmMailing.headerfooterList, {id: ""+componentId}); + if (!component || !component[0]) { + CRM.alert(ts('Invalid component ID (%1)', { + 1: componentId + })); + return; + } + var options = { + autoOpen: false, + modal: true, + title: title // component[0].name + }; + dialogService.open('previewComponentDialog', partialUrl('dialog/previewComponent.html'), component[0], options); + }; + }); + + // Controller for the "Preview Mailing" dialog + // Note: Expects $scope.model to be an object with properties: + // - "name" + // - "subject" + // - "body_html" + // - "body_text" + crmMailing2.controller('PreviewComponentDialogCtrl', function PreviewMailingDialogCtrl($scope) { + $scope.ts = CRM.ts('CiviMail'); + }); + })(angular, CRM.$, CRM._); diff --git a/partials/crmMailing2/dialog/previewComponent.html b/partials/crmMailing2/dialog/previewComponent.html new file mode 100644 index 0000000000..71db702761 --- /dev/null +++ b/partials/crmMailing2/dialog/previewComponent.html @@ -0,0 +1,28 @@ +
+
+
+
+
{{ts('Name')}}
+
+ {{model.name}} +
+
+
+
+
{{ts('Subject')}}
+
+ {{model.subject}} +
+
+
+
+
+
+
+ +
+
+
{{model.body_text}}
+
+
+
diff --git a/partials/crmMailing2/review.html b/partials/crmMailing2/review.html index f31aa79af1..e5fb27bb3f 100644 --- a/partials/crmMailing2/review.html +++ b/partials/crmMailing2/review.html @@ -1 +1,50 @@ -review.html + +
+
+
+
+ {{mailing.name}} +
+
+
+ +
+ ({{ts('Include:')}} {{getIncludesAsString()}}) +
+
+ ({{ts('Exclude:')}} {{getExcludesAsString()}}) +
+
+
+
+ +
+
+ + +
+
+
+ + +
+ +
+
+ {{mailing.visibility}} +
+
+
+
-- 2.25.1