From f12c89a9ee3d976c1bd8b23ea6a3ba940acab050 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 14 Oct 2016 08:21:43 +0200 Subject: [PATCH] Fix angular style issues. --- accountant-ui/js/scheduler.js | 151 +++++++++++++++++----------------- 1 file changed, 76 insertions(+), 75 deletions(-) diff --git a/accountant-ui/js/scheduler.js b/accountant-ui/js/scheduler.js index bc2d3ee..7ac7bb8 100644 --- a/accountant-ui/js/scheduler.js +++ b/accountant-ui/js/scheduler.js @@ -25,99 +25,100 @@ angular.module('accountant.scheduler', [ 'mgcrea.ngStrap' ]) -.config(['$resourceProvider', function($resourceProvider) { +.config(function($resourceProvider) { // Keep trailing slashes to avoid redirect by flask.. $resourceProvider.defaults.stripTrailingSlashes = false; -}]) +}) -.factory('ScheduledOperation', ['$resource', function($resource) { +.factory('ScheduledOperation', function($resource) { return $resource( '/api/scheduled_operation/:id', { id: '@id' } ); -}]) +}) -.controller('SchedulerController', [ - '$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'ScheduledOperation', - function($scope, $rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) { - // Operation store. - $scope.operations = []; +.controller('SchedulerController', function($rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) { + var vm = this; - /* - * Add a new operation at the beginning of th array. - */ - $scope.add = function() { - var operation = new ScheduledOperation({ - // eslint-disable-next-line camelcase - account_id: $routeParams.accountId - }); + // Operation store. + vm.operations = []; - // Insert new operation at the beginning of the array. - $scope.operations.splice(0, 0, operation); - }; + /* + * Add a new operation at the beginning of th array. + */ + vm.add = function() { + var operation = new ScheduledOperation({ + // eslint-disable-next-line camelcase + account_id: $routeParams.accountId + }); - /* - * Load operations. - */ - $scope.load = function() { - $scope.operations = ScheduledOperation.query({ - // eslint-disable-next-line camelcase - account_id: $routeParams.accountId - }); - }; + // Insert new operation at the beginning of the array. + vm.operations.splice(0, 0, operation); + }; - /* - * Save operation. - */ - $scope.save = function($data, $index) { - var operation; + /* + * Load operations. + */ + vm.load = function() { + vm.operations = ScheduledOperation.query({ + // eslint-disable-next-line camelcase + account_id: $routeParams.accountId + }); + }; - if ($data.$save) { - operation = $data; - } else { - operation = $scope.operations[$index]; - operation = angular.merge(operation, $data); - } + /* + * Save operation. + */ + vm.save = function($data, $index) { + var operation; - return operation.$save().then(function(data) { - Notification.success('Operation #' + data.id + ' saved.'); - }); - }; + if ($data.$save) { + operation = $data; + } else { + operation = vm.operations[$index]; + operation = angular.merge(operation, $data); + } - /* - * Cancel operation edition. Delete if new. - */ - $scope.cancelEdit = function(operation, rowform, $index) { - if (operation.id) { - rowform.$cancel(); - } else { - $scope.operations.splice($index, 1); - } - }; + return operation.$save().then(function(data) { + Notification.success('Operation #' + data.id + ' saved.'); + }); + }; - /* - * Delete operation. - */ - $scope.delete = function(operation, $index) { - var id = operation.id; + /* + * Cancel operation edition. Delete if new. + */ + vm.cancelEdit = function(operation, rowform, $index) { + if (operation.id) { + rowform.$cancel(); + } else { + vm.operations.splice($index, 1); + } + }; - $ngBootbox.confirm( - 'Voulez-vous supprimer l\'operation planifiée \\\'' + operation.label + '\\\' ?', - function(result) { - if (result) { - operation.$delete().then(function() { - Notification.success('Operation #' + id + ' deleted.'); + /* + * Delete operation. + */ + vm.delete = function(operation, $index) { + var id = operation.id; - // Remove account from array. - $scope.operations.splice($index, 1); - }); - } + $ngBootbox.confirm( + 'Voulez-vous supprimer l\'operation planifiée \\\'' + operation.label + '\\\' ?', + function(result) { + if (result) { + operation.$delete().then(function() { + Notification.success('Operation #' + id + ' deleted.'); + + // Remove account from array. + vm.operations.splice($index, 1); + }); } - ); - }; + } + ); + }; - // Load operations on controller initialization. - $scope.load(); - } -]); + // Load operations on controller initialization. + vm.load(); +}) + +;