aboutsummaryrefslogtreecommitdiffstats
path: root/moon_gui/static/app/policy/edit/parameter/data
diff options
context:
space:
mode:
Diffstat (limited to 'moon_gui/static/app/policy/edit/parameter/data')
-rwxr-xr-xmoon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html27
-rwxr-xr-xmoon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js98
2 files changed, 48 insertions, 77 deletions
diff --git a/moon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html b/moon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html
index 3f11a641..fae647e3 100755
--- a/moon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html
+++ b/moon_gui/static/app/policy/edit/parameter/data/data-edit.tpl.html
@@ -36,33 +36,6 @@
</div>
<div class="form-group"
- ng-class="{'has-error': edit.form.policyList.$invalid && edit.form.policyList.$dirty}">
-
- <label for="policyList" class="col-sm-3 control-label" data-translate="moon.policy.data.edit.policies">Policy
- List </label>
-
- <div class="col-sm-6">
-
- <ui-select ng-model="edit.selectedPolicy" name="policyList" id="policyList" required>
-
- <ui-select-match placeholder="(None)" ng-bind="$select.selected.name"></ui-select-match>
- <ui-select-choices repeat="aPolicy in edit.policyList">
- <div ng-value="aPolicy" ng-bind="aPolicy.name"></div>
- </ui-select-choices>
-
- </ui-select>
-
- <div class="help-block" ng-show="edit.form.policyList.$dirty && edit.form.policyList.$invalid">
- <small class="error" ng-show="edit.form.policyList.$error.required"
- data-translate="moon.policy.data.edit.check.policy.required">Policy is required
- </small>
- </div>
-
- </div>
-
- </div>
-
- <div class="form-group"
ng-class="{'has-error': edit.form.categoryList.$invalid && edit.form.categoryList.$dirty}">
<label for="categoryList" class="col-sm-3 control-label"
diff --git a/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js b/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js
index 57ad0c9b..2ae08177 100755
--- a/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js
+++ b/moon_gui/static/app/policy/edit/parameter/data/data.edit.dir.js
@@ -31,10 +31,10 @@
.controller('moonDataEditController', moonDataEditController);
moonDataEditController.$inject = ['$scope', 'dataService', 'DATA_CST', 'alertService', '$translate',
- 'formService', 'policyService', 'utilService', 'metaDataService'];
+ 'formService', 'policyService', 'utilService', 'metaDataService', 'modelService', 'metaRuleService'];
function moonDataEditController($scope, dataService, DATA_CST, alertService, $translate,
- formService, policyService, utilService, metaDataService) {
+ formService, policyService, utilService, metaDataService, modelService, metaRuleService) {
var edit = this;
@@ -50,7 +50,6 @@
edit.data = { name: null, description: null};
edit.list = [];
- edit.policyList = [];
edit.categoriesToBeSelected = [];
edit.create = createData;
@@ -64,7 +63,6 @@
function activate(){
loadAllCategories();
- loadAllPolicies();
switch(edit.dataType){
@@ -105,58 +103,54 @@
}
- function loadAllCategories(){
-
- switch(edit.dataType){
-
- case DATA_CST.TYPE.SUBJECT:
-
- metaDataService.subject.findAllWithCallback(callBackList);
- break;
-
- case DATA_CST.TYPE.OBJECT:
-
- metaDataService.object.findAllWithCallback(callBackList);
- break;
-
- case DATA_CST.TYPE.ACTION:
-
- metaDataService.action.findAllWithCallback(callBackList);
- break;
-
- default :
-
- edit.categoriesToBeSelected = [];
- break;
-
- }
-
- function callBackList(list){
-
- edit.categoriesToBeSelected = list;
-
- }
- }
- function loadAllPolicies() {
-
- edit.policyList = [];
-
- policyService.findAllWithCallback( function(data) {
-
- _.each(data, function(element){
+ function loadAllCategories(){
- if(element.id === edit.policy.id){
- edit.selectedPolicy = element;
+ modelService.findOneWithCallback(edit.policy.model_id, function(model){
+
+ metaRuleService.findSomeWithCallback(model.meta_rules, function(metaRules){
+
+ switch(edit.dataType){
+
+ case DATA_CST.TYPE.SUBJECT:
+ var subjectCategoryList = _.reduce(metaRules, function(result, metaRule) {
+ return result.concat(metaRule.subject_categories);
+ }, [])
+ metaDataService.subject.findSomeWithCallback(subjectCategoryList, callBackList);
+ break;
+
+ case DATA_CST.TYPE.OBJECT:
+ var objectCategoryList = _.reduce(metaRules, function(result, metaRule) {
+ return result.concat(metaRule.object_categories);
+ }, [])
+ metaDataService.object.findSomeWithCallback(objectCategoryList, callBackList);
+ break;
+
+ case DATA_CST.TYPE.ACTION:
+ var actionCategoryList = _.reduce(metaRules, function(result, metaRule) {
+ return result.concat(metaRule.action_categories);
+ }, [])
+ metaDataService.action.findSomeWithCallback(actionCategoryList, callBackList);
+ break;
+
+ default :
+
+ edit.categoriesToBeSelected = [];
+ break;
+
+ }
+
+ function callBackList(list){
+
+ edit.categoriesToBeSelected = list;
+
}
-
});
- edit.policyList = data;
-
});
- }
+
+ }
/**
* Create
@@ -200,26 +194,30 @@
function createSuccess(data) {
var created = {};
+ var name = '';
switch(edit.dataType){
case DATA_CST.TYPE.SUBJECT:
created = utilService.transformOne(data['subject_data'], 'data');
+ name = created.name;
break;
case DATA_CST.TYPE.OBJECT:
created = utilService.transformOne(data['object_data'], 'data');
+ name = created.value.name;
break;
case DATA_CST.TYPE.ACTION:
created = utilService.transformOne(data['action_data'], 'data');
+ name = created.value.name;
break;
}
- $translate('moon.policy.data.edit.create.success', { name: created.name }).then(function (translatedValue) {
+ $translate('moon.policy.data.edit.create.success', { name: name }).then(function (translatedValue) {
alertService.alertSuccess(translatedValue);
});