CRM-15970 - crmMailingAB - Use new testing_criteria and winner_criteria fields
authorTim Otten <totten@civicrm.org>
Wed, 18 Feb 2015 01:30:09 +0000 (17:30 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 18 Feb 2015 03:13:14 +0000 (19:13 -0800)
js/angular-crmMailingAB.js
js/angular-crmMailingAB/services.js
partials/crmMailingAB/edit.html
partials/crmMailingAB/list.html
partials/crmMailingAB/setup.html

index c5861d45ff2fd55143aa937935a3399bfd1ffbf3..0cacb6c974b9a8ac167f34b37a314051328cb342 100644 (file)
       abtest.mailings.b.name = ts('Test B (%1)', {1: abtest.ab.name});
       abtest.mailings.c.name = ts('Winner (%1)', {1: abtest.ab.name});
 
-      var criteria = crmMailingABCriteria.get(abtest.ab.testing_criteria_id);
-      if (criteria) {
+      if (abtest.ab.testing_criteria) {
         // TODO review fields exposed in UI and make sure the sync rules match
-        switch (criteria.name) {
-          case 'Subject lines':
+        switch (abtest.ab.testing_criteria) {
+          case 'subject':
             crmMailingMgr.mergeInto(abtest.mailings.b, abtest.mailings.a, [
               'name',
               'recipients',
               'subject'
             ]);
             break;
-          case 'From names':
+          case 'from':
             crmMailingMgr.mergeInto(abtest.mailings.b, abtest.mailings.a, [
               'name',
               'recipients',
               'from_email'
             ]);
             break;
-          case 'Two different emails':
+          case 'full_email':
             crmMailingMgr.mergeInto(abtest.mailings.b, abtest.mailings.a, [
               'name',
               'recipients',
       $location.replace();
     };
 
-    function updateCriteriaName() {
-      var criteria = crmMailingABCriteria.get($scope.abtest.ab.testing_criteria_id);
-      $scope.criteriaName = criteria ? criteria.name : null;
-    }
-
     // initialize
-    updateCriteriaName();
-    $scope.$watch('abtest.ab.testing_criteria_id', updateCriteriaName);
     var syncJob = $interval($scope.sync, 333);
     $scope.$on('$destroy', function(){
       $interval.cancel(syncJob);
index 04c1e480a4fdb9221af47444b5d1d37de540712a..955ba954ce6e58fd7828f1bd602b8a7699dc99b3 100644 (file)
@@ -17,9 +17,9 @@
   angular.module('crmMailingAB').factory('crmMailingABCriteria', function () {
     // TODO Get data from server
     var values = {
-      '1': {value: '1', name: 'Subject lines', label: ts('Test different "Subject" lines')},
-      '2': {value: '2', name: 'From names', label: ts('Test different "From" lines')},
-      '3': {value: '3', name: 'Two different emails', label: ts('Test entirely different emails')}
+      '1': {value: 'subject', name: 'subject', label: ts('Test different "Subject" lines')},
+      '2': {value: 'from', name: 'from', label: ts('Test different "From" lines')},
+      '3': {value: 'full_email', name: 'full_email', label: ts('Test entirely different emails')}
     };
     return new OptionGroup(values);
   });
@@ -70,8 +70,8 @@
             mailing_id_b: null,
             mailing_id_c: null,
             domain_id: null,
-            testing_criteria_id: 1, // FIXME
-            winner_criteria_id: null,
+            testing_criteria: 'subject',
+            winner_criteria: null,
             specific_url: '',
             declare_winning_time: null,
             group_percentage: 10
index ee1af5c66741cd9b8b97d49a79361bf3702bbc59..aafb88fb6c7437a13db0345c4a00213fe5267f83 100644 (file)
           }"
           crm-abtest="abtest"></div>
       </div>
-      <div crm-ui-wizard-step="20" crm-title="ts('Compose')" ng-if="criteriaName != 'Two different emails'" ng-form="composeForm">
+      <div crm-ui-wizard-step="20" crm-title="ts('Compose')" ng-if="abtest.ab.testing_criteria != 'full_email'" ng-form="composeForm">
         <div crm-ui-tab-set>
           <div crm-ui-tab id="tab-mailing" crm-title="ts('Mailing')">
             <div
-              ng-if="criteriaName == 'From names'"
+              ng-if="abtest.ab.testing_criteria == 'from'"
               crm-mailing-ab-block-mailing="{
                 msg_template_id: 1,
                 fromAddressA: 1,
@@ -47,7 +47,7 @@
                 }"
               crm-abtest="abtest"></div>
             <div
-              ng-if="criteriaName == 'Subject lines'"
+              ng-if="abtest.ab.testing_criteria == 'subject'"
               crm-mailing-ab-block-mailing="{
                 msg_template_id: 1,
                 fromAddress: 1,
@@ -87,7 +87,7 @@
           <div crm-mailing-block-preview crm-mailing="abtest.mailings.b" on-preview="previewMailing('b', preview.mode)" on-send="sendTest('b', preview.recipient)" />
         </div>
       </div>
-      <div crm-ui-wizard-step="21" crm-title="ts('Compose (A)')" ng-if="criteriaName == 'Two different emails'" ng-form="composeAForm">
+      <div crm-ui-wizard-step="21" crm-title="ts('Compose (A)')" ng-if="abtest.ab.testing_criteria == 'full_email'" ng-form="composeAForm">
         <div crm-ui-tab-set>
           <div crm-ui-tab id="tab-mailingA" crm-title="ts('Mailing')">
             <div
           <div crm-mailing-block-preview crm-mailing="abtest.mailings.a" on-preview="previewMailing('a', preview.mode)" on-send="sendTest('a', preview.recipient)" />
         </div>
       </div>
-      <div crm-ui-wizard-step="22" crm-title="ts('Compose (B)')" ng-if="criteriaName == 'Two different emails'" ng-form="composeBForm">
+      <div crm-ui-wizard-step="22" crm-title="ts('Compose (B)')" ng-if="abtest.ab.testing_criteria == 'full_email'" ng-form="composeBForm">
         <div crm-ui-tab-set>
           <div crm-ui-tab id="tab-mailingB" crm-title="ts('Mailing')">
             <div
index a59ce9fa8dc325e3350b805476519f8b9c46d35b..66b35b6996dfcad3da26bf745abfd607c6c4c531 100644 (file)
@@ -17,9 +17,9 @@ Required vars: mailingABList
       </select>
     </span>
     <span>
-      <select crm-ui-select style="width: 20em;" ng-model="filter.testing_criteria_id">
+      <select crm-ui-select style="width: 20em;" ng-model="filter.testing_criteria">
         <option value="">{{ts('- Test Type -')}}</option>
-        <option ng-repeat="o in fields.testing_criteria_id.options" ng-value="o.key">{{crmMailingABCriteria.get(o.key).label}}</option>
+        <option ng-repeat="o in fields.testing_criteria.options" ng-value="o.key">{{o.value}}</option>
       </select>
     </span>
   </form>
@@ -31,7 +31,7 @@ Required vars: mailingABList
     <tr>
       <th><a crm-ui-order-by="[myOrder, 'name']">{{ts('Name')}}</a></th>
       <th><a crm-ui-order-by="[myOrder, 'status']">{{ts('Status')}}</a></th>
-      <th><a crm-ui-order-by="[myOrder, 'testing_criteria_id']">{{ts('Test Type')}}</a></th>
+      <th><a crm-ui-order-by="[myOrder, 'testing_criteria']">{{ts('Test Type')}}</a></th>
       <th><a crm-ui-order-by="[myOrder, 'created_date']">{{ts('Created')}}</a></th>
       <th></th>
     </tr>
@@ -40,7 +40,7 @@ Required vars: mailingABList
     <tr ng-repeat="mailingAB in mailingABList | filter:filter | orderBy:myOrder.get()">
       <td>{{mailingAB.name}}</td>
       <td>{{crmMailingABStatus.getByName(mailingAB.status).label}}</td>
-      <td>{{crmMailingABCriteria.get(mailingAB.testing_criteria_id).label}}</td>
+      <td>{{crmMailingABCriteria.get(mailingAB.testing_criteria).label}}</td>
       <td>{{mailingAB.created_date}}</td>
       <td>
         <a class="action-item crm-hover-button" ng-href="#/abtest/{{mailingAB.id}}" ng-show="mailingAB.status == 'Draft'">{{ts('Continue')}}</a>
index 1778057e356cbe4ab85fdd704169acee7d4f4c03..2b15e66ca536c3c374bfd10c03f13c9155efb193 100644 (file)
@@ -29,7 +29,7 @@
     <div crm-ui-field crm-title="ts('Test Type')" ng-if="fields.testing_criteria">
       <div ng-repeat="criteria in crmMailingABCriteria.getAll()">
         <label>
-          <input name="testing_critiria" ng-model="abtest.ab.testing_criteria_id" type="radio"
+          <input name="testing_criteria" ng-model="abtest.ab.testing_criteria" type="radio"
                  value="{{criteria.value}}" required/>
           {{criteria.label}}
         </label>