Fix angular style issues.

This commit is contained in:
Alexis Lahouze 2016-10-12 23:32:54 +02:00
parent 032dd9bdc6
commit a872788def

View File

@ -24,12 +24,12 @@ angular.module('accountant.accounts', [
'ngBootbox' 'ngBootbox'
]) ])
.config(['$resourceProvider', function($resourceProvider) { .config(function($resourceProvider) {
// Keep trailing slashes to avoid redirect by flask.. // Keep trailing slashes to avoid redirect by flask..
$resourceProvider.defaults.stripTrailingSlashes = false; $resourceProvider.defaults.stripTrailingSlashes = false;
}]) })
.factory('Account', ['$resource', function($resource) { .factory('Account', function($resource) {
var Account = $resource( var Account = $resource(
'/api/account/:id', { '/api/account/:id', {
id: '@id' id: '@id'
@ -54,16 +54,16 @@ angular.module('accountant.accounts', [
}; };
return Account; return Account;
}]) })
.controller('AccountController', function($scope, $ngBootbox, Account, Notification) {
var vm=this;
.controller('AccountController', [
'$scope', '$ngBootbox', 'Account', 'Notification',
function($scope, $ngBootbox, Account, Notification) {
/* /*
* Return the class for an account current value compared to authorized * Return the class for an account current value compared to authorized
* overdraft. * overdraft.
*/ */
$scope.rowClass = function(account) { vm.rowClass = function(account) {
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
if (!account || !account.authorized_overdraft || !account.current) { if (!account || !account.authorized_overdraft || !account.current) {
return; return;
@ -80,7 +80,7 @@ angular.module('accountant.accounts', [
/* /*
* 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) { vm.valueClass = function(account, value) {
if (!account || !value) { if (!account || !value) {
return; return;
} }
@ -96,7 +96,7 @@ angular.module('accountant.accounts', [
/* /*
* Add an empty account. * Add an empty account.
*/ */
$scope.add = function() { vm.add = function() {
var account = new Account({ var account = new Account({
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
authorized_overdraft: 0 authorized_overdraft: 0
@ -109,7 +109,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) { vm.cancelEdit = function(rowform, account, $index) {
if (account.id) { if (account.id) {
rowform.$cancel(); rowform.$cancel();
} else { } else {
@ -121,7 +121,7 @@ angular.module('accountant.accounts', [
/* /*
* Save account. * Save account.
*/ */
$scope.save = function(account) { vm.save = function(account) {
// var account = $scope.accounts[$index]; // var account = $scope.accounts[$index];
// account = angular.merge(account, $data); // account = angular.merge(account, $data);
@ -138,7 +138,7 @@ angular.module('accountant.accounts', [
/* /*
* Delete an account. * Delete an account.
*/ */
$scope.delete = function(account, $index) { vm.delete = function(account, $index) {
var id = account.id; var id = account.id;
$ngBootbox.confirm( $ngBootbox.confirm(
@ -157,11 +157,10 @@ angular.module('accountant.accounts', [
}; };
// Load accounts. // Load accounts.
$scope.accounts = Account.query(); vm.accounts = Account.query();
}] })
)
.directive('accountFormDialog', function(Account, $ngBootbox, Notification) { .directive('accountFormDialog', function(Account, $ngBootbox, Notification, $log) {
return { return {
restrict: 'A', restrict: 'A',
scope: { scope: {
@ -189,7 +188,7 @@ angular.module('accountant.accounts', [
angular.copy(scope.data, scope.account); angular.copy(scope.data, scope.account);
// Save account // Save account
console.log(scope.account); $log.log(scope.account);
return scope.account.$save().then( return scope.account.$save().then(
function(data) { function(data) {
Notification.success('Account #' + data.id + ' saved.'); Notification.success('Account #' + data.id + ' saved.');
@ -201,7 +200,7 @@ angular.module('accountant.accounts', [
function(data) { function(data) {
Notification.error('Error while saving account #' + data.id); Notification.error('Error while saving account #' + data.id);
scope.account.getSolds(); scope.account.getSolds();
console.log(data); $log.log(data);
return false; return false;
} }
); );