blob: 123ee58bba481909645069ef20581a1b7b598132 (
plain)
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
|
(function() {
'use strict';
angular
.module('moon')
.controller('PolicyEditController', PolicyEditController);
PolicyEditController.$inject = ['$scope', '$rootScope', 'policy', 'modelService'];
function PolicyEditController($scope, $rootScope, policy, modelService) {
var edit = this;
edit.policy = policy;
edit.editBasic = false;
edit.showPerimeters = false;
edit.showData = false;
edit.showRules = false;
edit.showAssignments = false;
activate();
function activate(){
manageModel();
}
function manageModel(){
edit.loadingModel = true;
modelService.findOneWithCallback( edit.policy.model_id, function(model){
edit.loadingModel = false;
edit.policy.model = model;
});
}
/*
* ---- events
*/
var rootListeners = {
'event:policyUpdatedSuccess': $rootScope.$on('event:policyUpdatedSuccess', policyUpdatedSuccess)
};
for (var unbind in rootListeners) {
$scope.$on('$destroy', rootListeners[unbind]);
}
/**
* When the model is updated, this function refresh the current model with the new changes
* @param event
* @param policy
*/
function policyUpdatedSuccess(event, policy){
edit.policy = policy;
manageModel();
}
}
})();
|