Updated: Angularjs to v1.2.0 final.
Updated: Loading-bar to v0.0.5 Updated: Using the $promise of function to return promises instead of $q and callback function.
This commit is contained in:
1 parent
4ace61cdee
commit
d1a4fc1164
58 files changed
+4920
-3164
No files matched your search
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var PurchaseReturnCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'voucher', 'Account', 'Batch', function ($scope, $location, $q, dateFilter, $modal, voucher, Account, Batch) {
|
||||
var PurchaseReturnCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'voucher', 'Account', 'Batch', function ($scope, $location, dateFilter, $modal, voucher, Account, Batch) {
|
||||
$scope.voucher = voucher;
|
||||
$scope.rate = 0;
|
||||
function getOldInventory(productID, inventories) {
|
||||
@@ -158,48 +158,33 @@ var PurchaseReturnCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', '
|
||||
};
|
||||
|
||||
$scope.accounts = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Account.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
return Account.autocomplete({term: $viewValue, count: 20, a:true}).$promise;
|
||||
};
|
||||
$scope.batches = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
var params = {term: $viewValue, count: 20};
|
||||
|
||||
if (angular.isDate($scope.voucher.Date)) {
|
||||
params.date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
|
||||
} else {
|
||||
params.date = $scope.voucher.Date;
|
||||
}
|
||||
Batch.autocomplete(params, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
return Batch.autocomplete(params).$promise;
|
||||
};
|
||||
}];
|
||||
|
||||
PurchaseReturnCtrl.resolve = {
|
||||
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
voucher: ['$route', 'Voucher', function ($route, Voucher) {
|
||||
var id = $route.current.params.id;
|
||||
|
||||
var successCb = function (result) {
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof id === 'undefined') {
|
||||
Voucher.get({type: 'Purchase Return'}, successCb);
|
||||
return Voucher.get({type: 'Purchase Return'}).$promise;
|
||||
} else {
|
||||
Voucher.get({id: id}, successCb);
|
||||
return Voucher.get({id: id}).$promise;
|
||||
}
|
||||
return deferred.promise;
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
var PurchaseReturnModalCtrl = ['$scope', '$modalInstance', '$q', 'edit', 'Batch', function ($scope, $modalInstance, $q, edit, Batch) {
|
||||
var PurchaseReturnModalCtrl = ['$scope', '$modalInstance', 'edit', 'Batch', function ($scope, $modalInstance, edit, Batch) {
|
||||
$scope.edit = edit;
|
||||
$scope.ok = function () {
|
||||
$scope.edit.Product = $scope.edit.Batch.Product;
|
||||
@@ -214,10 +199,6 @@ var PurchaseReturnModalCtrl = ['$scope', '$modalInstance', '$q', 'edit', 'Batch'
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
$scope.batches = function ($viewValue) {
|
||||
var deferred = $q.defer();
|
||||
Batch.autocomplete({term: $viewValue, count: 20}, function (result) {
|
||||
deferred.resolve(result);
|
||||
});
|
||||
return deferred.promise;
|
||||
return Batch.autocomplete({term: $viewValue, count: 20}).$promise;
|
||||
};
|
||||
}]
|
||||
}];
|
||||
Reference in new issue
Block a user