CRM-15578 - Use server-provided defaults for new mailings.
authorTim Otten <totten@civicrm.org>
Sun, 8 Feb 2015 23:40:48 +0000 (15:40 -0800)
committerTim Otten <totten@civicrm.org>
Mon, 9 Feb 2015 11:26:50 +0000 (03:26 -0800)
js/angular-crmMailing/services.js
js/angular-crmMailingAB/services.js

index c33a120ea2c0bfdcb1b3ee2dd890d74f4b6b1663..398d6a0582e050eb046720d24938661d85b659e8 100644 (file)
           });
       },
       // @return Object Mailing (per APIv3)
-      create: function create() {
-        return {
+      create: function create(params) {
+        var defaults = {
           jobs: {}, // {jobId: JobRecord}
+          groups: {include: [], exclude: []},
+          mailings: {include: [], exclude: []},
           name: "",
           campaign_id: null,
-          from_name: crmFromAddresses.getDefault().author,
-          from_email: crmFromAddresses.getDefault().email,
           replyto_email: "",
           subject: "",
-          groups: {include: [], exclude: []},
-          mailings: {include: [], exclude: []},
           body_html: "",
-          body_text: "",
-          footer_id: null, // pickDefaultMailComponent('Footer'),
-          header_id: null, // pickDefaultMailComponent('Header'),
-          visibility: "Public Pages",
-          url_tracking: "1",
-          dedupe_email: "1",
-          forward_replies: "0",
-          auto_responder: "0",
-          open_tracking: "1",
-          override_verp: "1",
-          optout_id: pickDefaultMailComponent('OptOut'),
-          reply_id: pickDefaultMailComponent('Reply'),
-          resubscribe_id: pickDefaultMailComponent('Resubscribe'),
-          unsubscribe_id: pickDefaultMailComponent('Unsubscribe')
+          body_text: ""
         };
+        return angular.extend({}, defaults, params);
       },
 
       // @param mailing Object (per APIv3)
index 61e44b468503172a8f76b90d90871245799be3a1..e525e975519a3750180f804d51bcc5f44876ba8a 100644 (file)
             declare_winning_time: null,
             group_percentage: 10
           };
-          crmMailingAB.mailings.a = crmMailingMgr.create();
-          crmMailingAB.mailings.b = crmMailingMgr.create();
-          crmMailingAB.mailings.c = crmMailingMgr.create();
+          var mailingDefaults = {
+            // Most defaults provided by Mailing.create API, but we
+            // want to force-enable tracking.
+            open_tracking: "1",
+            url_tracking: "1"
+          };
+          crmMailingAB.mailings.a = crmMailingMgr.create(mailingDefaults);
+          crmMailingAB.mailings.b = crmMailingMgr.create(mailingDefaults);
+          crmMailingAB.mailings.c = crmMailingMgr.create(mailingDefaults);
           crmMailingAB.attachments.a = new CrmAttachments(function () {
             return {entity_table: 'civicrm_mailing', entity_id: crmMailingAB.ab.mailing_id_a};
           });