abtesting/subject_lines.html - Use select2 for "Reply-To"
authorJohn Prescott <john@futurefirst.org.uk>
Thu, 2 Oct 2014 08:57:24 +0000 (09:57 +0100)
committerJohn Prescott <john@futurefirst.org.uk>
Thu, 2 Oct 2014 09:02:53 +0000 (10:02 +0100)
Conflicts:

js/angular-crmMailingAB.js

js/angular-crmMailingAB.js
partials/abtesting/subject_lines.html

index b7cb5180d9ae03827766a66ca6144ac24de04de3..c377ad8d16ba7b073e5700ba2dccee113a9d9cf5 100755 (executable)
 
         $(element).on("click", function () {
           if (scope.tab_val == 0) {
-
             scope.create_abtest();
-
-
           }
           else {
             if (scope.tab_val == 2) {
               scope.a_b_update();
             }
           }
-
           scope.tab_upd();
 
           var myArray1 = [];
             }
           }
 
-
           scope.$apply();
           e.preventDefault();
         })
     };
   });
 
-  crmMailingAB.directive('stopa', function () {
+  crmMailingAB.directive('replytoselect',function(){
+    return {
+      restrict : 'AE',
+      link: function(scope, element, attrs){
+          
+        function format(item){ 
+            return item.label.replace(/&/g, '&amp;')
+            .replace(/"/g, '&quot;')
+            .replace(/</g, '&lt;')
+            .replace(/>/g, '&gt;');
+        }
+          
+        CRM.api3('OptionGroup', 'get', {
+          "sequential": 1,
+          "name": "from_email_address"
+        }).done(function(result) {
+          var emailGroupId = result.id;
+          console.log(result);
+           CRM.api3('OptionValue', 'get', {
+            "sequential": 1,
+            "option_group_id": result.id
+          }).done(function(orgEmails) {
+              console.log(orgEmails);
+              
+              //$sce.trustAsHtml(
+          
+            $(element).select2({width:"200px", 
+                data: orgEmails.values,           
+                formatResult: format,
+              formatSelection: format,
+              placeholder:"Select reply to address"});
+          
+          });
+          
+        });  
+                    
+
+      }
+    };
+  });
+
+  crmMailingAB.directive('stopa',function(){
     return {
       restrict: 'AE',
       link: function (scope, element, attrs) {
index 9d72d536c0dc438a63a3bf15a4aece2cad361d70..45678192a7b3c6b7081c620f7053f73cbfc93968 100755 (executable)
   <tr>
     <td class="label">Reply to E-mail Address</td>
     <td>
-      <select style="width: 200px" ng-model="mailA.replyto_email"
-              ng-options="frm.email as frm.email for frm in eMailing" >
-        <option value="">-none-</option>
-      </select>
+      <input type="hidden" replytoselect id= "replyToEmail"   ng-model="mailA.replyto_email"
+              ng-options="frm.email as frm.email for frm in eMailing" />
     </td>
   </tr>
   <tr>