made a superselect2 box,validations
authorSiddhant Rajagopalan <rajgo94@gmail.com>
Fri, 11 Jul 2014 04:22:59 +0000 (09:52 +0530)
committerSiddhant Rajagopalan <rajgo94@gmail.com>
Sat, 26 Jul 2014 05:11:57 +0000 (10:41 +0530)
CRM/Mailing/BAO/Mailing.php
i/include.jpeg [new file with mode: 0644]
js/angular-newMailing.js
partials/crmMailingType/attachments.html
partials/crmMailingType/content.html
partials/crmMailingType/mailingGroup.html
partials/crmMailingType/main.html
partials/crmMailingType/preview_ht.html
partials/crmMailingType/recipient.html
partials/crmMailingType/sched.html
partials/crmMailingType/trackandRespond.html

index 63edbeef694814f45029a2885971f0859ca9bdc7..6a1dc837bf6dfd2e824f17b5225f0d8e18894a7a 100644 (file)
@@ -1657,8 +1657,8 @@ ORDER BY   civicrm_email.is_bulkmail DESC
       // Populate the recipients.
       $mailing->getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, FALSE);
     }
-               //print_r($params);
-               //exit;
+       //      print_r($params);
+       //      exit;
     return $mailing;
   }
 
diff --git a/i/include.jpeg b/i/include.jpeg
new file mode 100644 (file)
index 0000000..4de3dc5
Binary files /dev/null and b/i/include.jpeg differ
index ad307ba9167ef10b4206a55136a50d602624341c..6d6a3fcfd4a1bde17f524e265b849348248f1dfc 100644 (file)
@@ -33,7 +33,7 @@
             }
             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",
+              return {visibility: "Public Pages", url_tracking:"1", forward_replies:"0", created_id: "202", auto_responder:"0", open_tracking:"1",
                  };
             }
           }
@@ -45,7 +45,7 @@
  
 
 //This controller is used in creating new mail and editing current mails
-       crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail) {
+       crmMailing.controller('mailingCtrl', function($scope, crmApi, selectedMail, $location) {
                        
        //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= [
@@ -60,6 +60,7 @@
                         'reply_mail': 'rajgo94@gmail_3.com'}
                ];
        //setting variables to the values we have got to the api
+         $scope.submitted = false;
                $scope.partialUrl = partialUrl;
                $scope.campaignList =  CRM.crmMailing.campNames;
                $scope.mailList = CRM.crmMailing.civiMails;
                $scope.currentMailing = selectedMail;
                $scope.testGroup = "";
                window.ct = $scope.currentMailing;
+               $scope.param = {};
+               $scope.mailingForm = function() {
+                       if ($scope.mailing_form.$valid) {
+                               // Submit as normal
+                       } else {
+                               $scope.mailing_form.submitted = true;
+                       }
+               }
                
+               $scope.back = function (){
+                       $location.path( "mailing" );
+               };
+
        //initializing variables we will use for checkboxes, or for purpose of ng-show
                $scope.acttab=0;
                $scope.composeS="1";
-               $scope.trackreplies="0";
+               if($scope.currentMailing.forward_replies==0 && $scope.currentMailing.auto_responder==0){
+                               $scope.trackreplies="0";
+               }
+               else {
+                               $scope.trackreplies="1";
+               }
+               
                $scope.now="1";
+               
+               $scope.reply = function(){
+                       if($scope.trackreplies==0){
+                                       $scope.trackreplies=1;
+                               }
+                       else{
+                                       $scope.trackreplies=0;
+                                       $scope.currentMailing.forward_replies=0;
+                                       $scope.currentMailing.auto_responder=0;
+                               }
+                       }
+                       
+               $scope.recclicked = function(){
+                       $scope.acttab=0;
+               };
 
+               $scope.conclicked = function(){
+                       $scope.acttab=1;
+               };              
+               
+               $scope.schedclicked = function(){
+                       $scope.acttab=2;
+               };              
+               
        //to split the value of selectedMail.scheduled_date into the date and time separately   
                $scope.scheddate={};
                $scope.scheddate.date = ""; 
                        }
                        else 
                                return false;
-               }
+               };
        //filter so we only get headers from mailing component 
                $scope.isHeader= function(hf){
                        return hf.component_type == "Header";
                        return ml.is_completed == 1;
                };
                
+               $scope.upload = function(){
+                       console.log($scope.param.file);
+                       };
+               
+               $scope.upload_2 = function(){
+                       console.log($scope.param.file_2);
+                       };
+               
+               $scope.upload_3 = function(){
+                       console.log($scope.param.file_3);
+               };
+                               
+                       
                $scope.save = function() {
                                $scope.incGrp=[];
                                $scope.excGrp=[];
                return {
                        restrict : 'AE',
                        link: function(scope,element, attrs){
+                          function format(item) {
+         if(!item.id) {
+            // return `text` for optgroup
+            return item.text;
+          }
+          // return item template
+          var a = item.id.split(" ");
+          console.log(a);
+          if(a[1]=="group" && a[2]=="include")
+                                               return "<img src='../../sites/all/modules/civicrm/i/include.jpeg' height=12 width=12/>" + "   " + "<img src='../../sites/all/modules/civicrm/i/group.png' height=12 width=12/>" + item.text;
+                                 if(a[1]=="group" && a[2]=="exclude")
+                                               return "<img src='../../sites/all/modules/civicrm/i/Error.gif' height=12 width=12/>" + "   " + "<img src='../../sites/all/modules/civicrm/i/group.png' height=12 width=12/>" + item.text;
+                                       if(a[1]=="mail" && a[2]=="include")
+                                               return "<img src='../../sites/all/modules/civicrm/i/include.jpeg' height=12 width=12/>" + "   "  + "<img src='../../sites/all/modules/civicrm/i/EnvelopeIn.gif' height=12 width=12/>" + item.text;
+                                       if(a[1]=="mail" && a[2]=="exclude")
+                                               return "<img src='../../sites/all/modules/civicrm/i/Error.gif' height=12 width=12/>" + "   " + "<img src='../../sites/all/modules/civicrm/i/EnvelopeIn.gif' height=12 width=12/>" + item.text;
+        }
+
                        $(element).select2({
                                width:"400px",
                                placeholder: "Choose Recipients",
+                               formatResult: format,
+                               formatSelection: format,
+                               escapeMarkup: function(m) { return m; }
                                });
                        $(element).on('select2-selecting', function(e) {
                                        incGroup.push(e.val);
        // 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;
+                                                       var ngModelName = this.attributes['ng-model'].value;
+              scope[ngModelName] = date;
+              scope.$apply();
                                                }
                                });
                        }
                };
        });
 
-/*
-       //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})
-                                                       );
+       crmMailing.directive('file', function(){
+                       return {
+                                       scope: {
+                                                       file: '='
+                                       },
+                                       link: function(scope, el, attrs){
+                                                       el.bind('change', function(event){
+                                                                       var files = event.target.files;
+                                                                       var file = files[0];
+                                                                       scope.file = file ? file.name : undefined;
+                                                                       scope.$apply();
+                                                       });
                                        }
-                                       // 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;
 
 })(angular, CRM.$, CRM._);
 
-
-
+/* example of params
+ [attachFile_1] => Array ( [uri] => /var/www/siddhant/drupal-7.27/sites/default/files/civicrm/custom/blog_2_odt_2c622a7b5e32415a92e81ed97d6554c7.unknown [type] => application/vnd.oasis.opendocument.text [location] => /var/www/siddhant/drupal-7.27/sites/default/files/civicrm/custom/blog_2_odt_2c622a7b5e32415a92e81ed97d6554c7.unknown [description] => dasdas [upload_date] => 20140706105804 [tag] => Array ( ) [attachment_taglist] => Array ( ) )
+*/
index e3ecc093bd5bc8c5073cd0b52a907c6e736dbba0..c710671963da774c9290126d84bf6247ed55333d 100644 (file)
@@ -4,19 +4,28 @@
          <tr>
            <td class="label">Attach Files</td>
                <td>
-                 <input type="file"/>
+                 <input type="file" data-file="param.file"/>
+               </td>
+               <td>
+                 <button ng-click="upload()" >Upload</button> 
                </td>
          </tr>
          <tr>
            <td class="label">Attach Files</td>
                <td>
-                 <input type="file"/>
+                 <input type="file" data-file="param.file_2"/>
+               </td>
+               <td>
+                 <button ng-click="upload_2()" >Upload</button> 
                </td>
          </tr>
          <tr>
            <td class="label">Attach Files</td>
                <td>
-                 <input type="file"/>
+                 <input type="file" data-file="param.file_3"/>
+               </td>
+               <td>
+                 <button ng-click="upload_3()" >Upload</button> 
                </td>
          </tr>
          
index cb02d7952be7f554e83e1d5f7c96c738b34bce74..de922ff28b49a80171f8d42de33ed6e9853976c4 100644 (file)
@@ -25,9 +25,14 @@ Required Variables: cool_api and currentMailing and eMailing
   <tr>
     <td class="label">Mailing Subject</td>
      <td>
-      <input type="text" ng-model="currentMailing.subject"/>
+      <input placeholder="Enter Subject" required name="subject" type="text" ng-model="currentMailing.subject"/>
     </td>
   </tr>
+  <tr>
+    <td class="label"  style= "color:red" ng-show="mailing_form.subject.$invalid">
+                                       Mailing subject required.
+               </td>
+  </tr>
   <tr>
     <td class="label">Use Template</td>
      <td>
@@ -36,7 +41,7 @@ Required Variables: cool_api and currentMailing and eMailing
                        </select>
     </td>
   </tr>
-  <tr>
+  <tr ng-show= "false">
                <td class="label">I want to</td>
                <td class="label">Compose on screen</td>
     <td><input type="radio" ng-model="composeS" value="1" /></td>
@@ -54,7 +59,7 @@ Required Variables: cool_api and currentMailing and eMailing
   <div class="crm-accordion-header">Upload Content</div>
   <div class="crm-accordion-body" ng-include="partialUrl('uploadContent.html')"></div>
 </div>
-<div class="crm-accordion-wrapper collapsed">
+<div class="crm-accordion-wrapper collapsed" ng-show="false">
   <div class="crm-accordion-header">Attachments</div>
   <div class="crm-accordion-body" ng-include="partialUrl('attachments.html')"></div>
 </div>
index c2ac7250090e2c24d7ec6ed212f320bae6b08aa3..7a0de23029a07c7ddc72089cd25a4adb6a7f9a9e 100644 (file)
@@ -5,11 +5,11 @@ MailingGroup api needs to be improved to bind the chosen groups
 -->
 
 <br>
-<select multiple chsgroup>
-       <option ng-repeat="grp in groupNamesList| filter: isGrp" value="{{grp.id}} group include" > Include {{grp.title}}</option>
-       <option ng-repeat="grp in groupNamesList| filter: isGrp" value="{{grp.id}} group exclude" > Exclude {{grp.title}}</option>
-       <option ng-repeat="ml in mailList| filter:isCompMail" value="{{ml.id}} mail include" > Include Mailing {{ml.name}}</option>
-       <option ng-repeat="ml in mailList| filter:isCompMail" value="{{ml.id}} mail exclude" > Exclude Mailing {{ml.name}}</option>
+<select multiple chsgroup ng-model="incGroup">
+       <option id= "1" ng-repeat="grp in groupNamesList| filter: isGrp" value="{{grp.id}} group include" > {{grp.title}} </option>
+       <option ng-repeat="grp in groupNamesList| filter: isGrp" value="{{grp.id}} group exclude" > {{grp.title}} </option>
+       <option ng-repeat="ml in mailList| filter:isCompMail" value="{{ml.id}} mail include" > {{ml.name}} </option>
+       <option ng-repeat="ml in mailList| filter:isCompMail" value="{{ml.id}} mail exclude" > {{ml.name}} </option>
 </select>
 <br> <br>
 
index ebf71f39d44d93f27a8bf0a6654d58436ed98361..d205c2989746dc7a89833fa416ba5bd288210281 100644 (file)
@@ -2,43 +2,47 @@
 Controller: MailCtrl
 Submit Mailing is not functional yet
 -->
+ <style>
+.crm-container .ng-invalid {
+    border: 1px solid black;
+}
+</style>
 
-
-<div class="crm-block crm-form-block "> 
+<form name="mailing_form" class="ng-valid" novalidate ng-submit="mailingForm()">
   <div ui-jq="tabs" id="alltabs">
     <ul>
-      <li><a href="#acttab-0">Recipients</a></li>
-      <li><a href="#acttab-1">Content</a></li>
-      <li><a href="#acttab-2">Schedule and Send</a></li>
+      <li><a href="#acttab-0" ng-click= "recclicked()">Recipients</a></li>
+      <li><a href="#acttab-1" ng-click= "conclicked()">Content</a></li>
+      <li><a href="#acttab-2" ng-click= "schedclicked()">Schedule and Send</a></li>
     </ul>
 
 
     <div id="acttab-0">
       <div ng-include="partialUrl('recipient.html')"></div>
-      <a nexttab class="button" ><span>Next</span></a>
-      <a ng-click="save()" class="button"><span>Save and Continue Later</span></a>
-      <a ng-href="#/mailing" class="button"><span>Cancel</span></a>
+      <button nexttab type= "button"><span>Next</span></button>
+      <button ng-click="save()" ng-disabled="mailing_form.$invalid" type= "submit"><span>Save and Continue Later</span></button>
+      <button ng-click="back()"><span>Cancel</span></button>
       <br><br>       
        </div>
     
     <div id="acttab-1">
       <div ng-include="partialUrl('content.html')"></div>
       <br>
-      <a prevtab class="button" ><span>Previous</span></a>         
-      <a nexttab class="button" ><span>Next</span></a> 
-      <a ng-click="save()" class="button"><span>Save and Continue Later</span></a>
-      <a ng-href="#/mailing" class="button"><span>Cancel</span></a>   
+      <button prevtab type= "button"><span>Previous</span></button>         
+      <button nexttab type= "button"><span>Next</span></button>
+      <button ng-click="save()" ng-disabled="mailing_form.$invalid" type="submit"><span>Save and Continue Later</span></button>
+      <button ng-click="back()" ><span>Cancel</span></button>
       <br><br> 
        </div>
     
     <div id="acttab-2">
       <div ng-include="partialUrl('send.html')"></div>
       <br>
-      <a prevtab class="button" ><span>Previous</span></a>  
-      <a ng-click="save()" class="button"><span>Save and Continue Later</span></a>
-      <a class="button"><span>Submit Mailing</span></a>      
-      <a ng-href="#/mailing" class="button"><span>Cancel</span></a>   
+      <button prevtab type="button" ><span>Previous</span></button>         
+      <button ng-click="save()" ng-disabled="mailing_form.$invalid" type= "submit"><span>Save and Continue Later</span></button>
+      <button> <span>Submit Mailing</span></button>      
+      <button ng-click="back()" ><span>Cancel</span></button>  
                        <br><br>
     </div>
   </div>   
-</div>
+</form>
index f84dc26cbd5c9fa812edd5412d00513d840b6716..900c6f65c0e5460ca7ad9f91fcbf35c6b7b8c453 100644 (file)
@@ -4,7 +4,9 @@ Required vars: currentMailing
 The editor has to be added. Currently just a simple text editor
 -->
 
-<br>
-&nbsp &nbsp &nbsp &nbsp
-<textarea readonly ng-model="currentMailing.body_html" style="width: 600px; height: 300px;"></textarea> 
-<br> <br>
+<iframe width="80%" height="300" src="/siddhant/drupal-7.27/civicrm/mailing/preview?type=html&qfKey=e1adc21bd61fb7e449c48ffe80c4d15c_991" >
+</iframe>
+
+<!--/siddhant/drupal-7.27/civicrm/mailing/preview?type=html&qfKey=e1adc21bd61fb7e449c48ffe80c4d15c_991
+/siddhant/drupal-7.27/civicrm/mailing/preview?type=html&qfKey=e1adc21bd61fb7e449c48ffe80c4d15c_7748
+-->
index dace667c749a7ca1161f0ce3ce22fd86712f92e7..f7ec651eb7e6d4fa5d129b41d2ae4164664e2ba2 100644 (file)
@@ -8,11 +8,16 @@ Remove duplicates not functional
 <table class="form-layout-compressed">
   <tbody>
   <tr>
-    <td class="label">Name your Mailing</td>
+    <td class="label">Name your Mailing *</td>
     <td>
-      <input type="text" ng-model="currentMailing.name"/>
+      <input placeholder="New Mail" name = "name" type="text" required ng-model="currentMailing.name"/>
     </td>
   </tr>
+  <tr> 
+    <td class="label"  style= "color:red" ng-show="mailing_form.name.$invalid">
+                                       Your name is required.
+               </td>
+       </tr>
   <tr>
     <td class="label">Campaign</td>
     <td class="addRow">
index 876948e6ad6046def39fae96bf489f95f9b205c1..c915ba094e144a936dbe732e381e200b2587096b 100644 (file)
@@ -2,7 +2,7 @@
 Controller: MailCtrl
 Required vars: currentMailing
 -->
-
+<!--<script src="../../packages/jquery/plugins/jquery.validate.min.js"><script>-->
 <br>
 <table class="form-layout-compressed">
   <tbody>
@@ -17,7 +17,7 @@ Required vars: currentMailing
   <tr ng-show="now==0">
     <td class="label">Schedule Mailing</td>
     <td>
-                <input type="text" chsdate ng-model="scheddate.date">
+                <input type="text" ng-model="scheddate.date" chsdate >
     </td>
     <td class="label" >Time</td>
                <td>
index 66c1b42d3eca7b8903f1d95acc47d338a1fa1a35..49e4194d72f779d8cbcb84446e6e94d8f25e6ca0 100644 (file)
@@ -41,7 +41,7 @@ Required vars: currentMailing
   </tr>  
   <tr>
     <td>
-      <input type="checkbox" ng-model="trackreplies" ng-true-value="1" ng-false-value="0">&nbsp Track Replies</input>
+      <input type="checkbox" ng-model="trackreplies" ng-change= "reply()" ng-true-value="1" ng-false-value="0">&nbsp Track Replies</input>
     </td>
   </tr>
   <tr>