| 1 | (function (angular, $, _) { |
| 2 | |
| 3 | angular.module('crmMailing', [ |
| 4 | 'crmUtil', 'crmAttachment', 'crmAutosave', 'ngRoute', 'ui.utils', 'crmUi', 'dialogService' |
| 5 | ]); |
| 6 | |
| 7 | angular.module('crmMailing').config([ |
| 8 | '$routeProvider', |
| 9 | function ($routeProvider) { |
| 10 | $routeProvider.when('/mailing', { |
| 11 | template: '<div></div>', |
| 12 | controller: 'ListMailingsCtrl' |
| 13 | }); |
| 14 | |
| 15 | if (!CRM || !CRM.crmMailing) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | $routeProvider.when('/mailing/new', { |
| 20 | template: '<p>' + ts('Initializing...') + '</p>', |
| 21 | controller: 'CreateMailingCtrl', |
| 22 | resolve: { |
| 23 | selectedMail: function(crmMailingMgr) { |
| 24 | var m = crmMailingMgr.create({ |
| 25 | template_type: CRM.crmMailing.templateTypes[0].name |
| 26 | }); |
| 27 | return crmMailingMgr.save(m); |
| 28 | } |
| 29 | } |
| 30 | }); |
| 31 | |
| 32 | $routeProvider.when('/mailing/new/:templateType', { |
| 33 | template: '<p>' + ts('Initializing...') + '</p>', |
| 34 | controller: 'CreateMailingCtrl', |
| 35 | resolve: { |
| 36 | selectedMail: function($route, crmMailingMgr) { |
| 37 | var m = crmMailingMgr.create({ |
| 38 | template_type: $route.current.params.templateType |
| 39 | }); |
| 40 | return crmMailingMgr.save(m); |
| 41 | } |
| 42 | } |
| 43 | }); |
| 44 | |
| 45 | $routeProvider.when('/mailing/:id', { |
| 46 | templateUrl: '~/crmMailing/EditMailingCtrl/base.html', |
| 47 | controller: 'EditMailingCtrl', |
| 48 | resolve: { |
| 49 | selectedMail: function($route, crmMailingMgr) { |
| 50 | return crmMailingMgr.get($route.current.params.id); |
| 51 | }, |
| 52 | attachments: function($route, CrmAttachments) { |
| 53 | var attachments = new CrmAttachments(function () { |
| 54 | return {entity_table: 'civicrm_mailing', entity_id: $route.current.params.id}; |
| 55 | }); |
| 56 | return attachments.load(); |
| 57 | } |
| 58 | } |
| 59 | }); |
| 60 | } |
| 61 | ]); |
| 62 | |
| 63 | })(angular, CRM.$, CRM._); |