Fix angular style issues.

This commit is contained in:
Alexis Lahouze 2016-10-14 08:21:43 +02:00
parent 4aed242a48
commit f12c89a9ee

View File

@ -25,43 +25,43 @@ angular.module('accountant.scheduler', [
'mgcrea.ngStrap' 'mgcrea.ngStrap'
]) ])
.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('ScheduledOperation', ['$resource', function($resource) { .factory('ScheduledOperation', function($resource) {
return $resource( return $resource(
'/api/scheduled_operation/:id', { '/api/scheduled_operation/:id', {
id: '@id' id: '@id'
} }
); );
}]) })
.controller('SchedulerController', function($rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) {
var vm = this;
.controller('SchedulerController', [
'$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'ScheduledOperation',
function($scope, $rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) {
// Operation store. // Operation store.
$scope.operations = []; vm.operations = [];
/* /*
* Add a new operation at the beginning of th array. * Add a new operation at the beginning of th array.
*/ */
$scope.add = function() { vm.add = function() {
var operation = new ScheduledOperation({ var operation = new ScheduledOperation({
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
account_id: $routeParams.accountId account_id: $routeParams.accountId
}); });
// Insert new operation at the beginning of the array. // Insert new operation at the beginning of the array.
$scope.operations.splice(0, 0, operation); vm.operations.splice(0, 0, operation);
}; };
/* /*
* Load operations. * Load operations.
*/ */
$scope.load = function() { vm.load = function() {
$scope.operations = ScheduledOperation.query({ vm.operations = ScheduledOperation.query({
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
account_id: $routeParams.accountId account_id: $routeParams.accountId
}); });
@ -70,13 +70,13 @@ angular.module('accountant.scheduler', [
/* /*
* Save operation. * Save operation.
*/ */
$scope.save = function($data, $index) { vm.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 = vm.operations[$index];
operation = angular.merge(operation, $data); operation = angular.merge(operation, $data);
} }
@ -88,18 +88,18 @@ angular.module('accountant.scheduler', [
/* /*
* Cancel operation edition. Delete if new. * Cancel operation edition. Delete if new.
*/ */
$scope.cancelEdit = function(operation, rowform, $index) { vm.cancelEdit = function(operation, rowform, $index) {
if (operation.id) { if (operation.id) {
rowform.$cancel(); rowform.$cancel();
} else { } else {
$scope.operations.splice($index, 1); vm.operations.splice($index, 1);
} }
}; };
/* /*
* Delete operation. * Delete operation.
*/ */
$scope.delete = function(operation, $index) { vm.delete = function(operation, $index) {
var id = operation.id; var id = operation.id;
$ngBootbox.confirm( $ngBootbox.confirm(
@ -110,7 +110,7 @@ angular.module('accountant.scheduler', [
Notification.success('Operation #' + id + ' deleted.'); Notification.success('Operation #' + id + ' deleted.');
// Remove account from array. // Remove account from array.
$scope.operations.splice($index, 1); vm.operations.splice($index, 1);
}); });
} }
} }
@ -118,6 +118,7 @@ angular.module('accountant.scheduler', [
}; };
// Load operations on controller initialization. // Load operations on controller initialization.
$scope.load(); vm.load();
} })
]);
;