CRM-15578 - crmMailingAB2 - Make crmMailingAbBlockMailing more consistent+flexible
authorTim Otten <totten@civicrm.org>
Sun, 14 Dec 2014 21:49:41 +0000 (13:49 -0800)
committerTim Otten <totten@civicrm.org>
Sun, 14 Dec 2014 22:55:41 +0000 (14:55 -0800)
js/angular-crmMailingAB2-services.js
partials/crmMailingAB2/edit.html
partials/crmMailingAB2/joint-mailing.html

index a26897100d6852d0560cb644558ca80e2fc8a408..33d489c819b412bfe2a3a47771211107a87124a7 100644 (file)
     };
   });
 
-  // CrmMailingAB is a data-model which combines an AB test (APIv3 "MailingAB") and three mailings (APIv3 "Mailing").
+  // CrmMailingAB is a data-model which combines an AB test (APIv3 "MailingAB"), three mailings (APIv3 "Mailing"),
+  // and three sets of attachments (APIv3 "Attachment").
+  //
+  // example:
+  //   var abtest = new CrmMailingAB(123);
+  //   abtest.load().then(function(){
+  //     alert("Mailing A is named "+abtest.mailings.a.name);
+  //   });
   angular.module('crmMailingAB2').factory('CrmMailingAB', function (crmApi, crmMailingMgr, $q, CrmAttachments) {
     function CrmMailingAB(id) {
       this.id = id;
index d9eaab3c1fa347a78ff7400277d8062d92cc6cee..e2ed4bd3a5e35c7ca2edc696b2b87ddf1c277d20 100644 (file)
@@ -43,7 +43,8 @@
                 msg_template_id: 1,
                 fromAddressA: 1,
                 fromAddressB: 1,
-                replyTo: 1,
+                replyToA: 1,
+                replyToB: 1,
                 subject: 1
                 }"
               crm-abtest="abtest"></div>
index 18be40636315eecc2820d640231513fedf2d667d..8836c34295a1c5b14281e1f943f3854b3d620862 100644 (file)
@@ -1,10 +1,20 @@
 <!--
-Required vars: abtest
+Required vars: abtest, fields
+
 Note: Much of this file is duplicated in crmMailing and crmMailingAB with variations on placement/title/binding.
 It could perhaps be thinned by 30-60% by making more directives.
+
+This template follows a basic pattern. For each included field, there are three variants, as in this example:
+ - fromAddress: The default From: address shared by both mailings (representatively mapped to mailing A)
+ - fromAddressA: The From: address for mailing A
+ - fromAddressB: The From: address for mailing B
+Each variant is guarded with "ng-if='fields.fieldName'"; if true, the field will be displayed and
+processed by Angular; if false, the field will be hidden and completely ignored by Angular.
 -->
 <div class="crm-block" ng-form="subform" crm-ui-id-scope>
   <div class="crm-group">
+
+
     <div crm-ui-field="subform.msg_template_id" crm-title="ts('Template')" style="background: #bbf; width:100%; padding: 0.1em;" ng-if="fields.msg_template_id">
       <div ng-controller="MsgTemplateCtrl">
         <select
@@ -20,6 +30,38 @@ It could perhaps be thinned by 30-60% by making more directives.
         <a ng-click="saveTemplate(abtest.mailings.a)" class="crm-hover-button action-item" title="{{ts('Save As')}}"><span class="icon ui-icon-disk"></span></a>
       </div>
     </div>
+    <div crm-ui-field="subform.msg_template_idA" crm-title="ts('Template (A)')" style="background: #bbf; width:100%; padding: 0.1em;" ng-if="fields.msg_template_idA">
+      <div ng-controller="MsgTemplateCtrl">
+        <select
+          crm-ui-id="subform.msg_template_idA"
+          name="msg_template_idA"
+          crm-ui-select="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('Message Template')}"
+          ng-model="abtest.mailings.a.msg_template_id"
+          ng-change="loadTemplate(abtest.mailings.a, abtest.mailings.a.msg_template_id)"
+          >
+          <option value=""></option>
+          <option ng-repeat="frm in crmMsgTemplates.getAll() | orderBy:'msg_title'" ng-value="frm.id">{{frm.msg_title}}</option>
+        </select>
+        <a ng-click="saveTemplate(abtest.mailings.a)" class="crm-hover-button action-item" title="{{ts('Save As')}}"><span class="icon ui-icon-disk"></span></a>
+      </div>
+    </div>
+    <div crm-ui-field="subform.msg_template_idB" crm-title="ts('Template (B)')" style="background: #bbf; width:100%; padding: 0.1em;" ng-if="fields.msg_template_idB">
+      <div ng-controller="MsgTemplateCtrl">
+        <select
+          crm-ui-id="subform.msg_template_idB"
+          name="msg_template_idB"
+          crm-ui-select="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('Message Template')}"
+          ng-model="abtest.mailings.b.msg_template_id"
+          ng-change="loadTemplate(abtest.mailings.b, abtest.mailings.b.msg_template_id)"
+          >
+          <option value=""></option>
+          <option ng-repeat="frm in crmMsgTemplates.getAll() | orderBy:'msg_title'" ng-value="frm.id">{{frm.msg_title}}</option>
+        </select>
+        <a ng-click="saveTemplate(abtest.mailings.b)" class="crm-hover-button action-item" title="{{ts('Save As')}}"><span class="icon ui-icon-disk"></span></a>
+      </div>
+    </div>
+
+
     <div crm-ui-field="subform.fromAddress" crm-title="ts('From')" ng-if="fields.fromAddress">
       <span ng-controller="EmailAddrCtrl" crm-mailing-from-address="fromPlaceholder" crm-mailing="abtest.mailings.a">
         <select
@@ -62,6 +104,8 @@ It could perhaps be thinned by 30-60% by making more directives.
         </select>
       </span>
     </div>
+
+
     <div crm-ui-field="subform.replyTo" crm-title="ts('Reply-To')" ng-show="crmMailingConst.enableReplyTo" ng-if="fields.replyTo">
       <span ng-controller="EmailAddrCtrl">
         <select
@@ -76,6 +120,36 @@ It could perhaps be thinned by 30-60% by making more directives.
         </select>
       </span>
     </div>
+    <div crm-ui-field="subform.replyToA" crm-title="ts('Reply-To (A)')" ng-show="crmMailingConst.enableReplyTo" ng-if="fields.replyToA">
+      <span ng-controller="EmailAddrCtrl">
+        <select
+          crm-ui-id="subform.replyToA"
+          name="replyToA"
+          ui-jq="select2"
+          ui-options="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('Email address')}"
+          ng-model="abtest.mailings.a.replyto_email"
+          ng-options="frm.label as frm.label for frm in crmFromAddresses.getAll() | filter:{is_active:1} | orderBy:'weight'"
+          >
+          <option value=""></option>
+        </select>
+      </span>
+    </div>
+    <div crm-ui-field="subform.replyToB" crm-title="ts('Reply-To (B)')" ng-show="crmMailingConst.enableReplyTo" ng-if="fields.replyToB">
+      <span ng-controller="EmailAddrCtrl">
+        <select
+          crm-ui-id="subform.replyToB"
+          name="replyToB"
+          ui-jq="select2"
+          ui-options="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('Email address')}"
+          ng-model="abtest.mailings.b.replyto_email"
+          ng-options="frm.label as frm.label for frm in crmFromAddresses.getAll() | filter:{is_active:1} | orderBy:'weight'"
+          >
+          <option value=""></option>
+        </select>
+      </span>
+    </div>
+
+
     <!--
     <div crm-ui-field="subform.recipients" crm-title="ts('Recipients')">
       <div ng-controller="EditRecipCtrl">
@@ -102,6 +176,8 @@ It could perhaps be thinned by 30-60% by making more directives.
       </div>
     </div>
     -->
+
+
     <div crm-ui-field="subform.subject" crm-title="ts('Subject')" ng-if="fields.subject">
       <div style="float: right;">
         <input crm-mailing-token crm-for="subject" />