diff options
Diffstat (limited to 'www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js')
-rw-r--r-- | www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js b/www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js new file mode 100644 index 00000000..f378f641 --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js @@ -0,0 +1,43 @@ +(function(angular, $, _) { + + angular.module('crmMailingAB').controller('CrmMailingABWinnerDialogCtrl', function($scope, $timeout, dialogService, crmMailingMgr, crmStatus) { + var ts = $scope.ts = CRM.ts(null); + var abtest = $scope.abtest = $scope.model.abtest; + var mailingName = $scope.model.mailingName; + + var titles = {a: ts('Mailing A'), b: ts('Mailing B')}; + $scope.mailingTitle = titles[mailingName]; + + function init() { + // When using dialogService with a button bar, the major button actions + // need to be registered with the dialog widget (and not embedded in + // the body of the dialog). + var buttons = [ + { + text: ts('Submit final mailing'), + icons: {primary: 'fa-paper-plane'}, + click: function() { + crmStatus({start: ts('Submitting...'), success: ts('Submitted')}, + abtest.submitFinal(abtest.mailings[mailingName].id).then(function (r) { + delete abtest.$CrmMailingABReportCnt; + })) + .then(function () { + dialogService.close('selectWinnerDialog', abtest); + }); + } + }, + { + text: ts('Cancel'), + icons: {primary: 'fa-times'}, + click: function() { + dialogService.cancel('selectWinnerDialog'); + } + } + ]; + dialogService.setButtons('selectWinnerDialog', buttons); + } + + $timeout(init); + }); + +})(angular, CRM.$, CRM._); |