Commit 359303f5328008312b1a6bbea2b00fdfdbaf41b1
1 parent
ea94f521f2
Exists in
master
Adding company/aircrafts -#87uwt(testing)
Showing
2 changed files
with
36 additions
and
26 deletions
Show diff stats
app/partials/viewCompany/viewCompany.controller.js
... | ... | @@ -245,6 +245,7 @@ angular.module('acufuel') |
245 | 245 | ViewCompanyService.getAircraft(companyId).then(function(result) { |
246 | 246 | |
247 | 247 | $scope.contactAircraftList = result; |
248 | + console.log("===contactAircraftList===",result) | |
248 | 249 | for (var i = 0; i < $scope.contactAircraftList.length; i++) { |
249 | 250 | if ($scope.contactAircraftList[i].aircraftsMargin != null) { |
250 | 251 | $scope.aircraftmargins.push({ |
... | ... | @@ -295,8 +296,6 @@ angular.module('acufuel') |
295 | 296 | getContactList(); |
296 | 297 | $scope.contactData.contactList = []; |
297 | 298 | $scope.data.email = ''; |
298 | - //console.log("data2==",$scope.contactData) | |
299 | - //toastr.success(''+result.success+'', { | |
300 | 299 | toastr.success('Created Successfully', { |
301 | 300 | closeButton: true |
302 | 301 | }) |
... | ... | @@ -388,10 +387,14 @@ angular.module('acufuel') |
388 | 387 | } |
389 | 388 | |
390 | 389 | $scope.aircraftListData = {}; |
391 | - //$scope.addData = []; | |
390 | + $scope.addData = []; | |
391 | + $scope.tailArray = []; | |
392 | + function check(array){ | |
393 | + return (new Set(array)).size !== array.length; | |
394 | + } | |
392 | 395 | $scope.saveCompanyData = function() { |
396 | + $scope.tailArray = []; | |
393 | 397 | for (var i = 0; i < $scope.aircraftDetails.length; i++) { |
394 | - $scope.addData = []; | |
395 | 398 | $scope.addData.push({ |
396 | 399 | 'tail': $scope.aircraftDetails[i].tail, |
397 | 400 | 'make': $scope.aircraftDetails[i].make, |
... | ... | @@ -400,25 +403,31 @@ angular.module('acufuel') |
400 | 403 | 'marginId': $scope.aircraftDetails[i].marginId, |
401 | 404 | 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId |
402 | 405 | }); |
406 | + $scope.tailArray.push($scope.aircraftDetails[i].tail); | |
407 | + } | |
408 | + console.log('check', check($scope.tailArray)); | |
409 | + if (check($scope.tailArray)) { | |
410 | + toastr.error('Duplicate Tail Added.', { | |
411 | + closeButton: true | |
412 | + }) | |
413 | + }else{ | |
414 | + $scope.aircraftListData.aircraftList = $scope.addData; | |
415 | + $scope.aircraftListData.accountId = companyId; | |
416 | + CustomersService.addAircraft($scope.aircraftListData).then(function(result) { | |
417 | + if (result != null && result.success) { | |
418 | + toastr.success('' + result.success + '', { | |
419 | + closeButton: true | |
420 | + }) | |
421 | + $('#aircraft-modal-3').css('display', 'none'); | |
422 | + $('.modal-backdrop').css('display', 'none'); | |
423 | + getAircraftList(); | |
424 | + } else { | |
425 | + toastr.error('' + result.statusText + '', { | |
426 | + closeButton: true | |
427 | + }) | |
428 | + } | |
429 | + }); | |
403 | 430 | } |
404 | - //console.log($scope.addData) | |
405 | - $scope.aircraftListData.aircraftList = $scope.addData; | |
406 | - $scope.aircraftListData.accountId = companyId; | |
407 | - | |
408 | - CustomersService.addAircraft($scope.aircraftListData).then(function(result) { | |
409 | - if (result != null && result.success) { | |
410 | - toastr.success('' + result.success + '', { | |
411 | - closeButton: true | |
412 | - }) | |
413 | - $('#aircraft-modal-3').css('display', 'none'); | |
414 | - $('.modal-backdrop').css('display', 'none'); | |
415 | - getAircraftList(); | |
416 | - } else { | |
417 | - toastr.error('' + result.statusText + '', { | |
418 | - closeButton: true | |
419 | - }) | |
420 | - } | |
421 | - }); | |
422 | 431 | |
423 | 432 | } |
424 | 433 | ... | ... |
app/partials/viewCompany/viewCompany.html
... | ... | @@ -340,7 +340,7 @@ |
340 | 340 | <div class="widget" style="min-height: 350px;"> |
341 | 341 | <div class="widget-header"> |
342 | 342 | <i class="fa fa-plane"></i> |
343 | - <h3>Aircraft List</h3> | |
343 | + <h3>Aircraft List kd</h3> | |
344 | 344 | <div class="pull-right"> |
345 | 345 | <button type="submit" class="btn btn-success btn-sm" data-toggle="modal" ng-click="clearAircrafts()" data-target="#aircraft-modal-3" style="margin-top: 4px; margin-right: 9px;"><i class="fa fa-plus" aria-hidden="true"></i> Add Aircraft </button> |
346 | 346 | </div> |
... | ... | @@ -593,7 +593,7 @@ |
593 | 593 | </div> |
594 | 594 | </div> |
595 | 595 | <div class="clearfix"></div><br> |
596 | - <div class="col-xs-12"> | |
596 | + <!-- <div class="col-xs-12"> | |
597 | 597 | <div class="col-md-12"> |
598 | 598 | <div class="pull-left" style="width: 110px;"> |
599 | 599 | <label class="new-input-label"><b>Address</b></label> |
... | ... | @@ -604,7 +604,7 @@ |
604 | 604 | <div class="clearfix"></div> |
605 | 605 | </div> |
606 | 606 | </div> |
607 | - <div class="clearfix"></div> | |
607 | + <div class="clearfix"></div> --> | |
608 | 608 | <br/> |
609 | 609 | <div class="col-xs-12"> |
610 | 610 | <div class="col-md-3"> |
... | ... | @@ -811,7 +811,7 @@ |
811 | 811 | <input type="tel" class="form-control" ng-model="aircraftData.tail" ng-blur="checkTail(aircraftData.tail, $index);" required/> |
812 | 812 | </td> |
813 | 813 | <td style="width: 17%"> |
814 | - <select class="form-control" ng-model="aircraftData.make" ng-change="getModal(aircraftData.make, $index) "> | |
814 | + <select class="form-control" style="width: fit-content;" ng-model="aircraftData.make" ng-change="getModal(aircraftData.make, $index) "> | |
815 | 815 | <option value="" disabled>Select</option> |
816 | 816 | <option ng-repeat="make in aircraftMakeList | orderBy">{{make}}</option> |
817 | 817 | </select> |
... | ... | @@ -872,6 +872,7 @@ |
872 | 872 | </div> |
873 | 873 | </div> |
874 | 874 | </div> |
875 | + | |
875 | 876 | <div class="modal-footer" style="border-top: 0;"> |
876 | 877 | <button type="button" class="btn btn-default" id="reset" data-dismiss="modal">Cancel</button> |
877 | 878 | <button type="button" class="btn btn-primary step step-1" data-step="1" ng-disabled="aircraftForm.$invalid" ng-click="saveCompanyData()">Save</button> | ... | ... |