From 6ba3bf815753b287850cd95bfb8a55b2379a52e7 Mon Sep 17 00:00:00 2001 From: Siddhant Rajagopalan Date: Sun, 29 Jun 2014 18:51:48 +0530 Subject: [PATCH] commented code, preview mailing --- js/angular-newMailing.js | 425 +++++++++--------- partials/crmMailingType/attachments.html | 2 +- partials/crmMailingType/content.html | 40 +- partials/crmMailingType/headerandFooter.html | 4 + partials/crmMailingType/ht.html | 6 + partials/crmMailingType/mailingGroup.html | 10 +- partials/crmMailingType/main.html | 20 +- partials/crmMailingType/plainText.html | 5 + partials/crmMailingType/previewMailing.html | 19 +- partials/crmMailingType/preview_ht.html | 10 + .../crmMailingType/preview_plaintext.html | 9 + partials/crmMailingType/recipient.html | 43 +- partials/crmMailingType/sched.html | 5 + partials/crmMailingType/send.html | 4 + partials/crmMailingType/test.html | 7 +- partials/crmMailingType/trackandRespond.html | 6 +- 16 files changed, 317 insertions(+), 298 deletions(-) create mode 100644 partials/crmMailingType/preview_ht.html create mode 100644 partials/crmMailingType/preview_plaintext.html diff --git a/js/angular-newMailing.js b/js/angular-newMailing.js index 283a0a2353..50ed3c0cc2 100644 --- a/js/angular-newMailing.js +++ b/js/angular-newMailing.js @@ -1,14 +1,11 @@ (function(angular, $, _) { - +//partials for the html pages var partialUrl = function(relPath) { return CRM.resourceUrls['civicrm'] + '/partials/crmMailingType/' + relPath; }; var crmMailing = angular.module('crmMailing', ['ngRoute', 'ui.utils']); - - - //------------------------------------------------------------------------------------------------------- crmMailing.config(['$routeProvider', function($routeProvider) { @@ -21,7 +18,7 @@ } } - }); + }); //This route is used for generating the list of mails created. @@ -34,234 +31,224 @@ return crmApi('Mailing', 'getsingle', {id: $route.current.params.id}); } else { + //created_id has been set to my id. Does not save without created_id. Needs to made generic based on the user return {name: "New Mail", visibility: "Public Pages", url_tracking:"1", forward_replies:"0", created_id: "202", auto_responder:"0", open_tracking:"1", }; } } } - }); + }); //This route is used for creating new mails and editing the current mails } ]); //----------------------------------------- - // Add a new record by name. - // Ex: - - - - -crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail) { - -//Making some dummy api to see if my from email, reply to email works. To see if all options come in select -// - $scope.cool_api= [ - {'name': 'Nexus S', - 'from_mail': 'rajgo94@gmail.com', - 'reply_mail': 'rajgo94@gmail.com' }, - {'name': 'Motorola XOOM™ with Wi-Fi', - 'from_mail': 'rajgo94@gmail2.com', - 'reply_mail': 'rajgo94@gmail2.com'}, - {'name': 'MOTOROLA XOOM™', - 'from_mail': 'rajgo94@gmail3.com', - 'reply_mail': 'rajgo94@gmail3.com'} - ]; - $scope.partialUrl = partialUrl; - $scope.campaignList = CRM.crmMailing.campNames; - $scope.mailNameList = _.pluck(CRM.crmCaseType.civiMails, 'name'); - $scope.groupNamesList = CRM.crmMailing.groupNames; - $scope.headerfooter = CRM.crmMailing.headerfooterList; - $scope.tmpList = CRM.crmMailing.mesTemplate; - $scope.incGroup = []; - $scope.excGroup = []; - $scope.testGroup = []; - $scope.currentMailing = selectedMail; - window.ct = $scope.currentMailing; - $scope.acttab=0; - $scope.composeS="1"; - $scope.trackreplies="0"; - $scope.now="1"; - $scope.scheddate={}; - $scope.scheddate.date = ""; - $scope.scheddate.time = ""; - $scope.ans=""; - $scope.mailAutoResponder=""; - ///changing upload on screen -/* if(selectedMail.scheduled_date != ""){ - $scope.ans= selectedMail.scheduled_date.split(" "); - $scope.scheddate.date=$scope.ans[0]; - $scope.scheddate.time=$scope.ans[1]; - }*/ - - console.log(selectedMail); - $scope.upldChange= function(composeS){ - if(composeS=="1"){ - return true; +//This controller is used in creating new mail and editing current mails + crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail) { + + //Making some dummy api to see if my from email, reply to email works. To see if all options come in select box + $scope.cool_api= [ + {'name': 'rajgo94', + 'from_mail': 'rajgo94@gmail.com', + 'reply_mail': 'rajgo94@gmail.com' }, + {'name': 'rajgo94_2', + 'from_mail': 'rajgo94@gmail_2.com', + 'reply_mail': 'rajgo94@gmail_2.com'}, + {'name': 'rajgo94_3', + 'from_mail': 'rajgo94@gmail_3.com', + 'reply_mail': 'rajgo94@gmail_3.com'} + ]; + //setting variables to the values we have got to the api + $scope.partialUrl = partialUrl; + $scope.campaignList = CRM.crmMailing.campNames; + $scope.mailNameList = _.pluck(CRM.crmCaseType.civiMails, 'name'); + $scope.groupNamesList = CRM.crmMailing.groupNames; + $scope.headerfooter = CRM.crmMailing.headerfooterList; + $scope.tmpList = CRM.crmMailing.mesTemplate; + $scope.currentMailing = selectedMail; + window.ct = $scope.currentMailing; + + //initializing variables we will use for checkboxes, or for purpose of ng-show + $scope.acttab=0; + $scope.composeS="1"; + $scope.trackreplies="0"; + $scope.now="1"; + + //to split the value of selectedMail.scheduled_date into the date and time separately + $scope.scheddate={}; + $scope.scheddate.date = ""; + $scope.scheddate.time = ""; + $scope.ans=""; + + + $scope.mailAutoResponder=""; + // To split the scheduled_date into date and time. The date format is not accepting + /* if(selectedMail.scheduled_date != ""){ + $scope.ans= selectedMail.scheduled_date.split(" "); + $scope.scheddate.date=$scope.ans[0]; + $scope.scheddate.time=$scope.ans[1]; + }*/ + + console.log(selectedMail); + + //changing the screen from compose on screen to upload content + $scope.upldChange= function(composeS){ + if(composeS=="1"){ + return true; + } + else + return false; } - else - return false; - } - - $scope.isHeader= function(hf){ - return hf.component_type == "Header"; - }; - - $scope.isFooter= function(f){ - return f.component_type == "Footer"; - }; - - $scope.isAuto= function(au){ - return au.component_type == "Reply"; - }; - - $scope.isUserDriven= function(mstemp){ - return (parseInt(mstemp.id)>58); - }; - - $scope.trackr= function(trackreplies){ - if(trackreplies=="1"){ - return true; + //filter so we only get headers from mailing component + $scope.isHeader= function(hf){ + return hf.component_type == "Header"; + }; + //filter so we only get footers from mailing component + $scope.isFooter= function(f){ + return f.component_type == "Footer"; + }; + //filter so we only get auto-Responders from mailing component + $scope.isAuto= function(au){ + return au.component_type == "Reply"; + }; + //filter so we only get userDriven message templates + $scope.isUserDriven= function(mstemp){ + return (parseInt(mstemp.id)>58); + }; + //used for ng-show when trackreplies is selected. Only then we show forward replies and auto-responders options + $scope.trackr= function(trackreplies){ + if(trackreplies=="1"){ + return true; + } + else + return false; } - 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.save = function() { - $scope.currentMailing.scheduled_date= $scope.scheddate.date + " " + $scope.scheddate.time ; - if($scope.currentMailing.scheduled_date!=" "){ - $scope.currentMailing.scheduled_id= "202"; - $scope.currentMailing.scheduled_date= ""; - } - 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('nexttab', function() { - return { - - restrict: 'A', + + $scope.isGrp= function(grp){ + return grp.visibility == "Public Pages"; + }; + + + $scope.save = function() { + $scope.currentMailing.scheduled_date= $scope.scheddate.date + " " + $scope.scheddate.time ; + if($scope.currentMailing.scheduled_date!=" "){ + $scope.currentMailing.scheduled_id= "202"; + } + else { + $scope.currentMailing.scheduled_date= ""; + } + 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"); + }); + }; + }); + + +// Directive to go to the next tab + 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', + $(element).parent().parent().tabs(); + $(element).on("click",function() { + scope.acttab=scope.acttab +1; + $(element).parent().parent().tabs({active:scope.acttab}); + console.log("sid"); + }); + } + }; + }); + + // Directive to go to the previous tab + 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.directive('chsdate',function(){ - return { - scope :{ - dat : '=send_date' - }, - restrict: 'AE', - link: function(scope,element,attrs){ - $(element).datepicker({ - dateFormat: 'yy-mm-dd', - onSelect: function(date) { - $(".ui-datepicker a").removeAttr("href"); - scope.dat =date; - } - }); - } - }; - }); - - - -crmMailing.controller('browse', function($scope){ - $scope.fileList = []; - $('#fileupload').bind('fileuploadadd', function(e, data){ - // Add the files to the list - numFiles = $scope.fileList.length - for (var i=0; i < data.files.length; ++i) { - var file = data.files[i]; - // .$apply to update angular when something else makes changes - $scope.$apply( - $scope.fileList.push({name: file.name}) - ); - } - // Begin upload immediately - data.submit(); - }); -}); - - - crmMailing.directive('add',function(){ - return { - restrict : 'AE', - link: function(scope,element, attrs){ - $(document).ready(function(){ - $('#fileupload').fileupload({ - dataType: 'json' - }); - }); - - - } - }; - }); - - - crmMailing.controller('mailingListCtrl', function($scope, crmApi, mailingList) { - $scope.mailingList = mailingList.values; - $scope.mailStatus = _.pluck(CRM.crmMailing.mailStatus, 'status'); - }); + $(element).parent().parent().tabs(); + $(element).on("click",function() { + scope.acttab=scope.acttab -1; + $(element).parent().parent().tabs({active:scope.acttab}); + console.log("sid"); + }); + } + }; + }); + + // Select 2 Widget for selecting the group + crmMailing.directive('chsgroup',function(){ + return { + restrict : 'AE', + link: function(scope,element, attrs){ + $(element).select2({ + width:"400px", + placeholder: "Include Group", + }); + } + }; + }); + + // Used for the select date option. This is used for giving scheduled_date its date value + crmMailing.directive('chsdate',function(){ + return { + scope :{ + dat : '=send_date' + }, + restrict: 'AE', + link: function(scope,element,attrs){ + $(element).datepicker({ + dateFormat: 'yy-mm-dd', + onSelect: function(date) { + $(".ui-datepicker a").removeAttr("href"); + scope.dat =date; + } + }); + } + }; + }); + +/* + //browsing controller. to add selected files. not working currently + crmMailing.controller('browse', function($scope){ + $scope.fileList = []; + $('#fileupload').bind('fileuploadadd', function(e, data){ + // Add the files to the list + numFiles = $scope.fileList.length + for (var i=0; i < data.files.length; ++i) { + var file = data.files[i]; + // .$apply to update angular when something else makes changes + $scope.$apply( + $scope.fileList.push({name: file.name}) + ); + } + // Begin upload immediately + data.submit(); + }); + }); + + //adding directive. to add selected files. not working currently + crmMailing.directive('add',function(){ + return { + restrict : 'AE', + link: function(scope,element, attrs){ + $(document).ready(function(){ + $('#fileupload').fileupload({ + dataType: 'json' + }); + }); + } + }; + }); +*/ + //This controller is used for creating the mailing list. Simply gets all the mailing data from civiAPI + 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 index 7d538acf94..e3ecc093bd 100644 --- a/partials/crmMailingType/attachments.html +++ b/partials/crmMailingType/attachments.html @@ -1,4 +1,4 @@ - + diff --git a/partials/crmMailingType/content.html b/partials/crmMailingType/content.html index c33a9dd538..e48a082853 100644 --- a/partials/crmMailingType/content.html +++ b/partials/crmMailingType/content.html @@ -1,22 +1,30 @@ - + -
+ diff --git a/partials/crmMailingType/headerandFooter.html b/partials/crmMailingType/headerandFooter.html index 6275434549..1730c1a5c3 100644 --- a/partials/crmMailingType/headerandFooter.html +++ b/partials/crmMailingType/headerandFooter.html @@ -1,3 +1,7 @@ +
diff --git a/partials/crmMailingType/ht.html b/partials/crmMailingType/ht.html index 951f638722..ee84fdd054 100644 --- a/partials/crmMailingType/ht.html +++ b/partials/crmMailingType/ht.html @@ -1,3 +1,9 @@ + +
        diff --git a/partials/crmMailingType/mailingGroup.html b/partials/crmMailingType/mailingGroup.html index 19ae7c99b4..a477d68be1 100644 --- a/partials/crmMailingType/mailingGroup.html +++ b/partials/crmMailingType/mailingGroup.html @@ -1,14 +1,16 @@ +
-

-

diff --git a/partials/crmMailingType/main.html b/partials/crmMailingType/main.html index a8832e9af3..ebf71f39d4 100644 --- a/partials/crmMailingType/main.html +++ b/partials/crmMailingType/main.html @@ -1,9 +1,10 @@ + +
-
- - - -
- - diff --git a/partials/crmMailingType/plainText.html b/partials/crmMailingType/plainText.html index c587bef07f..0fc4087116 100644 --- a/partials/crmMailingType/plainText.html +++ b/partials/crmMailingType/plainText.html @@ -1,3 +1,8 @@ + +
        diff --git a/partials/crmMailingType/previewMailing.html b/partials/crmMailingType/previewMailing.html index a076f5777a..1da937dfbd 100644 --- a/partials/crmMailingType/previewMailing.html +++ b/partials/crmMailingType/previewMailing.html @@ -1 +1,18 @@ -TO BE DONE LATER + +
+ + + +
+ + diff --git a/partials/crmMailingType/preview_ht.html b/partials/crmMailingType/preview_ht.html new file mode 100644 index 0000000000..f84dc26cbd --- /dev/null +++ b/partials/crmMailingType/preview_ht.html @@ -0,0 +1,10 @@ + + +
+        + +

diff --git a/partials/crmMailingType/preview_plaintext.html b/partials/crmMailingType/preview_plaintext.html new file mode 100644 index 0000000000..f50b9321d0 --- /dev/null +++ b/partials/crmMailingType/preview_plaintext.html @@ -0,0 +1,9 @@ + + +
+        + +

diff --git a/partials/crmMailingType/recipient.html b/partials/crmMailingType/recipient.html index 7be2112f98..dace667c74 100644 --- a/partials/crmMailingType/recipient.html +++ b/partials/crmMailingType/recipient.html @@ -1,9 +1,9 @@ +
@@ -16,7 +16,6 @@ The original form used table layout; don't know if we have an alternative, CSS-b - -
Campaign - @@ -28,45 +27,15 @@ The original form used table layout; don't know if we have an alternative, CSS-b

-