63 lines
1.9 KiB
JavaScript
63 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
var ClientListController = ['$scope', 'clients', function ($scope, clients) {
|
|
$scope.info = clients;
|
|
}];
|
|
|
|
ClientListController.resolve = {
|
|
clients: ['Client', function (Client) {
|
|
return Client.query({}).$promise;
|
|
}]
|
|
};
|
|
|
|
var ClientController = ['$scope', '$location', '$modal', 'client', function ($scope, $location, $modal, client) {
|
|
$scope.client = client;
|
|
|
|
$scope.save = function () {
|
|
$scope.client.$save(function () {
|
|
$scope.toasts.push({Type: 'Success', Message: ''});
|
|
$location.path('/Clients');
|
|
}, function (data) {
|
|
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
};
|
|
|
|
$scope.delete = function () {
|
|
$scope.client.$delete(function () {
|
|
$scope.toasts.push({Type: 'Success', Message: ''});
|
|
$location.path('/Clients');
|
|
}, function (data) {
|
|
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
|
});
|
|
};
|
|
|
|
$scope.confirm = function () {
|
|
var modalInstance = $modal.open({
|
|
backdrop: true,
|
|
templateUrl: '/template/modal/confirm.html',
|
|
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
|
$scope.title = "Delete Client";
|
|
$scope.body = "Are you sure? This cannot be undone.";
|
|
$scope.isDelete = true;
|
|
$scope.ok = function () {
|
|
$modalInstance.close();
|
|
};
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
}]
|
|
});
|
|
modalInstance.result.then(function () {
|
|
$scope.delete();
|
|
});
|
|
};
|
|
$scope.foName = true;
|
|
}];
|
|
|
|
ClientController.resolve = {
|
|
client: ['$route', 'Client', function ($route, Client) {
|
|
var id = $route.current.params.id;
|
|
return Client.get({id: id}).$promise;
|
|
}]
|
|
};
|