1app.directive('consignorSelector', function () { 2 return { 3 templateUrl: 'app/directives/consignorSelector.html', 4 restrict: 'EA', 5 scope: { 6 selectedConsignors: '=', 7 checkForActiveAuctionItems: '=' 8 }, 9 controller: 'consignorSelectorController', 10 controllerAs: 'vm', 11 bindToController: true 12 } 13}); 14 15 16app.controller('consignorSelectorController', ['$scope', 'lists', 'consignorsService', 'localStorageService', '$ngConfirm', 17 function ($scope, lists, consignorsService, localStorageService, $ngConfirm) { 18 var vm = this; 19 20 $scope.$watch('vm.selectedConsignors', function (newValue, oldValue) { 21 vm.getConsignors(); 22 }); 23 24 vm.getConsignors = function () { 25 26 consignorsService.getConsignors('{}', '[Name]', 'ASC', 1, 10000, false).then(function (results) { 27 vm.consignors = results.data.consignors; 28 29 $.each(vm.consignors, function (consignorIndex, consignor) { 30 consignor.isSelected = false; 31 }); 32 33 $.each(vm.selectedConsignors, function (selectedConsignorIndex, selectedConsignor) { 34 $.each(vm.consignors, function (consignorIndex, consignor) { 35 if (consignor.consignorId == selectedConsignor.consignorId) { 36 consignor.isSelected = true; 37 return false; 38 } 39 }); 40 }); 41 42 }, function (error) { 43 popApiErrorMessage(error); 44 }); 45 46 }; 47 48 vm.removeSelectedConsignor = function (consignorIndexToRemove, consignorToRemove) { 49 50 if (vm.checkForActiveAuctionItems && vm.selectedConsignors && vm.selectedConsignors[consignorIndexToRemove].hasActiveAuctionItems) { 51 52 $ngConfirm({ 53 closeIcon: false, 54 title: 'Cannot Remove Consignor', 55 icon: 'fa fa-warning text-danger', 56 content: 'The consignor cannot be removed since it has active lots in the auction.', 57 scope: $scope, 58 buttons: { 59 cancel: { 60 text: 'Cancel', 61 btnClass: 'btn-warning', 62 action: function (buttonScope, button) { 63 // Do nothing 64 } 65 } 66 } 67 }); 68 69 } else { 70 // Splice out the consignor 71 vm.selectedConsignors.splice(consignorIndexToRemove, 1); 72 73 $.each(vm.consignors, function (consignorIndex, consignor) { 74 if (consignor.consignorId == consignorToRemove.consignorId) { 75 consignor.isSelected = false; 76 return false; 77 } 78 }); 79 } 80 81 82 }; 83 84 vm.addSelectedConsignor = function (consignor) { 85 // See if the consignor is already selected 86 var consignorAlreadyExists = false; 87 $.each(vm.selectedConsignors, function (consignorIndex, consignorItem) { 88 if (consignorItem.consignorId == consignor.consignorId) { 89 consignorAlreadyExists = true; 90 return false; 91 } 92 }); 93 94 // Add the consignor 95 if (!consignorAlreadyExists) { 96 vm.selectedConsignors.push(consignor); 97 consignor.isSelected = true; 98 } else { 99 popMessage("warning", "Consignor Selected", "The consingor is already selected."); 100 } 101 }; 102 103 vm.consignorSearchText = ""; 104 vm.consignors = []; 105 106 vm.user = localStorageService.get('AuthData'); 107 108 vm.icons = lists.icons; 109 }]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.