From 1100c66ce03a059ebe7ece9734e799b49b3a5a9e Mon Sep 17 00:00:00 2001 From: WuKong Date: Sat, 23 Dec 2017 21:49:35 +0100 Subject: moonv4 cleanup Change-Id: Icef927f3236d985ac13ff7376f6ce6314b2b39b0 Signed-off-by: WuKong --- .../app/policy/edit/policy.controller.edit.js | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 moon_gui/static/app/policy/edit/policy.controller.edit.js (limited to 'moon_gui/static/app/policy/edit/policy.controller.edit.js') diff --git a/moon_gui/static/app/policy/edit/policy.controller.edit.js b/moon_gui/static/app/policy/edit/policy.controller.edit.js new file mode 100755 index 00000000..123ee58b --- /dev/null +++ b/moon_gui/static/app/policy/edit/policy.controller.edit.js @@ -0,0 +1,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(); + + } + + } + +})(); -- cgit 1.2.3-korg