(function (angular, $, _) {
- angular.module('crmMailingAB', ['ngRoute', 'ui.utils', 'ngSanitize', 'crmUi', 'crmAttachment', 'crmMailing', 'crmD3']);
+ angular.module('crmMailingAB', ['ngRoute', 'ui.utils', 'crmUi', 'crmAttachment', 'crmMailing', 'crmD3']);
angular.module('crmMailingAB').config([
'$routeProvider',
function ($routeProvider) {
}
});
$routeProvider.when('/abtest/:id', {
- templateUrl: '~/crmMailingAB/edit.html',
+ templateUrl: '~/crmMailingAB/main.html',
controller: 'CrmMailingABEditCtrl',
resolve: {
abtest: function ($route, CrmMailingAB) {
}
}
});
- $routeProvider.when('/abtest/:id/report', {
- templateUrl: '~/crmMailingAB/report.html',
- controller: 'CrmMailingABReportCtrl',
- resolve: {
- abtest: function ($route, CrmMailingAB) {
- var abtest = new CrmMailingAB($route.current.params.id);
- return abtest.load();
- }
- }
- });
}
]);
$scope.sync = function sync() {
abtest.mailings.a.name = ts('Test A (%1)', {1: abtest.ab.name});
abtest.mailings.b.name = ts('Test B (%1)', {1: abtest.ab.name});
- abtest.mailings.c.name = ts('Winner (%1)', {1: abtest.ab.name});
+ abtest.mailings.c.name = ts('Final (%1)', {1: abtest.ab.name});
if (abtest.ab.testing_criteria) {
// TODO review fields exposed in UI and make sure the sync rules match
};
var options = CRM.utils.adjustDialogDefaults({
autoOpen: false,
- title: ts('Select Winner (%1)', {
+ title: ts('Select Final Mailing (Test %1)', {
1: mailingName.toUpperCase()
})
});
angular.module('crmMailingAB').controller('CrmMailingABReportCtrl', function ($scope, crmApi, crmMailingStats) {
var ts = $scope.ts = CRM.ts(null);
+ var CrmMailingABReportCnt = 1, activeMailings = null;
+ $scope.getActiveMailings = function() {
+ if ($scope.abtest.$CrmMailingABReportCnt != CrmMailingABReportCnt) {
+ $scope.abtest.$CrmMailingABReportCnt = ++CrmMailingABReportCnt;
+ activeMailings = [
+ {name: 'a', title: ts('Mailing A'), mailing: $scope.abtest.mailings.a, attachments: $scope.abtest.attachments.a},
+ {name: 'b', title: ts('Mailing B'), mailing: $scope.abtest.mailings.b, attachments: $scope.abtest.attachments.b}
+ ];
+ if ($scope.abtest.ab.status == 'Final') {
+ activeMailings.push({name: 'c', title: ts('Final'), mailing: $scope.abtest.mailings.c, attachments: $scope.abtest.attachments.c});
+ }
+ }
+ return activeMailings;
+ };
+
crmMailingStats.getStats({
a: $scope.abtest.ab.mailing_id_a,
b: $scope.abtest.ab.mailing_id_b,
$scope.statTypes = crmMailingStats.getStatTypes();
$scope.statUrl = function statUrl(mailing, statType, view) {
- return crmMailingStats.getUrl(mailing, statType, view);
+ return crmMailingStats.getUrl(mailing, statType, view, 'abtest/' + $scope.abtest.ab.id);
};
+
+ $scope.checkPerm = CRM.checkPerm;
});
angular.module('crmMailingAB').controller('CrmMailingABWinnerDialogCtrl', function ($scope, $timeout, dialogService, crmMailingMgr, crmStatus) {
// need to be registered with the dialog widget (and not embedded in
// the body of the dialog).
var buttons = {};
- buttons[ts('Select Winner')] = function () {
+ buttons[ts('Submit final mailing')] = function () {
crmMailingMgr.mergeInto(abtest.mailings.c, abtest.mailings[mailingName], [
'name',
'recipients',
crmStatus({start: ts('Saving...'), success: ''}, abtest.save())
.then(function () {
return crmStatus({start: ts('Submitting...'), success: ts('Submitted')},
- abtest.submitFinal().then(function(){
- return abtest.load();
+ abtest.submitFinal().then(function(r){
+ delete abtest.$CrmMailingABReportCnt;
+ return r;
}));
})
.then(function(){