CRM-15578 - crmMailingAB - Improve listing
authorTim Otten <totten@civicrm.org>
Sat, 20 Dec 2014 08:50:48 +0000 (00:50 -0800)
committerTim Otten <totten@civicrm.org>
Sat, 20 Dec 2014 12:52:29 +0000 (04:52 -0800)
 * Translate strings
 * Remove unused help section
 * Display status

js/angular-crmMailingAB.js
js/angular-crmMailingAB/services.js
partials/crmMailingAB/list.html

index c9c5030929e6ef3f7c86a052ad0ef29fe136c89c..ea8839f2938259165d3ec72fcc500059f580dca3 100644 (file)
     }
   ]);
 
-  angular.module('crmMailingAB').controller('CrmMailingABListCtrl', function ($scope, mailingABList, crmMailingABCriteria) {
+  angular.module('crmMailingAB').controller('CrmMailingABListCtrl', function ($scope, mailingABList, crmMailingABCriteria, crmMailingABStatus) {
+    var ts = $scope.ts = CRM.ts('CiviMail');
     $scope.mailingABList = mailingABList.values;
-    $scope.testing_criteria = crmMailingABCriteria.getAll();
+    $scope.crmMailingABCriteria = crmMailingABCriteria;
+    $scope.crmMailingABStatus = crmMailingABStatus;
   });
 
   angular.module('crmMailingAB').controller('CrmMailingABEditCtrl', function ($scope, abtest, crmMailingABCriteria, crmMailingMgr, crmMailingPreviewMgr, crmStatus, $q, $location) {
index 345b52abea6203177357a0d76c6dc1be12c3fac0..c602fda731369d216869782417ac11fe3dd5774e 100644 (file)
@@ -1,5 +1,19 @@
 (function (angular, $, _) {
 
+  function OptionGroup(values) {
+    this.get = function get(value) {
+      var r = _.where(values, {value: '' + value});
+      return r.length > 0 ? r[0] : null;
+    };
+    this.getByName = function get(name) {
+      var r = _.where(values, {name: '' + name});
+      return r.length > 0 ? r[0] : null;
+    };
+    this.getAll = function getAll() {
+      return values;
+    };
+  }
+
   angular.module('crmMailingAB').factory('crmMailingABCriteria', function () {
     // TODO Get data from server
     var values = {
       '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')}
     };
-    return {
-      get: function get(value) {
-        var r = _.where(values, {value: '' + value});
-        return r.length > 0 ? r[0] : null;
-      },
-      getAll: function getAll() {
-        return values;
-      }
+    return new OptionGroup(values);
+  });
+
+  angular.module('crmMailingAB').factory('crmMailingABStatus', function () {
+    // TODO Get data from server
+    var values = {
+      '1': {value: '1', name: 'Draft', label: ts('Draft')},
+      '2': {value: '2', name: 'Testing', label: ts('Testing')},
+      '3': {value: '3', name: 'Final', label: ts('Final')}
     };
+    return new OptionGroup(values);
   });
 
   // CrmMailingAB is a data-model which combines an AB test (APIv3 "MailingAB"), three mailings (APIv3 "Mailing"),
index 780a3454c48b8dd111b136c412e10e3778cb394e..67b987257c7c3fb75841d42c06d0c44ee3a23d96 100644 (file)
@@ -2,29 +2,25 @@
 Controller: ABListingCtrl
 Required vars: mailingABList
 -->
-<div id="help">
-  A/B Testing list
-</div>
 
 <div ng-show="!$.isEmptyObject(mailingABList)">
   <table class="display">
     <thead>
     <tr>
-      <th>Title</th>
-      <th>Id</th>
-      <th>Test Type</th>
-      <th></th>
+      <th>{{ts('Name')}}</th>
+      <th>{{ts('Status')}}</th>
+      <th>{{ts('Test Type')}}</th>
       <th></th>
     </tr>
     </thead>
     <tbody>
     <tr ng-repeat="mailingAB in mailingABList">
       <td>{{mailingAB.name}}</td>
-      <td>{{mailingAB.id}}</td>
-      <td>{{testing_criteria[mailingAB.testing_criteria_id].label}}</td>
+      <td>{{crmMailingABStatus.getByName(mailingAB.status).label}}</td>
+      <td>{{crmMailingABCriteria.get(mailingAB.testing_criteria_id).label}}</td>
       <td>
-        <a class="action-item crm-hover-button" ng-href="#/abtest/{{mailingAB.id}}">Edit</a>&nbsp
-        <a class="action-item crm-hover-button" ng-href="#/abtest/report/{{mailingAB.id}}">Results</a>
+        <a class="action-item crm-hover-button" ng-href="#/abtest/{{mailingAB.id}}" ng-show="mailingAB.status == 'Draft'">{{ts('Continue')}}</a>
+        <a class="action-item crm-hover-button" ng-href="#/abtest/{{mailingAB.id}}/report" ng-show="mailingAB.status != 'Draft'">{{ts('Results')}}</a>
       </td>
     </tr>
     </tbody>
@@ -33,11 +29,11 @@ Required vars: mailingABList
 
 <div ng-show="$.isEmptyObject(mailingABList)" class="messages status no-popup">
   <div class="icon inform-icon"></div>
-  You have no A/B mailings
+  {{ts('You have no A/B mailings')}}
 </div>
 
 
 <div class="crm-submit-buttons">
   <br>
-  <a ng-href="#/abtest/new" class="button"><span><div class="icon add-icon"></div>New A/B Test</span></a>
+  <a ng-href="#/abtest/new" class="button"><span><div class="icon add-icon"></div>{{ts('New A/B Test')}}</span></a>
 </div>