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);
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);
});
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
}"
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,
}"
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,
<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
</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>
<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>
<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>
<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>