From 1321c37b8eded034af223d5fe74f3cc514b1c026 Mon Sep 17 00:00:00 2001 From: Siddhant Rajagopalan Date: Sat, 21 Jun 2014 13:58:05 +0530 Subject: [PATCH] Basic version of new CiviMail interface --- CRM/Mailing/Info.php | 23 ++ CRM/Mailing/Page/Optout.php | 41 +++ CRM/Mailing/Page/Unsubscribe.php | 42 +++ js/angular-newMailing.js | 331 +++++++++++++++++++ partials/crmMailingType/attachments.html | 0 partials/crmMailingType/composeonScreen.html | 0 partials/crmMailingType/content.html | 83 +++++ partials/crmMailingType/headerandFooter.html | 0 partials/crmMailingType/mailingGroup.html | 14 + partials/crmMailingType/mailingList.html | 32 ++ partials/crmMailingType/main.html | 54 +++ partials/crmMailingType/previewMailing.html | 0 partials/crmMailingType/recipient.html | 72 ++++ partials/crmMailingType/sched.html | 0 partials/crmMailingType/send.html | 17 + partials/crmMailingType/test.html | 0 partials/crmMailingType/trackandRespond.html | 91 +++++ 17 files changed, 800 insertions(+) create mode 100644 CRM/Mailing/Page/Optout.php create mode 100644 CRM/Mailing/Page/Unsubscribe.php create mode 100644 js/angular-newMailing.js create mode 100644 partials/crmMailingType/attachments.html create mode 100644 partials/crmMailingType/composeonScreen.html create mode 100644 partials/crmMailingType/content.html create mode 100644 partials/crmMailingType/headerandFooter.html create mode 100644 partials/crmMailingType/mailingGroup.html create mode 100644 partials/crmMailingType/mailingList.html create mode 100644 partials/crmMailingType/main.html create mode 100644 partials/crmMailingType/previewMailing.html create mode 100644 partials/crmMailingType/recipient.html create mode 100644 partials/crmMailingType/sched.html create mode 100644 partials/crmMailingType/send.html create mode 100644 partials/crmMailingType/test.html create mode 100644 partials/crmMailingType/trackandRespond.html diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index 92aeb3bb24..0d43ae3705 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -55,6 +55,29 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { ); } + public function getAngularModules() { + $result = array(); + $result['crmMailing'] = array( + 'ext' => 'civicrm', + 'js' => array('js/angular-newMailing.js'), + ); + + $civiMails = civicrm_api3('Mailing', 'get', array()); + $campNames = civicrm_api3('Campaign', 'get', array()); + $mailStatus = civicrm_api3('MailingJob', 'get', array()); + $groupNames = civicrm_api3('Group', 'get', array()); + + CRM_Core_Resources::singleton()->addSetting(array( + 'crmMailing' => array( + 'civiMails' => array_values($civiMails['values']), + 'campNames' => array_values($campNames['values']), + 'mailStatus' => array_values($mailStatus['values']), + 'groupNames' => array_values($groupNames['values']), + ), + )); + return $result; + } + /** * @return bool */ diff --git a/CRM/Mailing/Page/Optout.php b/CRM/Mailing/Page/Optout.php new file mode 100644 index 0000000000..3511eb00eb --- /dev/null +++ b/CRM/Mailing/Page/Optout.php @@ -0,0 +1,41 @@ +_type = 'optout'; + return parent::run(); + } +} + diff --git a/CRM/Mailing/Page/Unsubscribe.php b/CRM/Mailing/Page/Unsubscribe.php new file mode 100644 index 0000000000..a3f6a5fe2f --- /dev/null +++ b/CRM/Mailing/Page/Unsubscribe.php @@ -0,0 +1,42 @@ +_type = 'unsubscribe'; + return parent::run(); + } +} + diff --git a/js/angular-newMailing.js b/js/angular-newMailing.js new file mode 100644 index 0000000000..44b36ec006 --- /dev/null +++ b/js/angular-newMailing.js @@ -0,0 +1,331 @@ +(function(angular, $, _) { + + var partialUrl = function(relPath) { + return CRM.resourceUrls['civicrm'] + '/partials/crmMailingType/' + relPath; + }; + + var crmMailing = angular.module('crmMailing', ['ngRoute', 'ui.utils']); + + /* var sid = { + collapsible: true, + active: false + };*/ +//------------------------------------------------------------------------------------------------------- + crmMailing.config(['$routeProvider', + function($routeProvider) { + $routeProvider.when('/mailing', { + templateUrl: partialUrl('mailingList.html'), + controller: 'mailingListCtrl', + resolve: { + mailingList: function($route, crmApi) { + return crmApi('Mailing', 'get', {}); + } + + } + }); + + + + $routeProvider.when('/mailing/:id', { + templateUrl: partialUrl('main.html'), + controller: 'mailingCtrl', + resolve: { + selectedMail: function($route, crmApi) { + if ( $route.current.params.id !== 'new') { + return crmApi('Mailing', 'getsingle', {id: $route.current.params.id}); + } + else { + return {name: "New Mail", visibility: "Public Pages", url_tracking:"1", forward_replies:"0", auto_responder:"0", open_tracking:"1", + }; + } + } + } + }); + } + ]); +//----------------------------------------- + // Add a new record by name. + // Ex: + + + + + + crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail) { + $scope.partialUrl = partialUrl; + $scope.campaignList = CRM.crmMailing.campNames; + $scope.mailNameList = _.pluck(CRM.crmCaseType.civiMails, 'name'); + $scope.groupNamesList = CRM.crmMailing.groupNames; + $scope.incGroup = []; + $scope.excGroup = []; + $scope.currentMailing = selectedMail; + /*$scope.currentMailing.name = $scope.currentMailing.name || []; + $scope.currentMailing.visibility = $scope.currentMailing.visibility || []; + $scope.currentMailing.url_tracking = $scope.currentMailing.url_tracking || []; + $scope.currentMailing.forward_replies = $scope.currentMailing.forward_replies || []; + $scope.currentMailing.auto_responder = $scope.currentMailing.auto_responder || []; + $scope.currentMailing.open_tracking = $scope.currentMailing.open_tracking || [];*/ + window.ct = $scope.currentMailing; + $scope.acttab=0; + $scope.composeS="1"; + $scope.trackreplies="0"; + ///changing upload on screen + + $scope.upldChange= function(composeS){ + if(composeS=="1"){ + return true; + } + else + return false; + } + + $scope.trackr= function(trackreplies){ + if(trackreplies=="1"){ + return true; + } + else + return false; + } + + /// Add a new group to mailing + /* $scope.addGroup = function(grp, groupName) { + var names = _.pluck(CRM.crmMailing.groupNames, 'name'); + if (!_.contains(names, groupName)) { + grp.push({ + name: groupName + }); + } + }; */ + + + + /* $scope.addActivitySet = function(workflow) { + var activitySet = {}; + activitySet[workflow] = '1'; + activitySet.activityTypes = []; + + var offset = 1; + var names = _.pluck($scope.caseType.definition.activitySets, 'name'); + while (_.contains(names, workflow + '_' + offset)) offset++; + activitySet.name = workflow + '_' + offset; + activitySet.label = (offset == 1 ) ? $scope.workflows[workflow] : ($scope.workflows[workflow] + ' #' + offset); + + $scope.caseType.definition.activitySets.push(activitySet); + _.defer(function() { + $('.crmCaseType-acttab').tabs('refresh').tabs({active: -1}); + }); + }; + + /// Add a new activity entry to an activity-set + $scope.addActivity = function(activitySet, activityType) { + activitySet.activityTypes.push({ + name: activityType + }); + if (!_.contains($scope.activityTypeNames, activityType)) { + $scope.activityTypeNames.push(activityType); + } + }; + + /// Add a new top-level activity-type entry + $scope.addActivityType = function(activityType) { + var names = _.pluck($scope.caseType.definition.activityTypes, 'name'); + if (!_.contains(names, activityType)) { + $scope.caseType.definition.activityTypes.push({ + name: activityType + }); + + } + if (!_.contains($scope.activityTypeNames, activityType)) { + $scope.activityTypeNames.push(activityType); + } + }; + + /// Add a new role + $scope.addRole = function(roles, roleName) { + var names = _.pluck($scope.caseType.definition.caseRoles, 'name'); + if (!_.contains(names, roleName)) { + roles.push({ + name: roleName + }); + } + if (!_.contains($scope.relationshipTypeNames, roleName)) { + $scope.relationshipTypeNames.push(roleName); + } + }; + + $scope.onManagerChange = function(managerRole) { + angular.forEach($scope.caseType.definition.caseRoles, function(caseRole) { + if (caseRole != managerRole) { + caseRole.manager = '0'; + } + }); + }; + + $scope.removeItem = function(array, item) { + var idx = _.indexOf(array, item); + if (idx != -1) { + array.splice(idx, 1); + } + }; + + $scope.isNewActivitySetAllowed = function(workflow) { + switch (workflow) { + case 'timeline': + return true; + case 'sequence': + return 0 == _.where($scope.caseType.definition.activitySets, {sequence: '1'}).length; + default: + if (console && console.log) console.log('Denied access to unrecognized workflow: (' + workflow + ')'); + return false; + } + }; + + $scope.getWorkflowName = function(activitySet) { + var result = 'Unknown'; + _.each($scope.workflows, function(value, key) { + if (activitySet[key]) result = value; + }); + return result; + }; + + /** + * Determine which HTML partial to use for a particular + * + * @return string URL of the HTML partial + */ + $scope.save = function() { + var result = crmApi('Mailing', 'create', $scope.currentMailing, true); + result.success(function(data) { + if (data.is_error == 0) { + $scope.currentMailing.id = data.id; + console.log("OK"); + } + console.log("OK2"); + }); + }; + }); + + +/* crmMailing.directive('crmAddMail', function() { + return { + restrict: 'AE', + template: '', + link: function(scope, element, attrs) { + /// Format list of options for select2's "data" + var getFormattedOptions = function() { + return { + results: _.map(scope[attrs.crmOptions], function(option){ + return {id: option, text: option}; + }) + }; + }; + + var input = $('input', element); + + scope._resetSelection = function() { + $(input).select2('close'); + $(input).select2('val', ''); + scope[attrs.crmVar] = ''; + }; + + $(input).select2({ + data: getFormattedOptions, + createSearchChoice: function(term) { + return {id: term, text: term}; + } + }); + $(input).on('select2-selecting', function(e) { + scope[attrs.crmVar] = e.val; + scope.$evalAsync(attrs.crmOnAdd); + scope.$evalAsync('_resetSelection()'); + e.preventDefault(); + }); + + scope.$watch(attrs.crmOptions, function(value) { + $(input).select2('data', getFormattedOptions); + $(input).select2('val', ''); + }); + } + }; + }); */ + + + /*crmMailing.directive('nexttab', function() { + return { + // Restrict it to be an attribute in this case + restrict: 'A', + // responsible for registering DOM listeners as well as updating the DOM + link: function(scope, element, attrs) { + + $(element).parent().parent().tabs(); + $(element).on("click",function() { + var selected = $(element).parent().parent().tabs("option","selected"); + $(element).parent().parent().tabs("select", selected + 1); + + + }); + } + }; + });*/ + + crmMailing.directive('nexttab', function() { + return { + + restrict: 'A', + link: function(scope, element, attrs) { + + $(element).parent().parent().tabs(); + + $(element).on("click",function() { + scope.acttab=scope.acttab +1; + $(element).parent().parent().tabs({active:scope.acttab}); + console.log("sid"); + }); + } + }; + }); + + crmMailing.directive('prevtab', function() { + return { + + restrict: 'A', + link: function(scope, element, attrs) { + + $(element).parent().parent().tabs(); + + $(element).on("click",function() { + scope.acttab=scope.acttab -1; + $(element).parent().parent().tabs({active:scope.acttab}); + console.log("sid"); + }); + } + }; + }); + + + crmMailing.directive('chsgroup',function(){ + return { + restrict : 'AE', + link: function(scope,element, attrs){ + $(element).select2( + {width:"400px", + placeholder: "Include Group", + }); + } + }; + + }); + + + + + + + crmMailing.controller('mailingListCtrl', function($scope, crmApi, mailingList) { + $scope.mailingList = mailingList.values; + $scope.mailStatus = _.pluck(CRM.crmMailing.mailStatus, 'status'); + }); + +})(angular, CRM.$, CRM._); + + diff --git a/partials/crmMailingType/attachments.html b/partials/crmMailingType/attachments.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/partials/crmMailingType/composeonScreen.html b/partials/crmMailingType/composeonScreen.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/partials/crmMailingType/content.html b/partials/crmMailingType/content.html new file mode 100644 index 0000000000..d0c73fd223 --- /dev/null +++ b/partials/crmMailingType/content.html @@ -0,0 +1,83 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
From E-mail Address + +
Reply to E-mail Address + +
Mailing Subject + +
I want toCompose on screenUpload Content
+
+ + + + + + diff --git a/partials/crmMailingType/headerandFooter.html b/partials/crmMailingType/headerandFooter.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/partials/crmMailingType/mailingGroup.html b/partials/crmMailingType/mailingGroup.html new file mode 100644 index 0000000000..42bed40167 --- /dev/null +++ b/partials/crmMailingType/mailingGroup.html @@ -0,0 +1,14 @@ + +
+ +

+ + +

diff --git a/partials/crmMailingType/mailingList.html b/partials/crmMailingType/mailingList.html new file mode 100644 index 0000000000..845c3a8527 --- /dev/null +++ b/partials/crmMailingType/mailingList.html @@ -0,0 +1,32 @@ + +
+ All partially completed and completed mail are listed here +
+ + + + + + + + + + + + + + + + + + + +
Mailing NameCreated ByCreated DateSent By
{{mail.name}}{{mail.from_email}}{{mail.created_date}}{{mail.from_email}}Edit +
+ + diff --git a/partials/crmMailingType/main.html b/partials/crmMailingType/main.html new file mode 100644 index 0000000000..a8832e9af3 --- /dev/null +++ b/partials/crmMailingType/main.html @@ -0,0 +1,54 @@ + + + + diff --git a/partials/crmMailingType/previewMailing.html b/partials/crmMailingType/previewMailing.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/partials/crmMailingType/recipient.html b/partials/crmMailingType/recipient.html new file mode 100644 index 0000000000..7be2112f98 --- /dev/null +++ b/partials/crmMailingType/recipient.html @@ -0,0 +1,72 @@ + +
+ + + + + + + + + + + + + + + + + +
Name your Mailing + +
Campaign + + +
Remove Duplicates? + +
+
+ + + + +
+ diff --git a/partials/crmMailingType/sched.html b/partials/crmMailingType/sched.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/partials/crmMailingType/send.html b/partials/crmMailingType/send.html new file mode 100644 index 0000000000..8f68d2d62a --- /dev/null +++ b/partials/crmMailingType/send.html @@ -0,0 +1,17 @@ +
+ + + + + + + diff --git a/partials/crmMailingType/test.html b/partials/crmMailingType/test.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/partials/crmMailingType/trackandRespond.html b/partials/crmMailingType/trackandRespond.html new file mode 100644 index 0000000000..e5d74cd9eb --- /dev/null +++ b/partials/crmMailingType/trackandRespond.html @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Tracking

+
Track Click Throughs + + +
+ Track the number of times recipients click each link in this mailing. NOTE: When this feature is enabled, all links in the message body will be automaticallly re-written to route through your CiviCRM server prior to redirecting to the target page. +
+
Track Opens + + +
+ Track the number of times recipients open this mailing in their email software. +
+
+

Responding

+
Track Replies + + +
+ Recipients' replies are sent to a CiviMail specific address instead of the sender's address so they can be stored within CiviCRM. +
+
Forward Replies + + +
+ If a recipient replies to this mailing, forward the reply to the FROM Email address specified for the mailing. +
+
Auto-Responder + + + +
+
+ If a recipient replies to this mailing, send an automated reply using the selected message. +
+
+

Online Publication

+
Mailing Visibility + +
+ + -- 2.25.1