Chore: Major variable renaming from python style underscores to camel case.

Chore: Replace undefined checks with angular.isUndefined
This commit is contained in:
Amritanshu
2014-06-06 16:09:32 +05:30
parent 358b235d8f
commit f667481d71
50 changed files with 494 additions and 576 deletions

View File

@ -1,6 +1,6 @@
'use strict';
var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImageResizer', 'voucher', 'Account', function ($scope, $location, dateFilter, $modal, UploadedImageResizer, voucher, Account) {
var JournalCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uploadedImageResizer', 'voucher', 'Account', function ($scope, $location, asDate, $modal, uploadedImageResizer, voucher, Account) {
$('#txtAccount').focus();
$scope.voucher = voucher;
@ -12,7 +12,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}
$scope.$on("fileSelected", function (event, args) {
UploadedImageResizer(args, $scope.voucher.Files);
uploadedImageResizer(args, $scope.voucher.Files);
});
@ -39,7 +39,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
return;
}
var oldJournal = getOld($scope.account.LedgerID, this.voucher.Journals);
if (typeof oldJournal !== 'undefined') {
if (!angular.isUndefined(oldJournal)) {
var amount = (oldJournal.Debit * oldJournal.Amount) + (parseInt($scope.debit) * Number($scope.amount));
if (amount < 0) {
oldJournal.Debit = -1;
@ -61,7 +61,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
this.voucher.Journals.splice(index, 1);
};
$scope.$watch('voucher.Journals', function (journals, oldValue) {
$scope.$watch('voucher.Journals', function (journals) {
if (!angular.isArray(journals)) {
return;
}
@ -72,9 +72,9 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}, true);
$scope.preventAlteration = function (voucher) {
if (typeof $scope.perms === 'undefined') {
if (angular.isUndefined($scope.perms)) {
return false;
} else if (typeof voucher.VoucherID === 'undefined') {
} else if (angular.isUndefined(voucher.VoucherID)) {
return !$scope.perms['Journal'];
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
return true;
@ -85,18 +85,8 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
}
};
$scope.get = function (voucherid) {
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.save = function () {
if (angular.isDate($scope.voucher.Date)) {
$scope.voucher.Date = dateFilter($scope.voucher.Date, 'dd-MMM-yyyy');
}
$scope.voucher.Date = asDate($scope.voucher.Date);
return $scope.voucher.$save({type: 'Journal'}, function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/Journal/' + u.VoucherID);
@ -137,7 +127,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
modalInstance.result.then(function (updated) {
if (updated.Ledger.LedgerID !== $scope.selectedJournal.Ledger.LedgerID) {
var oldJournal = getOld(updated.Ledger.LedgerID, $scope.voucher.Journals);
if (typeof oldJournal !== 'undefined') {
if (!angular.isUndefined(oldJournal)) {
delete $scope.selectedJournal;
return false;
}
@ -179,7 +169,7 @@ var JournalCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'UploadedImage
JournalCtrl.resolve = {
voucher: ['$route', 'Voucher', function ($route, Voucher) {
var id = $route.current.params.id;
if (typeof id === 'undefined') {
if (angular.isUndefined(id)) {
return Voucher.get({type: 'Journal'}).$promise;
} else {
return Voucher.get({id: id}).$promise;