-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrollers.js
More file actions
84 lines (63 loc) · 2.2 KB
/
Copy pathcontrollers.js
File metadata and controls
84 lines (63 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict';
//Controller de la liste des données
function EmployeeListController($scope, $location, EmployeeFactory) {
//Appel du service de la liste des collection
$scope.listEmployees = EmployeeFactory.getEmployees();
$scope.gotoTodoNewPage = function () {
$location.path("/employee/new")
};
$scope.supprimerEmployee = function(currentEmploye){
//Appel du service de suppression
EmployeeFactory.supprimerEmployee(currentEmploye).then(function(data){
$scope.listEmployees = EmployeeFactory.getEmployees();
});
};
}
//Controlleur de gestion du detail
function EmployeeDetailController($scope, $routeParams, $location, EmployeeFactory) {
//Recuperation du parametre
var idparam = $routeParams.id ;
//Appel du service de recuperation de l'employé choisi
EmployeeFactory.getEmployee(idparam).then(function(data){
$scope.oneEmployee = data.data;
});
$scope.gotoRetour = function () {
$location.path("/")
};
}
//Controller de creation d'un nouvel employé
function EmployeeNewController($scope, $routeParams, $location, EmployeeFactory) {
//Recuperer la valeur de l'id si 0 c-a-d creation sinon MAJS
var idparam = ($routeParams.id) ? parseInt($routeParams.id) : 0 ;
$scope.saveEmployee = function(currentEmployee){
if(idparam<=0){
var currentEmployeeJsoned = angular.toJson(currentEmployee);
EmployeeFactory.insertEmployee(currentEmployeeJsoned);
//Prevoir un message de notification dans la liste
//et un timeout pour le message
$location.path("/");
}
}
$scope.gotoRetour = function () {
$location.path("/");
};
}
//Controller d'edition de l' employé
function EmployeeEditController($scope, $routeParams, $location, EmployeeFactory) {
//Recuperer la valeur de l'id
var idparam = $routeParams.id ;
$scope.other ={};
EmployeeFactory.getEmployee(idparam).then(function(data){
$scope.other = data.data;
console.log(data);
});
$scope.updateEmployee = function(){
EmployeeFactory.updateEmployee($scope.other);
//Prevoir un message de notification dans la liste
//et un timeout pour le message
$location.path("/");
}
$scope.gotoRetour = function () {
$location.path("/")
};
}