CRM-15578 - crmMailing2 - Skeleton for new page
authorTim Otten <totten@civicrm.org>
Thu, 30 Oct 2014 02:15:11 +0000 (19:15 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 11 Nov 2014 00:19:25 +0000 (16:19 -0800)
14 files changed:
CRM/Mailing/Info.php
js/angular-crm-ui.js
js/angular-crmMailing2.js [new file with mode: 0644]
partials/crmMailing2/attachments.html [new file with mode: 0644]
partials/crmMailing2/edit.html [new file with mode: 0644]
partials/crmMailing2/headerFooter.html [new file with mode: 0644]
partials/crmMailing2/mailing.html [new file with mode: 0644]
partials/crmMailing2/preview.html [new file with mode: 0644]
partials/crmMailing2/publication.html [new file with mode: 0644]
partials/crmMailing2/responses.html [new file with mode: 0644]
partials/crmMailing2/review.html [new file with mode: 0644]
partials/crmMailing2/schedule.html [new file with mode: 0644]
partials/crmMailing2/summary.html [new file with mode: 0644]
partials/crmMailing2/tracking.html [new file with mode: 0644]

index 7eb682851f02c93f2e32f1b7b5ee95ac2ab38c59..d8d9a2ac0ddf793093b86af6bb2cb65ea5b4987b 100644 (file)
@@ -59,7 +59,15 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
     $result = array();
     $result['crmMailing'] = array(
       'ext' => 'civicrm',
-      'js' => array('js/angular-Mailing.js' , 'js/angularsanitize.js' , 'packages/ckeditor/ckeditor.js'),
+      'js' => array(
+        'js/angular-Mailing.js' ,
+        'js/angularsanitize.js' ,
+        'packages/ckeditor/ckeditor.js'
+       ),
+    );
+    $result['crmMailing2'] = array(
+      'ext' => 'civicrm',
+      'js' => array('js/angular-crmMailing2.js'),
     );
     $result['crmMailingAB'] = array(
       'ext' => 'civicrm',
index 793750e8d202dad848b4b47a744215e5927f72c5..502db3791960d4be6c16768b03de7955bd92b06a 100644 (file)
@@ -3,6 +3,19 @@
   var idCount = 0;
 
   angular.module('crmUi', [])
+
+    // example <div crm-ui-accordion crm-title="ts('My Title')">...content...</div>
+    .directive('crmUiAccordion', function() {
+      return {
+        scope: {
+          crmTitle: '@'
+        },
+        template: '<div><b>(Accordion: {{$parent.$eval(crmTitle)}})</b><span ng-transclude/></div>',
+        transclude: true,
+        link: function (scope, element, attrs) {}
+      };
+    })
+
     // example: <form name="myForm">...<label crm-ui-label crm-for="myField">My Field</span>...<input name="myField"/>...</form>
     //
     // Label adapts based on <input required>, <input ng-required>, or any other validation.
         }
       };
     })
+
+    // example <div crm-ui-tab crm-title="ts('My Title')">...content...</div>
+    .directive('crmUiTab', function($parse) {
+      return {
+        scope: {
+          crmTitle: '@'
+        },
+        template: '<div><b>(Tab: {{$parent.$eval(crmTitle)}})</b><span ng-transclude/></div>',
+        transclude: true,
+        link: function (scope, element, attrs) {}
+      };
+    })
+
+    // example: <div crm-ui-tab-set><div crm-ui-tab crm-title="Tab 1">...</div><div crm-ui-tab crm-title="Tab 2">...</div></div>
+    .directive('crmUiTabSet', function() {
+      return {
+        template: '<div><span ng-transclude/></div>',
+        transclude: true,
+        link: function (scope, element, attrs) {}
+      };
+    })
+
+    // example: <div crm-ui-wizard><div crm-ui-wizard-step crm-title="Step 1">...</div><div crm-ui-wizard-step crm-title="Step 2">...</div></div>
+    .directive('crmUiWizard', function() {
+      return {
+        template: '<div><span ng-transclude/></div>',
+        transclude: true,
+        link: function (scope, element, attrs) {}
+      };
+    })
+
+    .directive('crmUiWizardFooter', function() {
+      return {
+        template: '<div><span ng-transclude/></div>',
+        transclude: true,
+        link: function (scope, element, attrs) {}
+      };
+    })
+
+    // example <div crm-ui-wizard-step crm-title="ts('My Title')">...content...</div>
+    .directive('crmUiWizardStep', function() {
+      return {
+        scope: {
+          crmTitle: '@'
+        },
+        template: '<div><b>(Step: {{$parent.$eval(crmTitle)}})</b><span ng-transclude/></div>',
+        transclude: true,
+        link: function (scope, element, attrs) {}
+      };
+    })
+
     // Example: <button crm-confirm="{message: ts('Are you sure you want to continue?')}" on-yes="frobnicate(123)">Frobincate</button>
     // Example: <button crm-confirm="{type: 'disable', obj: myObject}" on-yes="myObject.is_active=0; myObject.save()">Disable</button>
     .directive('crmConfirm', function () {
diff --git a/js/angular-crmMailing2.js b/js/angular-crmMailing2.js
new file mode 100644 (file)
index 0000000..d017a84
--- /dev/null
@@ -0,0 +1,59 @@
+(function (angular, $, _) {
+  var partialUrl = function (relPath) {
+    return CRM.resourceUrls['civicrm'] + '/partials/crmMailing2/' + relPath;
+  };
+
+  var crmMailing2 = angular.module('crmMailing2', ['ngRoute', 'ui.utils', 'crmUi']); // TODO ngSanitize, unsavedChanges
+
+  /**
+   * Initialize a new mailing
+   * TODO Move to separate file or service
+   */
+  var createMailing = function () {
+    return {
+      visibility: "Public Pages",
+      url_tracking: "1",
+      dedupe_email: "1",
+      forward_replies: "0",
+      auto_responder: "0",
+      open_tracking: "1"
+    };
+  };
+
+  crmMailing2.config(['$routeProvider',
+    function ($routeProvider) {
+      $routeProvider.when('/mailing2', {
+        template: '<div></div>',
+        controller: 'ListMailingsCtrl'
+      });
+
+      $routeProvider.when('/mailing2/:id', {
+        templateUrl: partialUrl('edit.html'),
+        controller: 'EditMailingCtrl',
+        resolve: {
+          selectedMail: function ($route, crmApi) {
+            return ($route.current.params.id == 'new')
+                    ? createMailing()
+                    : crmApi('Mailing', 'getsingle', {id: $route.current.params.id});
+          }
+        }
+      });
+    }
+  ]);
+
+  crmMailing2.controller('ListMailingsCtrl', function ($scope) {
+    // We haven't implemented this in Angular, but some users may get clever
+    // about typing URLs, so we'll provide a redirect.
+    window.location = CRM.url('civicrm/mailing/browse/unscheduled', {
+      reset: 1,
+      scheduled: 'false'
+    });
+  });
+
+  crmMailing2.controller('EditMailingCtrl', function ($scope, selectedMail) {
+    $scope.partialUrl = partialUrl;
+    $scope.ts = CRM.ts('CiviMail');
+    $scope.deleteMe = 'deleteMe';
+  });
+
+})(angular, CRM.$, CRM._);
diff --git a/partials/crmMailing2/attachments.html b/partials/crmMailing2/attachments.html
new file mode 100644 (file)
index 0000000..24728b0
--- /dev/null
@@ -0,0 +1 @@
+attachments.html
diff --git a/partials/crmMailing2/edit.html b/partials/crmMailing2/edit.html
new file mode 100644 (file)
index 0000000..35bafd9
--- /dev/null
@@ -0,0 +1,47 @@
+<div crm-ui-wizard>
+  <div crm-ui-wizard-step crm-title="ts('Define Mailing')">
+    <div crm-ui-accordion crm-title="ts('Summary')">
+      <div ng-include="partialUrl('summary.html')" />
+    </div>
+    <div crm-ui-tabset>
+      <div crm-ui-tab crm-title="ts('Mailing')">
+        <div ng-include="partialUrl('mailing.html')" />
+      </div>
+      <div crm-ui-tab crm-title="ts('Attachments')">
+        <div ng-include="partialUrl('attachments.html')" />
+      </div>
+      <div crm-ui-tab crm-title="ts('Header and Footer')">
+        <div ng-include="partialUrl('headerFooter.html')" />
+      </div>
+      <div crm-ui-tab crm-title="ts('Publication')">
+        <div ng-include="partialUrl('publication.html')" />
+      </div>
+      <div crm-ui-tab crm-title="ts('Responses')">
+        <div ng-include="partialUrl('responses.html')" />
+      </div>
+      <div crm-ui-tab crm-title="ts('Tracking')">
+        <div ng-include="partialUrl('tracking.html')" />
+      </div>
+    </div>
+    <div crm-ui-accordion crm-title="ts('Preview')">
+      <div ng-include="partialUrl('preview.html')" />
+    </div>
+  </div>
+  <div crm-ui-wizard-step crm-title="ts('Review and Schedule')">
+    <div crm-ui-accordion crm-title="ts('Review')">
+      <div ng-include="partialUrl('review.html')" />
+    </div>
+    <div crm-ui-accordion crm-title="ts('Schedule')">
+      <div ng-include="partialUrl('schedule.html')" />
+      <button ng-click="mailing.send();
+                gotoListing();">Schedule</button>
+    </div>
+  </div>
+  <div crm-ui-wizard-footer>
+    <button ng-click="mailing.save();
+              gotoListing();">Save Draft</button>
+    <button ng-click="mailing.destroy();
+              gotoListing();">Abort</button>
+  </div>
+
+</div>
diff --git a/partials/crmMailing2/headerFooter.html b/partials/crmMailing2/headerFooter.html
new file mode 100644 (file)
index 0000000..a2373a1
--- /dev/null
@@ -0,0 +1 @@
+headerFooter.html
diff --git a/partials/crmMailing2/mailing.html b/partials/crmMailing2/mailing.html
new file mode 100644 (file)
index 0000000..7b52c8f
--- /dev/null
@@ -0,0 +1 @@
+mailing.html
diff --git a/partials/crmMailing2/preview.html b/partials/crmMailing2/preview.html
new file mode 100644 (file)
index 0000000..64d9145
--- /dev/null
@@ -0,0 +1 @@
+preview.html
diff --git a/partials/crmMailing2/publication.html b/partials/crmMailing2/publication.html
new file mode 100644 (file)
index 0000000..8bd61f0
--- /dev/null
@@ -0,0 +1 @@
+publication.html
diff --git a/partials/crmMailing2/responses.html b/partials/crmMailing2/responses.html
new file mode 100644 (file)
index 0000000..07753eb
--- /dev/null
@@ -0,0 +1 @@
+responses.html
diff --git a/partials/crmMailing2/review.html b/partials/crmMailing2/review.html
new file mode 100644 (file)
index 0000000..f31aa79
--- /dev/null
@@ -0,0 +1 @@
+review.html
diff --git a/partials/crmMailing2/schedule.html b/partials/crmMailing2/schedule.html
new file mode 100644 (file)
index 0000000..1f9d4e7
--- /dev/null
@@ -0,0 +1 @@
+schedule.html
diff --git a/partials/crmMailing2/summary.html b/partials/crmMailing2/summary.html
new file mode 100644 (file)
index 0000000..67ba0a4
--- /dev/null
@@ -0,0 +1 @@
+summary.html
diff --git a/partials/crmMailing2/tracking.html b/partials/crmMailing2/tracking.html
new file mode 100644 (file)
index 0000000..32568c2
--- /dev/null
@@ -0,0 +1 @@
+tracking.html