Commit b97bc56e0f537d5fa6d8091575990f3f73d9fe4e

Authored by Swarn Singh
1 parent eefc1c74d9
Exists in master

table search and sort issue resolved

app/partials/customers/customers.controller.js
... ... @@ -35,7 +35,7 @@
35 35 {id: "false", title: "Inactive"}
36 36 ]
37 37  
38   - function getAllCompanies(){
  38 + /*function getAllCompanies(){
39 39 $scope.displayCompanyList = new NgTableParams({
40 40 page: 1,
41 41 count: 10
... ... @@ -57,9 +57,40 @@
57 57 })
58 58 }
59 59 });
  60 + }*/
  61 +
  62 + function getAllCompanies(){
  63 + CustomersService.getAllCompanies().then(function(result) {
  64 + console.log('log', result);
  65 + $scope.companyList = result;
  66 + for (var i = 0; i < $scope.companyList.length; i++) {
  67 + if ($scope.companyList[i].companyContact != null) {
  68 + if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) {
  69 + $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber;
  70 + }
  71 + }
  72 + if ($scope.companyList[i].primaryContact != null) {
  73 + if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) {
  74 + $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName;
  75 + }
  76 + }
  77 + if ($scope.companyList[i].margin != null) {
  78 + if ($scope.companyList[i].margin.marginName != null) {
  79 + $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id;
  80 + }
  81 + }
  82 + }
  83 + $scope.displayCompanyList = new NgTableParams({
  84 + page: 1,
  85 + count: 10,
  86 + }, {
  87 + data: $scope.companyList
  88 + });
  89 + })
60 90 }
61 91  
62 92 $scope.editMargin = function(customer){
  93 + console.log('customer', customer);
63 94 event.stopPropagation();
64 95  
65 96 var companyMargin = "companyName=" + customer.companyName + "&masterMargin=" + customer.masterMargin
... ...
app/partials/customers/customers.html
... ... @@ -108,11 +108,11 @@
108 108 <td data-title="'Fleet'" filter="{companyAircraftSize: 'text'}" sortable="'companyAircraftSize'">
109 109 {{row.companyAircraftSize}}
110 110 </td>
111   - <td data-title="'Main Phone'" filter="{companyCustomContacts: 'text'}" sortable="'companyCustomContacts[0].contactNumber'">
112   - {{row.companyCustomContacts[0].contactNumber}}
  111 + <td data-title="'Main Phone'" filter="{newContactNumber: 'text'}" sortable="'newContactNumber'">
  112 + {{row.newContactNumber}}
113 113 </td>
114   - <td data-title="'Primary Contact'" filter="{companyPrimaryContacts: 'text'}" sortable="'companyPrimaryContacts[0].firstName && companyPrimaryContacts[0].lastName'">
115   - {{row.companyPrimaryContacts[0].firstName}} {{row.companyPrimaryContacts[0].lastName}}
  114 + <td data-title="'Primary Contact'" filter="{primaryContactName: 'text'}" sortable="'primaryContactName'">
  115 + {{row.primaryContactName}}
116 116 </td>
117 117 <td data-title="'Base'" filter="{baseIcao: 'text'}" sortable="'baseIcao'">
118 118 {{row.baseIcao}}
... ... @@ -122,7 +122,7 @@
122 122 <button type="button" ng-if="row.activate == false" class="btn btn-warning btn-xs">InActive</button>
123 123 </td>
124 124 <td data-title="'Margin Setting'" filter="{masterMargin: 'select'}" sortable="'masterMargin'">
125   - <select class="form-control" ng-click="editMargin(row)" style="height:31px;" ng-model="row.masterMargin" ng-options="margin.id as margin.marginName for margin in marginList" required></select>
  125 + <select class="form-control" ng-click="editMargin(row)" style="height:31px;" ng-model="row.masterMargin" ng-selected="" ng-options="margin.id as margin.marginName for margin in marginList" required></select>
126 126 </td>
127 127 <td data-title="'All In'" filter="{allIn: 'text'}" sortable="'allIn'">
128 128 {{row.allIn}}
... ...