changed listing removed group code
authoraditya-nambiar <aditya.nambiar007@gmail.com>
Mon, 18 Aug 2014 11:12:27 +0000 (16:42 +0530)
committeraditya-nambiar <aditya.nambiar007@gmail.com>
Mon, 18 Aug 2014 11:12:27 +0000 (16:42 +0530)
js/angular-crmMailingAB.js
partials/abtesting/list.html

index d468f9bd16aa68b5ac22779b912df2ae5a2ee911..93ee512fd3235f9501e5073d0db159e43d700f85 100755 (executable)
@@ -9,9 +9,7 @@
   var mltokens = [];
   var crmMailingAB = angular.module('crmMailingAB', ['ngRoute', 'ui.utils', 'ngSanitize']);
   var mltokens = [];
-  var chck = []; //to fill the group variable $scope.incGroup
-  var chck2= []; // to get id and text in the required format
-  var chck3= [];
+
   crmMailingAB.run(function ($rootScope, $templateCache) {
     $rootScope.$on('$viewContentLoaded', function () {
       $templateCache.removeAll();
@@ -24,8 +22,8 @@
         templateUrl: partialUrl('list.html'),
         controller: 'ABListingCtrl',
         resolve: {
-          mailingList: function ($route, crmApi) {
-            return crmApi('Mailing', 'get', {});
+          mailingABList: function ($route, crmApi) {
+            return crmApi('MailingAB', 'get', {});
           }
         }
       });
@@ -62,8 +60,8 @@
 //-----------------------------------------
   // Add a new record by name.
   // Ex: <crmAddName crm-options="['Alpha','Beta','Gamma']" crm-var="newItem" crm-on-add="callMyCreateFunction(newItem)" />
-  crmMailingAB.controller('ABListingCtrl', function ($scope, crmApi) {
-    $scope.abmailList = CRM.crmMailing.mailingabNames;
+  crmMailingAB.controller('ABListingCtrl', function ($scope, crmApi,mailingABList) {
+    $scope.mailingABList = mailingABList.values;
   });
 
   crmMailingAB.controller('ReportCtrl', function ($scope, crmApi, selectedABTest) {
       $scope.currentABTest.time = $scope.ans[1];
     }
     $scope.token = [];
-    chck = [];
-    chck2 = [];
-    chck3=[];
+
     if ($scope.currentABTest.just_created != 1) {
       $scope.abId = $scope.currentABTest.id;
       $scope.sparestuff.isnew = false;
       abmailC.success(function (data) {
         if (data.is_error == 0) {
           $scope.mailC = data;
-          for(var a in $scope.mailingGrp){
-            console.log("youuo");
-            if($scope.mailingGrp[a].mailing_id==$scope.mailC.id){
-              console.log($scope.mailingGrp[a]);
-              var b = $scope.mailingGrp[a].entity_id + " " + $scope.mailingGrp[a].entity_table +" " + $scope.mailingGrp[a].group_type;
-              var c = $scope.mailingGrp[a].id;
-              chck.push(b);
-              $scope.mailid.push(c);
-            }
-          }
-          for(var a in chck)
-          {    var b ={}
-            b.id = chck[a];
-            var splt = chck[a].split(" ");
-
-            if(splt[1] == "civicrm_group"){
-              for(var c in $scope.groups){
-                if($scope.groups[c].id==splt[0]){
-                  b.text = $scope.groups[c].title;
-                }
-              }
-            }
-            if(splt[1] == "civicrm_mailing"){
-              for(var c in $scope.mailList){
-                if($scope.mailList[c].id==splt[0]){
-                  b.text = $scope.mailList[c].name;
-                }
-              }
-            }
-            chck2.push(b);
-          }
-          for(var a in chck2){
-            var b =chck2[a];
 
-            chck3.push(b.id+" "+ b.text);
-          }
-          console.log("yooyo");
-          console.log(chck);
-          console.log(chck2);
-          console.log(chck3);
-          $scope.sparestuff.allgroups = chck3;
 
         }
       });
           }
         }).select2("data", scope.sparestuff.allgroups);
 
-        $(element).on("select2-opening", function()
-        {      scope.sparestuff.allgroups=chck3;
-
-          scope.$apply();
-
-        });
 
         $(element).on('select2-selecting', function (e) {
           var a = e.val.split(" ");
             scope.excGroupids.push(a[0]);
             scope.$apply();
           }
-          chck3.push(e.val);
-          scope.sparestuff.allgroups=chck3;
+
           scope.$apply();
          // console.log(scope.incGroup);
 
             scope.incGroupids.splice(index, 1);
             scope.$apply();
           }
-          var index = chck3.indexOf(e.val);
-          chck3.splice(index, 1);
-          scope.sparestuff.allgroups=chck3;
+
          // console.log(scope.incGroup);
           scope.$apply();
         });
index 7c1b708a8d0979f20cff702ca08ef232413dca83..2bbf187342ea1d1450d804066fa92552e0459709 100755 (executable)
@@ -1,12 +1,12 @@
 <!--
 Controller: ABListingCtrl
-Required vars: abmailList
+Required vars: mailingABList
 -->
 <div id="help">
   A/B Testing list
 </div>
 
-<div ng-show="abmailList.length > 0">
+<div ng-show="!$.isEmptyObject(mailingABList)">
   <table class="display">
     <thead>
     <tr>
@@ -18,7 +18,7 @@ Required vars: abmailList
     </tr>
     </thead>
     <tbody>
-    <tr ng-repeat="ab in abmailList">
+    <tr ng-repeat="ab in mailingABList">
       <td>{{ab.name}}</td>
       <td>{{ab.id}}</td>
       <td><a class="action-item crm-hover-button" ng-href="#/mailing/abtesting/{{ab.id}}">Edit</a>&nbsp
@@ -29,7 +29,7 @@ Required vars: abmailList
   </table>
 </div>
 
-<div ng-show="abmailList.length == 0" class="messages status no-popup">
+<div ng-show="$.isEmptyObject(mailingABList)" class="messages status no-popup">
   <div class="icon inform-icon"></div>
   You have no A/B mailings
 </div>