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
|
(function() {
'use strict';
angular
.module('moon')
.controller('ModelEditController', ModelEditController);
ModelEditController.$inject = ['$scope', '$rootScope', 'model', 'metaRuleService'];
function ModelEditController($scope, $rootScope, model, metaRuleService) {
var edit = this;
edit.model = model;
edit.editBasic = false;
edit.editMetaRules = true;
activate();
function activate(){
}
/*
* ---- events
*/
var rootListeners = {
'event:modelUpdatedSuccess': $rootScope.$on('event:modelUpdatedSuccess', modelUpdatedSuccess),
'event:updateModelFromMetaRuleAddSuccess': $rootScope.$on('event:updateModelFromMetaRuleAddSuccess', modelUpdatedSuccess)
};
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 model
*/
function modelUpdatedSuccess(event, model){
edit.model = model;
metaRuleService.findSomeWithCallback(model.meta_rules, function(metaRules){
edit.model.meta_rules_values = metaRules;
});
}
}
})();
|