Merge pull request #19677 from totten/master-joomla-syncuser
[civicrm-core.git] / ang / crmMailing.js
CommitLineData
030dce01 1(function (angular, $, _) {
030dce01 2
0b199194 3 angular.module('crmMailing', CRM.angRequires('crmMailing'));
030dce01 4
88e9e883 5 angular.module('crmMailing').config([
f4f103fa 6 '$routeProvider',
030dce01 7 function ($routeProvider) {
96ac27bd 8 $routeProvider.when('/mailing', {
030dce01
TO
9 template: '<div></div>',
10 controller: 'ListMailingsCtrl'
11 });
b7c3beb2 12
3ac6e107
TO
13 if (!CRM || !CRM.crmMailing) {
14 return;
15 }
16
17 $routeProvider.when('/mailing/new', {
18 template: '<p>' + ts('Initializing...') + '</p>',
19 controller: 'CreateMailingCtrl',
20 resolve: {
21 selectedMail: function(crmMailingMgr) {
22 var m = crmMailingMgr.create({
23 template_type: CRM.crmMailing.templateTypes[0].name
24 });
25 return crmMailingMgr.save(m);
26 }
c0e89319 27 }
3ac6e107
TO
28 });
29
30 $routeProvider.when('/mailing/new/:templateType', {
31 template: '<p>' + ts('Initializing...') + '</p>',
32 controller: 'CreateMailingCtrl',
33 resolve: {
34 selectedMail: function($route, crmMailingMgr) {
35 var m = crmMailingMgr.create({
36 template_type: $route.current.params.templateType
37 });
38 return crmMailingMgr.save(m);
f4f103fa 39 }
3ac6e107
TO
40 }
41 });
42
43 $routeProvider.when('/mailing/:id', {
44 templateUrl: '~/crmMailing/EditMailingCtrl/base.html',
45 controller: 'EditMailingCtrl',
46 resolve: {
47 selectedMail: function($route, crmMailingMgr) {
48 return crmMailingMgr.get($route.current.params.id);
49 },
12f3f181
TO
50 mailingFields: function(crmMetadata) {
51 return crmMetadata.getFields('Mailing');
52 },
3ac6e107
TO
53 attachments: function($route, CrmAttachments) {
54 var attachments = new CrmAttachments(function () {
55 return {entity_table: 'civicrm_mailing', entity_id: $route.current.params.id};
56 });
57 return attachments.load();
f4f103fa 58 }
3ac6e107 59 }
030dce01
TO
60 });
61 }
62 ]);
63
030dce01 64})(angular, CRM.$, CRM._);