From d95b1485ef4a0ff8ceb07ea8fac264e8580c9fb7 Mon Sep 17 00:00:00 2001 From: Siddhant Rajagopalan Date: Tue, 24 Jun 2014 10:35:55 +0530 Subject: [PATCH] Message template id done and a dummy for fromemail --- CRM/Mailing/Info.php | 7 +- js/angular-newMailing.js | 165 +++++++-------------- partials/crmMailingType/attachments.html | 36 +---- partials/crmMailingType/content.html | 104 +++++++++---- partials/crmMailingType/uploadContent.html | 6 +- 5 files changed, 146 insertions(+), 172 deletions(-) diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index 15ce035548..9ffc634651 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -67,7 +67,11 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { $mailStatus = civicrm_api3('MailingJob', 'get', array()); $groupNames = civicrm_api3('Group', 'get', array()); $headerfooterList = civicrm_api3('MailingComponent', 'get', array()); - + $mesTemplate = civicrm_api3('MessageTemplate', 'get', array( 'sequential' => 1, + 'return' => "msg_title", + 'id' => array('>' => 58),) + ); + CRM_Core_Resources::singleton()->addSetting(array( 'crmMailing' => array( 'civiMails' => array_values($civiMails['values']), @@ -75,6 +79,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { 'mailStatus' => array_values($mailStatus['values']), 'groupNames' => array_values($groupNames['values']), 'headerfooterList' => array_values($headerfooterList['values']), + 'mesTemplate' => array_values($mesTemplate['values']), ), )); return $result; diff --git a/js/angular-newMailing.js b/js/angular-newMailing.js index f051e697e4..283a0a2353 100644 --- a/js/angular-newMailing.js +++ b/js/angular-newMailing.js @@ -5,7 +5,9 @@ }; var crmMailing = angular.module('crmMailing', ['ngRoute', 'ui.utils']); + + //------------------------------------------------------------------------------------------------------- crmMailing.config(['$routeProvider', @@ -49,11 +51,27 @@ 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 = []; @@ -93,8 +111,12 @@ crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail) { }; $scope.isAuto= function(au){ - return au.component_type == "Auto-responder"; + return au.component_type == "Reply"; }; + + $scope.isUserDriven= function(mstemp){ + return (parseInt(mstemp.id)>58); + }; $scope.trackr= function(trackreplies){ if(trackreplies=="1"){ @@ -114,10 +136,7 @@ crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail) { } }; */ - - - - $scope.save = function() { + $scope.save = function() { $scope.currentMailing.scheduled_date= $scope.scheddate.date + " " + $scope.scheddate.time ; if($scope.currentMailing.scheduled_date!=" "){ $scope.currentMailing.scheduled_id= "202"; @@ -171,7 +190,7 @@ crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail) { }); - crmMailing.directive('chsgroup',function(){ + crmMailing.directive('chsgroup',function(){ return { restrict : 'AE', link: function(scope,element, attrs){ @@ -197,118 +216,48 @@ crmMailing.directive('chsdate',function(){ onSelect: function(date) { $(".ui-datepicker a").removeAttr("href"); scope.dat =date; - console.log(date); } }); } }; }); - - -crmMailing.controller('browse', function(){ -FileUploadCtrl.$inject = ['$scope'] -function FileUploadCtrl(scope) { - //============== DRAG & DROP ============= - // source for drag&drop: http://www.webappers.com/2011/09/28/drag-drop-file-upload-with-html5-javascript/ - var dropbox = document.getElementById("dropbox") - scope.dropText = 'Drop files here...' - - // init event handlers - function dragEnterLeave(evt) { - evt.stopPropagation() - evt.preventDefault() - scope.$apply(function(){ - scope.dropText = 'Drop files here...' - scope.dropClass = '' - }) - } - dropbox.addEventListener("dragenter", dragEnterLeave, false) - dropbox.addEventListener("dragleave", dragEnterLeave, false) - dropbox.addEventListener("dragover", function(evt) { - evt.stopPropagation() - evt.preventDefault() - var clazz = 'not-available' - var ok = evt.dataTransfer && evt.dataTransfer.types && evt.dataTransfer.types.indexOf('Files') >= 0 - scope.$apply(function(){ - scope.dropText = ok ? 'Drop files here...' : 'Only files are allowed!' - scope.dropClass = ok ? 'over' : 'not-available' - }) - }, false) - dropbox.addEventListener("drop", function(evt) { - console.log('drop evt:', JSON.parse(JSON.stringify(evt.dataTransfer))) - evt.stopPropagation() - evt.preventDefault() - scope.$apply(function(){ - scope.dropText = 'Drop files here...' - scope.dropClass = '' - }) - var files = evt.dataTransfer.files - if (files.length > 0) { - scope.$apply(function(){ - scope.files = [] - for (var i = 0; i < files.length; i++) { - scope.files.push(files[i]) - } - }) - } - }, false) - //============== DRAG & DROP ============= - - scope.setFiles = function(element) { - scope.$apply(function(scope) { - console.log('files:', element.files); - // Turn the FileList object into an Array - scope.files = [] - for (var i = 0; i < element.files.length; i++) { - scope.files.push(element.files[i]) - } - scope.progressVisible = false - }); - }; - - scope.uploadFile = function() { - var fd = new FormData() - for (var i in scope.files) { - fd.append("uploadedFile", scope.files[i]) - } - var xhr = new XMLHttpRequest() - xhr.upload.addEventListener("progress", uploadProgress, false) - xhr.addEventListener("load", uploadComplete, false) - xhr.addEventListener("error", uploadFailed, false) - xhr.addEventListener("abort", uploadCanceled, false) - xhr.open("POST", "/fileupload") - scope.progressVisible = true - xhr.send(fd) - } - function uploadProgress(evt) { - scope.$apply(function(){ - if (evt.lengthComputable) { - scope.progress = Math.round(evt.loaded * 100 / evt.total) - } else { - scope.progress = 'unable to compute' - } - }) - } - function uploadComplete(evt) { - /* This event is raised when the server send back a response */ - alert(evt.target.responseText) - } - function uploadFailed(evt) { - alert("There was an error attempting to upload the file.") - } +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(); + }); +}); - function uploadCanceled(evt) { - scope.$apply(function(){ - scope.progressVisible = false - }) - alert("The upload has been canceled by the user or the browser dropped the connection.") - } -} -}); + + 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'); diff --git a/partials/crmMailingType/attachments.html b/partials/crmMailingType/attachments.html index 16fabc92d0..7d538acf94 100644 --- a/partials/crmMailingType/attachments.html +++ b/partials/crmMailingType/attachments.html @@ -1,22 +1,22 @@ - + @@ -24,31 +24,3 @@ - - - diff --git a/partials/crmMailingType/content.html b/partials/crmMailingType/content.html index b4bc595fbb..c33a9dd538 100644 --- a/partials/crmMailingType/content.html +++ b/partials/crmMailingType/content.html @@ -4,7 +4,7 @@ Required vars: caseType The original form used table layout; don't know if we have an alternative, CSS-based layout --> -
+ + +
+
Attach Files - +
Attach Files - +
Attach Files - +
+ + + + - - - + + + + + + + + + + + - - - --> + + + + + + + + + +
From E-mail Address + Exclude Group - - +
Reply to E-mail Address + +
Mailing Subject + +
Use Template + Campaign - - -
I want toCompose on screenUpload Content
+
+ + + + + diff --git a/partials/crmMailingType/uploadContent.html b/partials/crmMailingType/uploadContent.html index 5e00794d43..3f77bc933a 100644 --- a/partials/crmMailingType/uploadContent.html +++ b/partials/crmMailingType/uploadContent.html @@ -1,15 +1,15 @@ - +
Upload TEXT Message - +
Upload HTML Message - +
-- 2.25.1