Fix angular style issues.
This commit is contained in:
parent
4aed242a48
commit
f12c89a9ee
@ -25,99 +25,100 @@ 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', [
|
.controller('SchedulerController', function($rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) {
|
||||||
'$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'ScheduledOperation',
|
var vm = this;
|
||||||
function($scope, $rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) {
|
|
||||||
// Operation store.
|
|
||||||
$scope.operations = [];
|
|
||||||
|
|
||||||
/*
|
// Operation store.
|
||||||
* Add a new operation at the beginning of th array.
|
vm.operations = [];
|
||||||
*/
|
|
||||||
$scope.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);
|
* 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
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
// Insert new operation at the beginning of the array.
|
||||||
* Load operations.
|
vm.operations.splice(0, 0, operation);
|
||||||
*/
|
};
|
||||||
$scope.load = function() {
|
|
||||||
$scope.operations = ScheduledOperation.query({
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
account_id: $routeParams.accountId
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save operation.
|
* Load operations.
|
||||||
*/
|
*/
|
||||||
$scope.save = function($data, $index) {
|
vm.load = function() {
|
||||||
var operation;
|
vm.operations = ScheduledOperation.query({
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
|
account_id: $routeParams.accountId
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if ($data.$save) {
|
/*
|
||||||
operation = $data;
|
* Save operation.
|
||||||
} else {
|
*/
|
||||||
operation = $scope.operations[$index];
|
vm.save = function($data, $index) {
|
||||||
operation = angular.merge(operation, $data);
|
var operation;
|
||||||
}
|
|
||||||
|
|
||||||
return operation.$save().then(function(data) {
|
if ($data.$save) {
|
||||||
Notification.success('Operation #' + data.id + ' saved.');
|
operation = $data;
|
||||||
});
|
} else {
|
||||||
};
|
operation = vm.operations[$index];
|
||||||
|
operation = angular.merge(operation, $data);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
return operation.$save().then(function(data) {
|
||||||
* Cancel operation edition. Delete if new.
|
Notification.success('Operation #' + data.id + ' saved.');
|
||||||
*/
|
});
|
||||||
$scope.cancelEdit = function(operation, rowform, $index) {
|
};
|
||||||
if (operation.id) {
|
|
||||||
rowform.$cancel();
|
|
||||||
} else {
|
|
||||||
$scope.operations.splice($index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete operation.
|
* Cancel operation edition. Delete if new.
|
||||||
*/
|
*/
|
||||||
$scope.delete = function(operation, $index) {
|
vm.cancelEdit = function(operation, rowform, $index) {
|
||||||
var id = operation.id;
|
if (operation.id) {
|
||||||
|
rowform.$cancel();
|
||||||
|
} else {
|
||||||
|
vm.operations.splice($index, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$ngBootbox.confirm(
|
/*
|
||||||
'Voulez-vous supprimer l\'operation planifiée \\\'' + operation.label + '\\\' ?',
|
* Delete operation.
|
||||||
function(result) {
|
*/
|
||||||
if (result) {
|
vm.delete = function(operation, $index) {
|
||||||
operation.$delete().then(function() {
|
var id = operation.id;
|
||||||
Notification.success('Operation #' + id + ' deleted.');
|
|
||||||
|
|
||||||
// Remove account from array.
|
$ngBootbox.confirm(
|
||||||
$scope.operations.splice($index, 1);
|
'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.
|
// Load operations on controller initialization.
|
||||||
$scope.load();
|
vm.load();
|
||||||
}
|
})
|
||||||
]);
|
|
||||||
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user