From: Tim Otten Date: Tue, 11 Nov 2014 01:08:33 +0000 (-0800) Subject: CRM-15578 - crmMailing2 - Add "preview.html" X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=493eb47a2a70f1dfd673554a6a5d14c186f8d9d3;p=civicrm-core.git CRM-15578 - crmMailing2 - Add "preview.html" --- diff --git a/css/angular-crmMailing2.css b/css/angular-crmMailing2.css index 04f02d9365..c672f83f67 100644 --- a/css/angular-crmMailing2.css +++ b/css/angular-crmMailing2.css @@ -25,4 +25,36 @@ span.crmMailing2-include { span.crmMailing2-exclude { color: #600; text-decoration: line-through; +} + +.crmMailing2 input[name=preview_test_email], .crmMailing2-preview select[name=preview_test_group] { + width: 80%; +} + +.crmMailing2 .preview-popup, .crmMailing2 .preview-contact, .crmMailing2 .preview-group { + width: 30%; + height: 4.5em; + margin: 0.5em; + text-align: center; + vertical-align: middle; + float: left; +} +.crmMailing2 .preview-popup, .crmMailing2 .preview-contact { + border-right: 1px solid black; +} +.crmMailing2 .preview-group, .crmMailing2 .preview-contact { +} + +/* Odd: These placeholder directives break if combined */ +input[name=preview_test_email]:-moz-placeholder { + text-align: center; +} +input[name=preview_test_email]::-moz-placeholder { + text-align: center; +} +input[name=preview_test_email]::-webkit-input-placeholder { + text-align: center; +} +input[name=preview_test_email]:-ms-input-placeholder { + text-align: center; } \ No newline at end of file diff --git a/js/angular-crmMailing2-services.js b/js/angular-crmMailing2-services.js index 20f7c93a9c..616d522757 100644 --- a/js/angular-crmMailing2-services.js +++ b/js/angular-crmMailing2-services.js @@ -63,6 +63,21 @@ }; }, + // @param mailing Object (per APIv3) + // @return Promise an object with "subject", "body_text", "body_html" + preview: function preview(mailing) { + var params = _.extend({}, mailing, { + options: {force_rollback: 1}, + 'api.Mailing.preview': { + id: '$value.id', + } + }); + return crmApi('Mailing', 'create', params).then(function(result){ + console.log('preview', params, result); + return result.values[result.id]['api.Mailing.preview'].values; + }); + }, + // @param mailing Object (per APIv3) // @param int previewLimit // @return Promise for a list of recipients (mailing_id, contact_id, api.contact.getvalue, api.email.getvalue) diff --git a/js/angular-crmMailing2.js b/js/angular-crmMailing2.js index b671137c9f..ed013e6d64 100644 --- a/js/angular-crmMailing2.js +++ b/js/angular-crmMailing2.js @@ -143,4 +143,56 @@ crmMailing2.controller('PreviewRecipCtrl', function ($scope) { $scope.ts = CRM.ts('CiviMail'); }); + + // Controller for the "Preview Mailing" segment + // Note: Expects $scope.model to be an object with properties: + // - mailing: object + crmMailing2.controller('PreviewMailingCtrl', function ($scope, dialogService, crmMailingMgr) { + $scope.ts = CRM.ts('CiviMail'); + $scope.testContact = {email: ''}; + $scope.testGroup = {gid: null}; + + $scope.previewHtml = function() { + $scope.previewDialog(partialUrl('dialog/previewHtml.html')); + }; + $scope.previewText = function() { + $scope.previewDialog(partialUrl('dialog/previewText.html')); + }; + $scope.previewFull = function() { + $scope.previewDialog(partialUrl('dialog/previewFull.html')); + }; + // Open a dialog with a preview of the current mailing + // @param template string URL of the template to use in the preview dialog + $scope.previewDialog = function(template) { + CRM.status(ts('Previewing')); + crmMailingMgr + .preview($scope.mailing) + .then(function(content){ + var options = { + autoOpen: false, + modal: true, + title: ts('Subject: %1', { + 1: content.subject + }), + }; + dialogService.open('previewDialog', template, content, options); + }); + }; + $scope.sendTestToContact = function() { + CRM.alert('Send test to contact, ' + $scope.testContact.email); + }; + $scope.sendTestToGroup = function() { + CRM.alert('Send test to group, ' + $scope.testGroup.gid); + }; + }); + + // Controller for the "Preview Mailing" dialog + // Note: Expects $scope.model to be an object with properties: + // - "subject" + // - "body_html" + // - "body_text" + crmMailing2.controller('PreviewMailingDialogCtrl', function ($scope, crmMailingMgr) { + $scope.ts = CRM.ts('CiviMail'); + }); + })(angular, CRM.$, CRM._); diff --git a/partials/crmMailing2/dialog/previewFull.html b/partials/crmMailing2/dialog/previewFull.html new file mode 100644 index 0000000000..0e257a11bc --- /dev/null +++ b/partials/crmMailing2/dialog/previewFull.html @@ -0,0 +1,10 @@ +
+
+
+ +
+
+
{{model.body_text}}
+
+
+
\ No newline at end of file diff --git a/partials/crmMailing2/dialog/previewHtml.html b/partials/crmMailing2/dialog/previewHtml.html new file mode 100644 index 0000000000..c47b1c024c --- /dev/null +++ b/partials/crmMailing2/dialog/previewHtml.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/partials/crmMailing2/dialog/previewText.html b/partials/crmMailing2/dialog/previewText.html new file mode 100644 index 0000000000..246add4bc1 --- /dev/null +++ b/partials/crmMailing2/dialog/previewText.html @@ -0,0 +1,3 @@ +
+
{{model.body_text}}
+
\ No newline at end of file diff --git a/partials/crmMailing2/preview.html b/partials/crmMailing2/preview.html index 64d9145c77..61e2b59e96 100644 --- a/partials/crmMailing2/preview.html +++ b/partials/crmMailing2/preview.html @@ -1 +1,55 @@ -preview.html +
+ +
+
+ ({{ts('No content to preview')}}) +
+
+ +
+
+ +
+ +
+
+
+ {{ts('Send test email to:')}} +
+
+ +
+ +
+
+
+ {{ts('Send test email to group:')}} +
+
+ +
+ +
+
+