Fix angular style issues.
This commit is contained in:
parent
4aed242a48
commit
f12c89a9ee
@ -25,43 +25,43 @@ 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', 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.
|
||||
$scope.operations = [];
|
||||
vm.operations = [];
|
||||
|
||||
/*
|
||||
* Add a new operation at the beginning of th array.
|
||||
*/
|
||||
$scope.add = function() {
|
||||
vm.add = function() {
|
||||
var operation = new ScheduledOperation({
|
||||
// eslint-disable-next-line camelcase
|
||||
account_id: $routeParams.accountId
|
||||
});
|
||||
|
||||
// Insert new operation at the beginning of the array.
|
||||
$scope.operations.splice(0, 0, operation);
|
||||
vm.operations.splice(0, 0, operation);
|
||||
};
|
||||
|
||||
/*
|
||||
* Load operations.
|
||||
*/
|
||||
$scope.load = function() {
|
||||
$scope.operations = ScheduledOperation.query({
|
||||
vm.load = function() {
|
||||
vm.operations = ScheduledOperation.query({
|
||||
// eslint-disable-next-line camelcase
|
||||
account_id: $routeParams.accountId
|
||||
});
|
||||
@ -70,13 +70,13 @@ angular.module('accountant.scheduler', [
|
||||
/*
|
||||
* Save operation.
|
||||
*/
|
||||
$scope.save = function($data, $index) {
|
||||
vm.save = function($data, $index) {
|
||||
var operation;
|
||||
|
||||
if ($data.$save) {
|
||||
operation = $data;
|
||||
} else {
|
||||
operation = $scope.operations[$index];
|
||||
operation = vm.operations[$index];
|
||||
operation = angular.merge(operation, $data);
|
||||
}
|
||||
|
||||
@ -88,18 +88,18 @@ angular.module('accountant.scheduler', [
|
||||
/*
|
||||
* Cancel operation edition. Delete if new.
|
||||
*/
|
||||
$scope.cancelEdit = function(operation, rowform, $index) {
|
||||
vm.cancelEdit = function(operation, rowform, $index) {
|
||||
if (operation.id) {
|
||||
rowform.$cancel();
|
||||
} else {
|
||||
$scope.operations.splice($index, 1);
|
||||
vm.operations.splice($index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Delete operation.
|
||||
*/
|
||||
$scope.delete = function(operation, $index) {
|
||||
vm.delete = function(operation, $index) {
|
||||
var id = operation.id;
|
||||
|
||||
$ngBootbox.confirm(
|
||||
@ -110,7 +110,7 @@ angular.module('accountant.scheduler', [
|
||||
Notification.success('Operation #' + id + ' deleted.');
|
||||
|
||||
// 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.
|
||||
$scope.load();
|
||||
}
|
||||
]);
|
||||
vm.load();
|
||||
})
|
||||
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user