Commit | Line | Data |
---|---|---|
030dce01 | 1 | (function (angular, $, _) { |
030dce01 | 2 | |
88e9e883 | 3 | angular.module('crmMailing', [ |
8443385d | 4 | 'crmUtil', 'crmAttachment', 'crmAutosave', 'ngRoute', 'ui.utils', 'crmUi', 'dialogService' |
882e1558 | 5 | ]); |
030dce01 | 6 | |
88e9e883 | 7 | angular.module('crmMailing').config([ |
f4f103fa | 8 | '$routeProvider', |
030dce01 | 9 | function ($routeProvider) { |
96ac27bd | 10 | $routeProvider.when('/mailing', { |
030dce01 TO |
11 | template: '<div></div>', |
12 | controller: 'ListMailingsCtrl' | |
13 | }); | |
b7c3beb2 | 14 | |
3ac6e107 TO |
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 | } | |
c0e89319 | 29 | } |
3ac6e107 TO |
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); | |
f4f103fa | 41 | } |
3ac6e107 TO |
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(); | |
f4f103fa | 57 | } |
3ac6e107 | 58 | } |
030dce01 TO |
59 | }); |
60 | } | |
61 | ]); | |
62 | ||
030dce01 | 63 | })(angular, CRM.$, CRM._); |