Style with jscs.
This commit is contained in:
parent
655d72d4ae
commit
e5721b3573
35
.jscsrc
Normal file
35
.jscsrc
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"preset": "google",
|
||||||
|
"fileExtensions": [".js", "jscs"],
|
||||||
|
|
||||||
|
"requireSemicolons": true,
|
||||||
|
"requireParenthesesAroundIIFE": true,
|
||||||
|
"maximumLineLength": 120,
|
||||||
|
"validateLineBreaks": "LF",
|
||||||
|
"validateIndentation": 4,
|
||||||
|
"disallowTrailingComma": true,
|
||||||
|
"disallowUnusedParams": true,
|
||||||
|
|
||||||
|
"disallowSpacesInsideObjectBrackets": null,
|
||||||
|
"disallowImplicitTypeConversion": ["string"],
|
||||||
|
|
||||||
|
"safeContextKeyword": "_this",
|
||||||
|
|
||||||
|
"jsDoc": {
|
||||||
|
"checkAnnotations": "closurecompiler",
|
||||||
|
"checkParamNames": true,
|
||||||
|
"requireParamTypes": true,
|
||||||
|
"checkRedundantParams": true,
|
||||||
|
"checkReturnTypes": true,
|
||||||
|
"checkRedundantReturns": true,
|
||||||
|
"requireReturnTypes": true,
|
||||||
|
"checkTypes": "capitalizedNativeCase",
|
||||||
|
"checkRedundantAccess": true,
|
||||||
|
"requireNewlineAfterDescription": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"excludeFiles": [
|
||||||
|
"test/data/**",
|
||||||
|
"patterns/*"
|
||||||
|
]
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
// vim: set tw=80 ts=4 sw=4 sts=4:
|
||||||
/*
|
/*
|
||||||
This file is part of Accountant.
|
This file is part of Accountant.
|
||||||
|
|
||||||
@ -14,7 +15,6 @@
|
|||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
// vim: set tw=80 ts=2 sw=2 sts=2:
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('accountant.accounts', [
|
angular.module('accountant.accounts', [
|
||||||
@ -66,30 +66,36 @@ angular.module('accountant.accounts', [
|
|||||||
* overdraft.
|
* overdraft.
|
||||||
*/
|
*/
|
||||||
$scope.rowClass = function(account) {
|
$scope.rowClass = function(account) {
|
||||||
if(!account || !account.authorized_overdraft || !account.current) {
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
if (!account || !account.authorized_overdraft || !account.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
|
||||||
if(account.current < account.authorized_overdraft) {
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
if (account.current < account.authorized_overdraft) {
|
||||||
return 'danger';
|
return 'danger';
|
||||||
} else if(account.current < 0) {
|
} else if (account.current < 0) {
|
||||||
return 'warning';
|
return 'warning';
|
||||||
}
|
}
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the class for a value compared to account authorized overdraft.
|
* Return the class for a value compared to account authorized overdraft.
|
||||||
*/
|
*/
|
||||||
$scope.valueClass = function(account, value) {
|
$scope.valueClass = function(account, value) {
|
||||||
if(!account || !value) {
|
if (!account || !value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(value < account.authorized_overdraft) {
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
if (value < account.authorized_overdraft) {
|
||||||
return 'text-danger';
|
return 'text-danger';
|
||||||
} else if(value < 0) {
|
} else if (value < 0) {
|
||||||
return 'text-warning';
|
return 'text-warning';
|
||||||
}
|
}
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -97,7 +103,9 @@ angular.module('accountant.accounts', [
|
|||||||
*/
|
*/
|
||||||
$scope.add = function() {
|
$scope.add = function() {
|
||||||
var account = new Account({
|
var account = new Account({
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
authorized_overdraft: 0
|
authorized_overdraft: 0
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
});
|
});
|
||||||
|
|
||||||
// Insert account at the begining of the array.
|
// Insert account at the begining of the array.
|
||||||
@ -108,7 +116,7 @@ angular.module('accountant.accounts', [
|
|||||||
* Cancel account edition. Remove it from array if a new one.
|
* Cancel account edition. Remove it from array if a new one.
|
||||||
*/
|
*/
|
||||||
$scope.cancelEdit = function(rowform, account, $index) {
|
$scope.cancelEdit = function(rowform, account, $index) {
|
||||||
if(!account.id) {
|
if (!account.id) {
|
||||||
// Account not saved, just remove it from array.
|
// Account not saved, just remove it from array.
|
||||||
$scope.accounts.splice($index, 1);
|
$scope.accounts.splice($index, 1);
|
||||||
} else {
|
} else {
|
||||||
@ -142,7 +150,7 @@ angular.module('accountant.accounts', [
|
|||||||
$ngBootbox.confirm(
|
$ngBootbox.confirm(
|
||||||
'Voulez-vous supprimer le compte \'' + account.name + '\' ?',
|
'Voulez-vous supprimer le compte \'' + account.name + '\' ?',
|
||||||
function(result) {
|
function(result) {
|
||||||
if(result) {
|
if (result) {
|
||||||
account.$delete().then(function() {
|
account.$delete().then(function() {
|
||||||
Notification.success('Account #' + id + ' deleted.');
|
Notification.success('Account #' + id + ' deleted.');
|
||||||
|
|
||||||
@ -169,7 +177,7 @@ angular.module('accountant.accounts', [
|
|||||||
link: function(scope, element) {
|
link: function(scope, element) {
|
||||||
var title = 'Account';
|
var title = 'Account';
|
||||||
|
|
||||||
if(scope.account && scope.account.id) {
|
if (scope.account && scope.account.id) {
|
||||||
title = title + ' #' + scope.account.id;
|
title = title + ' #' + scope.account.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +190,9 @@ angular.module('accountant.accounts', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Authorized overdraft is a positive integer but data is a negative integer.
|
// Authorized overdraft is a positive integer but data is a negative integer.
|
||||||
scope.data.authorized_overdraft = -scope.data.authorized_overdraft
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
scope.data.authorized_overdraft = -scope.data.authorized_overdraft;
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
|
||||||
angular.copy(scope.data, scope.account);
|
angular.copy(scope.data, scope.account);
|
||||||
|
|
||||||
@ -206,9 +216,11 @@ angular.module('accountant.accounts', [
|
|||||||
|
|
||||||
element.on('click', function() {
|
element.on('click', function() {
|
||||||
// Create new account if not passed in ng-model.
|
// Create new account if not passed in ng-model.
|
||||||
if(!scope.account) {
|
if (!scope.account) {
|
||||||
scope.account = new Account({
|
scope.account = new Account({
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
authorized_overdraft: 0
|
authorized_overdraft: 0
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +228,9 @@ angular.module('accountant.accounts', [
|
|||||||
angular.copy(scope.account, scope.data);
|
angular.copy(scope.account, scope.data);
|
||||||
|
|
||||||
// Authorized overdraft must be positive in form.
|
// Authorized overdraft must be positive in form.
|
||||||
scope.data.authorized_overdraft = -scope.data.authorized_overdraft
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
scope.data.authorized_overdraft = -scope.data.authorized_overdraft;
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
|
||||||
// Open dialog with form.
|
// Open dialog with form.
|
||||||
$ngBootbox.customDialog({
|
$ngBootbox.customDialog({
|
||||||
@ -240,4 +254,5 @@ angular.module('accountant.accounts', [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// vim: set tw=80 ts=4 sw=4 sts=4:
|
||||||
/*
|
/*
|
||||||
This file is part of Accountant.
|
This file is part of Accountant.
|
||||||
|
|
||||||
@ -14,7 +15,6 @@
|
|||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
// vim: set tw=80 ts=2 sw=2 sts=2:
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('accountant', [
|
angular.module('accountant', [
|
||||||
@ -29,12 +29,12 @@ angular.module('accountant', [
|
|||||||
|
|
||||||
.factory('sessionInjector', ['$storage', function($storage) {
|
.factory('sessionInjector', ['$storage', function($storage) {
|
||||||
var sessionInjector = {
|
var sessionInjector = {
|
||||||
request : function(config) {
|
request: function(config) {
|
||||||
var token = $storage.get('token');
|
var token = $storage.get('token');
|
||||||
|
|
||||||
if(token) {
|
if (token) {
|
||||||
var token_type = $storage.get('token_type');
|
var tokenType = $storage.get('token_type');
|
||||||
var authorization = token_type + ' ' + token;
|
var authorization = tokenType + ' ' + token;
|
||||||
config.headers.Authorization = authorization;
|
config.headers.Authorization = authorization;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,6 @@ angular.module('accountant', [
|
|||||||
.otherwise({
|
.otherwise({
|
||||||
redirectTo: '/accounts'
|
redirectTo: '/accounts'
|
||||||
});
|
});
|
||||||
|
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.config(['$storageProvider', function($storageProvider) {
|
.config(['$storageProvider', function($storageProvider) {
|
||||||
@ -99,7 +98,7 @@ angular.module('accountant', [
|
|||||||
|
|
||||||
$scope.showLoginForm = function() {
|
$scope.showLoginForm = function() {
|
||||||
// First, if there are registered credentials, use them
|
// First, if there are registered credentials, use them
|
||||||
if($scope.dialogShown) {
|
if ($scope.dialogShown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,9 +127,13 @@ angular.module('accountant', [
|
|||||||
).success(function(result) {
|
).success(function(result) {
|
||||||
// TODO Alexis Lahouze 2015-08-28 Handle callback.
|
// TODO Alexis Lahouze 2015-08-28 Handle callback.
|
||||||
// Call to /api/login to retrieve the token
|
// Call to /api/login to retrieve the token
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
$storage.set('token_type', result.token_type);
|
$storage.set('token_type', result.token_type);
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
$storage.set('token', result.token);
|
$storage.set('token', result.token);
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
$storage.set('expiration_date', result.expiration_date);
|
$storage.set('expiration_date', result.expiration_date);
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
|
||||||
authService.loginConfirmed();
|
authService.loginConfirmed();
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// vim: set tw=80 ts=4 sw=4 sts=4:
|
||||||
/*
|
/*
|
||||||
This file is part of Accountant.
|
This file is part of Accountant.
|
||||||
|
|
||||||
@ -14,7 +15,6 @@
|
|||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
// vim: set tw=80 ts=2 sw=2 sts=2:
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('accountant.operations', [
|
angular.module('accountant.operations', [
|
||||||
@ -24,7 +24,7 @@ angular.module('accountant.operations', [
|
|||||||
'ngBootbox',
|
'ngBootbox',
|
||||||
'ui-notification',
|
'ui-notification',
|
||||||
'mgcrea.ngStrap',
|
'mgcrea.ngStrap',
|
||||||
'highcharts-ng',
|
'highcharts-ng'
|
||||||
])
|
])
|
||||||
|
|
||||||
.config(['$resourceProvider', function($resourceProvider) {
|
.config(['$resourceProvider', function($resourceProvider) {
|
||||||
@ -32,7 +32,7 @@ angular.module('accountant.operations', [
|
|||||||
$resourceProvider.defaults.stripTrailingSlashes = false;
|
$resourceProvider.defaults.stripTrailingSlashes = false;
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('Operation', [ '$resource', function($resource) {
|
.factory('Operation', ['$resource', function($resource) {
|
||||||
return $resource(
|
return $resource(
|
||||||
'/api/operation/:id', {
|
'/api/operation/:id', {
|
||||||
id: '@id'
|
id: '@id'
|
||||||
@ -40,29 +40,35 @@ angular.module('accountant.operations', [
|
|||||||
);
|
);
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('OHLC', [ '$resource', '$routeParams',
|
.factory('OHLC', ['$resource', '$routeParams',
|
||||||
function($resource, $routeParams) {
|
function($resource, $routeParams) {
|
||||||
return $resource(
|
return $resource(
|
||||||
'/api/account/:account_id/ohlc', {
|
'/api/account/:account_id/ohlc', {
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
account_id: $routeParams.accountId
|
account_id: $routeParams.accountId
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('Category', [ '$resource', '$routeParams',
|
.factory('Category', ['$resource', '$routeParams',
|
||||||
function($resource, $routeParams) {
|
function($resource, $routeParams) {
|
||||||
return $resource(
|
return $resource(
|
||||||
'/api/account/:account_id/category', {
|
'/api/account/:account_id/category', {
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
account_id: $routeParams.accountId
|
account_id: $routeParams.accountId
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('Balance', [ '$resource', '$routeParams',
|
.factory('Balance', ['$resource', '$routeParams',
|
||||||
function($resource, $routeParams) {
|
function($resource, $routeParams) {
|
||||||
return $resource(
|
return $resource(
|
||||||
'/api/account/:account_id/balance', {
|
'/api/account/:account_id/balance', {
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
account_id: $routeParams.accountId
|
account_id: $routeParams.accountId
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}])
|
}])
|
||||||
@ -70,11 +76,9 @@ angular.module('accountant.operations', [
|
|||||||
/*
|
/*
|
||||||
* Controller for category chart.
|
* Controller for category chart.
|
||||||
*/
|
*/
|
||||||
.controller(
|
.controller('CategoryChartController', [
|
||||||
'CategoryChartController', [
|
|
||||||
'$rootScope', '$scope', '$http', 'Category', 'Balance',
|
'$rootScope', '$scope', '$http', 'Category', 'Balance',
|
||||||
function($rootScope, $scope, $http, Category, Balance) {
|
function($rootScope, $scope, $http, Category, Balance) {
|
||||||
|
|
||||||
var colors = Highcharts.getOptions().colors;
|
var colors = Highcharts.getOptions().colors;
|
||||||
$scope.revenueColor = colors[2];
|
$scope.revenueColor = colors[2];
|
||||||
$scope.expenseColor = colors[3];
|
$scope.expenseColor = colors[3];
|
||||||
@ -128,7 +132,7 @@ angular.module('accountant.operations', [
|
|||||||
dataLabels: {
|
dataLabels: {
|
||||||
formatter: function() {
|
formatter: function() {
|
||||||
return this.point.name !== null && this.percentage >= 2.5 ? this.point.name : null;
|
return this.point.name !== null && this.percentage >= 2.5 ? this.point.name : null;
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
@ -147,7 +151,8 @@ angular.module('accountant.operations', [
|
|||||||
begin: begin.format('YYYY-MM-DD'),
|
begin: begin.format('YYYY-MM-DD'),
|
||||||
end: end.format('YYYY-MM-DD')
|
end: end.format('YYYY-MM-DD')
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
var expenses = [], revenues = [];
|
var expenses = [];
|
||||||
|
var revenues = [];
|
||||||
|
|
||||||
var expenseColor = $scope.brightenColor($scope.expenseColor);
|
var expenseColor = $scope.brightenColor($scope.expenseColor);
|
||||||
var revenueColor = $scope.brightenColor($scope.revenueColor);
|
var revenueColor = $scope.brightenColor($scope.revenueColor);
|
||||||
@ -193,7 +198,7 @@ angular.module('accountant.operations', [
|
|||||||
}, {
|
}, {
|
||||||
name: 'Expenses',
|
name: 'Expenses',
|
||||||
y: -balance.expenses,
|
y: -balance.expenses,
|
||||||
color: $scope.expenseColor,
|
color: $scope.expenseColor
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -203,13 +208,13 @@ angular.module('accountant.operations', [
|
|||||||
$scope.load(args.begin, args.end);
|
$scope.load(args.begin, args.end);
|
||||||
$scope.getBalance(args.begin, args.end);
|
$scope.getBalance(args.begin, args.end);
|
||||||
});
|
});
|
||||||
}])
|
}
|
||||||
|
])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Controller for the sold chart.
|
* Controller for the sold chart.
|
||||||
*/
|
*/
|
||||||
.controller(
|
.controller('SoldChartController', [
|
||||||
'SoldChartController', [
|
|
||||||
'$rootScope', '$scope', '$http', 'OHLC',
|
'$rootScope', '$scope', '$http', 'OHLC',
|
||||||
function($rootScope, $scope, $http, OHLC) {
|
function($rootScope, $scope, $http, OHLC) {
|
||||||
// Configure chart for operations.
|
// Configure chart for operations.
|
||||||
@ -239,7 +244,7 @@ angular.module('accountant.operations', [
|
|||||||
type: 'all',
|
type: 'all',
|
||||||
text: 'All'
|
text: 'All'
|
||||||
}],
|
}],
|
||||||
selected: 0,
|
selected: 0
|
||||||
},
|
},
|
||||||
navigator: {
|
navigator: {
|
||||||
enabled: true
|
enabled: true
|
||||||
@ -258,8 +263,8 @@ angular.module('accountant.operations', [
|
|||||||
type: 'ohlc',
|
type: 'ohlc',
|
||||||
name: 'Sold',
|
name: 'Sold',
|
||||||
data: [],
|
data: [],
|
||||||
dataGrouping : {
|
dataGrouping: {
|
||||||
units : [[
|
units: [[
|
||||||
'week', // unit name
|
'week', // unit name
|
||||||
[1] // allowed multiples
|
[1] // allowed multiples
|
||||||
], [
|
], [
|
||||||
@ -310,7 +315,9 @@ angular.module('accountant.operations', [
|
|||||||
|
|
||||||
angular.forEach(data, function(operation) {
|
angular.forEach(data, function(operation) {
|
||||||
$scope.config.series[0].data.push([
|
$scope.config.series[0].data.push([
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
moment.utc(operation.operation_date).valueOf(),
|
moment.utc(operation.operation_date).valueOf(),
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
operation.open, operation.high, operation.low, operation.close
|
operation.open, operation.high, operation.low, operation.close
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@ -336,18 +343,20 @@ angular.module('accountant.operations', [
|
|||||||
|
|
||||||
// Update authorized overdraft on account loading.
|
// Update authorized overdraft on account loading.
|
||||||
$rootScope.$on('accountLoadedEvent', function(e, account) {
|
$rootScope.$on('accountLoadedEvent', function(e, account) {
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
$scope.config.yAxis.plotLines[1].value = account.authorized_overdraft;
|
$scope.config.yAxis.plotLines[1].value = account.authorized_overdraft;
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
});
|
});
|
||||||
|
|
||||||
// Select beginning and end of month.
|
// Select beginning and end of month.
|
||||||
$scope.loadSolds();
|
$scope.loadSolds();
|
||||||
}])
|
}
|
||||||
|
])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Controller for the operations.
|
* Controller for the operations.
|
||||||
*/
|
*/
|
||||||
.controller(
|
.controller('OperationController', [
|
||||||
'OperationController', [
|
|
||||||
'$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'Account', 'Operation',
|
'$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'Account', 'Operation',
|
||||||
function($scope, $rootScope, $routeParams, $ngBootbox, Notification, Account, Operation) {
|
function($scope, $rootScope, $routeParams, $ngBootbox, Notification, Account, Operation) {
|
||||||
// List of operations.
|
// List of operations.
|
||||||
@ -358,7 +367,9 @@ angular.module('accountant.operations', [
|
|||||||
*/
|
*/
|
||||||
$scope.add = function() {
|
$scope.add = function() {
|
||||||
var operation = new Operation({
|
var operation = new Operation({
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
account_id: $routeParams.accountId
|
account_id: $routeParams.accountId
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.operations.splice(0, 0, operation);
|
$scope.operations.splice(0, 0, operation);
|
||||||
@ -369,7 +380,9 @@ angular.module('accountant.operations', [
|
|||||||
*/
|
*/
|
||||||
$scope.load = function(begin, end) {
|
$scope.load = function(begin, end) {
|
||||||
$scope.operations = Operation.query({
|
$scope.operations = Operation.query({
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
account_id: $routeParams.accountId,
|
account_id: $routeParams.accountId,
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
begin: begin.format('YYYY-MM-DD'),
|
begin: begin.format('YYYY-MM-DD'),
|
||||||
end: end.format('YYYY-MM-DD')
|
end: end.format('YYYY-MM-DD')
|
||||||
});
|
});
|
||||||
@ -379,7 +392,7 @@ angular.module('accountant.operations', [
|
|||||||
* Cancel edition.
|
* Cancel edition.
|
||||||
*/
|
*/
|
||||||
$scope.cancelEdit = function(operation, rowform, $index) {
|
$scope.cancelEdit = function(operation, rowform, $index) {
|
||||||
if(!operation.id) {
|
if (!operation.id) {
|
||||||
$scope.operations.splice($index, 1);
|
$scope.operations.splice($index, 1);
|
||||||
} else {
|
} else {
|
||||||
rowform.$cancel();
|
rowform.$cancel();
|
||||||
@ -393,7 +406,7 @@ angular.module('accountant.operations', [
|
|||||||
operation.pointed = !operation.pointed;
|
operation.pointed = !operation.pointed;
|
||||||
|
|
||||||
// Save operation if not editing it.
|
// Save operation if not editing it.
|
||||||
if(!rowform.$visible) {
|
if (!rowform.$visible) {
|
||||||
$scope.save(operation);
|
$scope.save(operation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -414,7 +427,7 @@ angular.module('accountant.operations', [
|
|||||||
// Check if $data is already a resource.
|
// Check if $data is already a resource.
|
||||||
var operation;
|
var operation;
|
||||||
|
|
||||||
if($data.$save) {
|
if ($data.$save) {
|
||||||
operation = $data;
|
operation = $data;
|
||||||
} else {
|
} else {
|
||||||
operation = $scope.operations[$index];
|
operation = $scope.operations[$index];
|
||||||
@ -439,7 +452,7 @@ angular.module('accountant.operations', [
|
|||||||
$ngBootbox.confirm(
|
$ngBootbox.confirm(
|
||||||
'Voulez-vous supprimer l\'opération \\\'' + operation.label + '\\\' ?',
|
'Voulez-vous supprimer l\'opération \\\'' + operation.label + '\\\' ?',
|
||||||
function(result) {
|
function(result) {
|
||||||
if(result) {
|
if (result) {
|
||||||
operation.$delete().then(function() {
|
operation.$delete().then(function() {
|
||||||
Notification.success('Operation #' + id + ' deleted.');
|
Notification.success('Operation #' + id + ' deleted.');
|
||||||
|
|
||||||
@ -463,10 +476,10 @@ angular.module('accountant.operations', [
|
|||||||
$rootScope.$on('rangeSelectedEvent', function(e, args) {
|
$rootScope.$on('rangeSelectedEvent', function(e, args) {
|
||||||
$scope.load(args.begin, args.end);
|
$scope.load(args.begin, args.end);
|
||||||
});
|
});
|
||||||
}])
|
}
|
||||||
|
])
|
||||||
|
|
||||||
.directive(
|
.directive('operationFormDialog', function($ngBootbox) {
|
||||||
'operationFormDialog', function($ngBootbox) {
|
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
scope: {
|
scope: {
|
||||||
@ -475,7 +488,7 @@ angular.module('accountant.operations', [
|
|||||||
link: function(scope, element) {
|
link: function(scope, element) {
|
||||||
var title = 'Operation';
|
var title = 'Operation';
|
||||||
|
|
||||||
if(scope.operation && scope.operation.id) {
|
if (scope.operation && scope.operation.id) {
|
||||||
title = title + ' #' + scope.operation.id;
|
title = title + ' #' + scope.operation.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// vim: set tw=80 ts=4 sw=4 sts=4:
|
||||||
/*
|
/*
|
||||||
This file is part of Accountant.
|
This file is part of Accountant.
|
||||||
|
|
||||||
@ -14,7 +15,6 @@
|
|||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
// vim: set tw=80 ts=2 sw=2 sts=2:
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('accountant.scheduler', [
|
angular.module('accountant.scheduler', [
|
||||||
@ -38,8 +38,7 @@ angular.module('accountant.scheduler', [
|
|||||||
);
|
);
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.controller(
|
.controller('SchedulerController', [
|
||||||
'SchedulerController', [
|
|
||||||
'$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'ScheduledOperation',
|
'$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'ScheduledOperation',
|
||||||
function($scope, $rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) {
|
function($scope, $rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) {
|
||||||
// Operation store.
|
// Operation store.
|
||||||
@ -50,7 +49,9 @@ angular.module('accountant.scheduler', [
|
|||||||
*/
|
*/
|
||||||
$scope.add = function() {
|
$scope.add = function() {
|
||||||
var operation = new ScheduledOperation({
|
var operation = new ScheduledOperation({
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
account_id: $routeParams.accountId
|
account_id: $routeParams.accountId
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
});
|
});
|
||||||
|
|
||||||
// Insert new operation at the beginning of the array.
|
// Insert new operation at the beginning of the array.
|
||||||
@ -62,7 +63,9 @@ angular.module('accountant.scheduler', [
|
|||||||
*/
|
*/
|
||||||
$scope.load = function() {
|
$scope.load = function() {
|
||||||
$scope.operations = ScheduledOperation.query({
|
$scope.operations = ScheduledOperation.query({
|
||||||
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
account_id: $routeParams.accountId
|
account_id: $routeParams.accountId
|
||||||
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,7 +75,7 @@ angular.module('accountant.scheduler', [
|
|||||||
$scope.save = function($data, $index) {
|
$scope.save = function($data, $index) {
|
||||||
var operation;
|
var operation;
|
||||||
|
|
||||||
if($data.$save) {
|
if ($data.$save) {
|
||||||
operation = $data;
|
operation = $data;
|
||||||
} else {
|
} else {
|
||||||
operation = $scope.operations[$index];
|
operation = $scope.operations[$index];
|
||||||
@ -88,7 +91,7 @@ angular.module('accountant.scheduler', [
|
|||||||
* Cancel operation edition. Delete if new.
|
* Cancel operation edition. Delete if new.
|
||||||
*/
|
*/
|
||||||
$scope.cancelEdit = function(operation, rowform, $index) {
|
$scope.cancelEdit = function(operation, rowform, $index) {
|
||||||
if(!operation.id) {
|
if (!operation.id) {
|
||||||
$scope.operations.splice($index, 1);
|
$scope.operations.splice($index, 1);
|
||||||
} else {
|
} else {
|
||||||
rowform.$cancel();
|
rowform.$cancel();
|
||||||
@ -104,7 +107,7 @@ angular.module('accountant.scheduler', [
|
|||||||
$ngBootbox.confirm(
|
$ngBootbox.confirm(
|
||||||
'Voulez-vous supprimer l\'operation planifiée \\\'' + operation.label + '\\\' ?',
|
'Voulez-vous supprimer l\'operation planifiée \\\'' + operation.label + '\\\' ?',
|
||||||
function(result) {
|
function(result) {
|
||||||
if(result) {
|
if (result) {
|
||||||
operation.$delete().then(function() {
|
operation.$delete().then(function() {
|
||||||
Notification.success('Operation #' + id + ' deleted.');
|
Notification.success('Operation #' + id + ' deleted.');
|
||||||
|
|
||||||
@ -118,4 +121,5 @@ angular.module('accountant.scheduler', [
|
|||||||
|
|
||||||
// Load operations on controller initialization.
|
// Load operations on controller initialization.
|
||||||
$scope.load();
|
$scope.load();
|
||||||
}]);
|
}
|
||||||
|
]);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
options: {
|
options: {
|
||||||
config: '.jscsrc',
|
config: '.jscsrc'
|
||||||
verbose: true
|
|
||||||
},
|
},
|
||||||
frontend_js: [
|
frontend_js: [
|
||||||
'<%= accountant.frontend.src %>/js/*.js'
|
'<%= accountant.frontend.src %>/js/*.js'
|
||||||
|
Loading…
Reference in New Issue
Block a user