1
|
var module = angular.module('affiliationsUI', []);
|
2
|
|
3
|
module.controller('affiliationsCtrl', function ($scope, $http, $timeout, $sce) {
|
4
|
initSpinner();
|
5
|
|
6
|
$scope.affiliations = [];
|
7
|
$scope.tempAffiliation = {};
|
8
|
$scope.groups = [];
|
9
|
|
10
|
$scope.refresh = function() {
|
11
|
showSpinner();
|
12
|
|
13
|
$scope.affiliations = [];
|
14
|
$http.get('portal/aff_view').success(function(data) {
|
15
|
hideSpinner();
|
16
|
angular.forEach(data, function(persons, name) {
|
17
|
$scope.affiliations.push({'name' : name, 'persons': persons});
|
18
|
});
|
19
|
}).error(function() {
|
20
|
hideSpinner();
|
21
|
show_notification("error","An error occurred while fetching affiliations");
|
22
|
});
|
23
|
|
24
|
$http.get('portal/groups').success(function(data) {
|
25
|
$scope.groups = data;
|
26
|
}).error(function() {
|
27
|
show_notification("error","An error occurred while fetching groups");
|
28
|
});
|
29
|
|
30
|
}
|
31
|
|
32
|
$scope.prepareTempAffiliation = function(pid, pname, year) {
|
33
|
$scope.tempAffiliation = {
|
34
|
'pid' : pid,
|
35
|
'pname' : pname,
|
36
|
'year' : year
|
37
|
}
|
38
|
}
|
39
|
|
40
|
$scope.saveAffiliation = function(aff) { alert('TODO'); }
|
41
|
|
42
|
$scope.refresh();
|
43
|
|
44
|
});
|
45
|
|