aboutsummaryrefslogtreecommitdiffstats
path: root/old/moon_gui/static/app/model/edit
diff options
context:
space:
mode:
Diffstat (limited to 'old/moon_gui/static/app/model/edit')
-rwxr-xr-xold/moon_gui/static/app/model/edit/metadata/metadata-edit.tpl.html99
-rwxr-xr-xold/moon_gui/static/app/model/edit/metadata/metadata-list.tpl.html491
-rwxr-xr-xold/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js332
-rwxr-xr-xold/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js374
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-add.tpl.html50
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-map.tpl.html102
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-unmap.tpl.html35
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.controller.add.js99
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.map.controller.js213
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js74
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/metarules-edit-basic.tpl.html67
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/metarules-edit.tpl.html62
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/metarules.controller.edit.js49
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js100
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/metarules-list.tpl.html138
-rwxr-xr-xold/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js241
-rwxr-xr-xold/moon_gui/static/app/model/edit/model-edit-basic.tpl.html65
-rwxr-xr-xold/moon_gui/static/app/model/edit/model-edit.tpl.html70
-rwxr-xr-xold/moon_gui/static/app/model/edit/model.controller.edit.js61
-rwxr-xr-xold/moon_gui/static/app/model/edit/model.edit.basic.dir.js97
20 files changed, 2819 insertions, 0 deletions
diff --git a/old/moon_gui/static/app/model/edit/metadata/metadata-edit.tpl.html b/old/moon_gui/static/app/model/edit/metadata/metadata-edit.tpl.html
new file mode 100755
index 00000000..2616be1c
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metadata/metadata-edit.tpl.html
@@ -0,0 +1,99 @@
+<div>
+
+ <div class="col-md-4 col-sm-4 col-xs-4">
+ <a class="btn btn-primary" type="button" style="white-space: normal;" ng-click="edit.fromList = !edit.fromList">
+ <span ng-if="!edit.fromList" data-translate="moon.model.metadata.edit.action.list">Add from the list</span>
+ <span ng-if="edit.fromList" data-translate="moon.model.metadata.edit.action.new">Add a new Category</span>
+ </a>
+ </div>
+
+ <div class="col-md-8 col-sm-8 col-xs-8">
+
+ <form name="selectMetaData" ng-if="edit.fromList" class="form-horizontal" role="form" >
+
+ <div class="form-group" >
+
+ <ui-select ng-model="edit.selectedMetaData" name="object">
+
+ <ui-select-match placeholder="(None)" ng-bind="$select.selected.name"></ui-select-match>
+ <ui-select-choices repeat="ametaData in edit.list">
+ <div ng-value="ametaData" ng-bind="ametaData.name"></div>
+ </ui-select-choices>
+
+ </ui-select>
+
+ </div>
+
+ <div class="form-group">
+
+ <div class="pull-left col-md-4 col-sm-4 col-xs-4">
+
+ <a href="" ng-disabled="edit.loading || !edit.selectedMetaData" ng-click="edit.deleteMetaData()" class="btn btn-warning">
+ <span class="glyphicon glyphicon-trash"></span>
+ <span data-translate="moon.model.metadata.edit.action.delete">Delete</span>
+ </a>
+
+ </div>
+
+ <div class="pull-right col-md-7 col-md-offset-1 col-sm-7 col-sm-offset-1 col-xs-7 col-xs-offset-1 ">
+
+ <a href="" ng-disabled="edit.loading || !edit.selectedMetaData" ng-click="edit.addToMetaRule()" class="btn btn-warning" style="white-space: normal;">
+ <span class="glyphicon glyphicon-link"></span>
+ <span data-translate="moon.model.metadata.edit.action.add">Add the selected Category</span>
+ </a>
+
+ </div>
+
+ </div>
+
+ <moon-loader ng-if="edit.loading"></moon-loader>
+
+ </form>
+
+ <form ng-if="!edit.fromList" class="form-horizontal" role="form" name="edit.form">
+
+ <div class="form-group" ng-class="{'has-error': edit.form.name.$invalid && edit.form.name.$dirty}">
+
+ <label for="name" class="col-sm-3 control-label" data-translate="moon.model.metadata.edit.name">Name</label>
+
+ <div class="col-sm-6">
+
+ <input name="name" id="name" class="form-control" type="text" data-ng-model="edit.metaData.name" required />
+
+ <div class="help-block" ng-show="edit.form.name.$dirty && edit.form.name.$invalid">
+ <small class="error" ng-show="edit.form.name.$error.required" data-translate="moon.model.metadata.edit.check.name.required">Name is required</small>
+ </div>
+
+ </div>
+
+ </div>
+
+ <div class="form-group">
+
+ <label for="description" class="col-sm-3 control-label" data-translate="moon.model.metadata.edit.description">Description</label>
+ <div class="col-sm-6">
+ <textarea id="description" name="description" class="form-control" data-ng-model="edit.metaData.description"></textarea>
+ </div>
+
+ </div>
+
+ <div class="form-group">
+
+ <div class="pull-right">
+
+ <a href="" ng-disabled="edit.loading" ng-click="edit.create()" class="btn btn-warning">
+ <span class="glyphicon glyphicon-save"></span>
+ <span data-translate="moon.model.metadata.edit.action.create">Create</span>
+ </a>
+
+ <moon-loader ng-if="edit.loading"></moon-loader>
+
+ </div>
+
+ </div>
+
+ </form>
+
+ </div>
+
+</div> \ No newline at end of file
diff --git a/old/moon_gui/static/app/model/edit/metadata/metadata-list.tpl.html b/old/moon_gui/static/app/model/edit/metadata/metadata-list.tpl.html
new file mode 100755
index 00000000..30a42dbc
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metadata/metadata-list.tpl.html
@@ -0,0 +1,491 @@
+<div>
+ <!--
+ !shortDisplay allow to display more details than shortDisplay.
+ It will display panels row by row and each panels list have a table with more columns
+ -->
+ <div ng-if="!list.shortDisplay">
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.subject.title">List of associated Subject Categories</h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <div class="table-responsive">
+
+ <table class="table table-striped">
+
+ <thead>
+ <tr>
+ <th data-translate="moon.model.metadata.table.id">Id</th>
+ <th data-translate="moon.model.metadata.table.name">Name</th>
+ <th data-translate="moon.model.metadata.table.description">Description</th>
+ <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th>
+ </tr>
+ </thead>
+
+ <moon-loader ng-if="list.loadingCatSub"></moon-loader>
+
+ <tbody ng-if="!list.loadingCatSub && list.getSubjectCategories().length > 0">
+ <tr ng-repeat="(key, value) in list.catSub">
+ <td ng-bind="value.id"></td>
+ <td ng-bind="value.name"></td>
+ <td ng-bind="value.description"></td>
+ <td ng-if="list.editMode">
+
+ <a href="" ng-if="!value.loader" ng-click="list.unMapSub(value)">
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span>
+ </a>
+
+ <!--<div ng-if="!value.loader" class="dropdown">
+
+ <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
+ <span data-translate="moon.model.metadata.table.action.title">Actions</span>
+ <span class="caret"></span>
+ </button>
+
+ <ul class="dropdown-menu">
+
+ <li>
+ <a href="" ng-click="list.unMapSub(value)" >
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span>
+ </a>
+ </li>
+
+ <li class="divider"></li>
+
+ <li>
+ <a href="" ng-click="list.deleteSub(value)">
+ <span class="glyphicon glyphicon-trash"></span>
+ <span class="control-label" data-translate="moon.model.metadata.table.action.delete">Delete</span>
+ </a>
+ </li>
+
+ </ul>
+
+ </div>-->
+
+ <div ng-if="value.loader">
+
+ <moon-loader></moon-loader>
+
+ </div>
+
+ </td>
+
+ </tr>
+ </tbody>
+
+
+ <tbody ng-if="!list.loadingCatSub && list.catSub.length === 0">
+ <tr>
+ <td data-translate="moon.model.metadata.subject.notFound">There is no Subjects</td>
+ <td></td>
+ <td></td>
+ <td ng-if="list.editMode"></td>
+ </tr>
+ </tbody>
+
+ </table>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ <div ng-if="list.editMode" class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.subject.add.title">Add a Subject Category</h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <moon-meta-data-edit meta-rule="list.metaRule"
+ meta-data-type="list.typeOfSubject"></moon-meta-data-edit>
+
+ </div>
+
+ </div>
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.object.title">List associated of Object Categories</h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <div class="table-responsive">
+
+ <table class="table table-striped">
+
+ <thead>
+ <tr>
+ <th data-translate="moon.model.metadata.table.id">Id</th>
+ <th data-translate="moon.model.metadata.table.name">Name</th>
+ <th data-translate="moon.model.metadata.table.description">Description</th>
+ <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th>
+
+ </tr>
+ </thead>
+
+ <moon-loader ng-if="list.loadingCatObj"></moon-loader>
+
+ <tbody ng-if="!list.loadingCatObj && list.catObj.length > 0">
+ <tr ng-repeat="(key, value) in list.catObj">
+ <td ng-bind="value.id"></td>
+ <td ng-bind="value.name"></td>
+ <td ng-bind="value.description"></td>
+ <td ng-if="list.editMode">
+
+ <a href="" ng-if="!value.loader" ng-click="list.unMapObj(value)">
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span>
+ </a>
+
+
+ <!--<div ng-if="!value.loader" class="dropdown">
+
+ <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
+ <span data-translate="moon.model.metadata.table.action.title">Actions</span>
+ <span class="caret"></span>
+ </button>
+
+ <ul class="dropdown-menu">
+
+ <li>
+ <a href="" ng-click="list.unMapObj(value)" >
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span>
+ </a>
+ </li>
+
+ <li class="divider"></li>
+
+ <li>
+ <a href="" ng-click="list.deleteObj(value)">
+ <span class="glyphicon glyphicon-trash"></span>
+ <span class="control-label" data-translate="moon.model.metadata.table.action.delete">Delete</span>
+ </a>
+ </li>
+
+ </ul>
+
+ </div>-->
+
+ <div ng-if="value.loader">
+
+ <moon-loader></moon-loader>
+
+ </div>
+
+ </td>
+ </tr>
+ </tbody>
+
+ <tbody ng-if="!list.loadingCatObj && list.catObj.length === 0">
+ <tr>
+ <td data-translate="moon.model.metadata.object.notFound">There is no Objects</td>
+ <td></td>
+ <td></td>
+ <td ng-if="list.editMode"></td>
+ </tr>
+ </tbody>
+
+ </table>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ <div ng-if="list.editMode" class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.object.add.title">Add an Object Category</h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfObject"></moon-meta-data-edit>
+
+ </div>
+
+ </div>
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.action.title">List associated of Action Categories</h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <div class="table-responsive">
+
+ <table class="table table-striped">
+
+ <thead>
+ <tr>
+ <th data-translate="moon.model.metadata.table.id">Id</th>
+ <th data-translate="moon.model.metadata.table.name">Name</th>
+ <th data-translate="moon.model.metadata.table.description">Description</th>
+ <th ng-if="list.editMode" data-translate="moon.model.metadata.table.action.title"></th>
+ </tr>
+ </thead>
+
+ <moon-loader ng-if="list.loadingCatAct"></moon-loader>
+
+ <tbody ng-if="!list.loadingCatAct && list.catAct.length > 0">
+ <tr ng-repeat="(key, value) in list.catAct">
+ <td ng-bind="value.id"></td>
+ <td ng-bind="value.name"></td>
+ <td ng-bind="value.description"></td>
+ <td ng-if="list.editMode">
+
+ <a href="" ng-if="!value.loader" ng-click="list.unMapAct(value)">
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span>
+ </a>
+
+ <!--<div ng-if="!value.loader" class="dropdown">
+
+ <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
+ <span data-translate="moon.model.metadata.table.action.title">Actions</span>
+ <span class="caret"></span>
+ </button>
+
+ <ul class="dropdown-menu">
+
+ <li>
+ <a href="" ng-click="list.unMapAct(value)" >
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span class="control-label" data-translate="moon.model.metadata.action.remove">Remove</span>
+ </a>
+ </li>
+
+ <li class="divider"></li>
+
+ <li>
+ <a href="" ng-click="list.deleteAct(value)">
+ <span class="glyphicon glyphicon-trash"></span>
+ <span class="control-label" data-translate="moon.model.metadata.table.action.delete">Delete</span>
+ </a>
+ </li>
+
+ </ul>
+
+ </div>-->
+
+ <div ng-if="value.loader">
+
+ <moon-loader></moon-loader>
+
+ </div>
+
+ </td>
+ </tr>
+ </tbody>
+
+ <tbody ng-if="!list.loadingCatAct && list.catAct.length === 0">
+ <tr>
+ <td data-translate="moon.model.metadata.action.notFound">There is no Actions</td>
+ <td></td>
+ <td></td>
+ <td ng-if="list.editMode"></td>
+ </tr>
+ </tbody>
+
+ </table>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ <div ng-if="list.editMode" class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.action.add.title">Add an Action Category</h4>
+
+ </div>
+
+ <div class="panel-body">.
+
+ <moon-meta-data-edit meta-rule="list.metaRule" meta-data-type="list.typeOfAction"></moon-meta-data-edit>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ <!--
+ !shortDisplay allow to display less details than shortDisplay.
+ It will display 3 panels on the same row, each panels have a table with on columns (name)
+ -->
+ <div ng-if="list.shortDisplay">
+
+ <div class="row">
+
+ <div class="col-md-4">
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.subject.title">List of associated Subject Categories</h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <div class="table-responsive">
+
+ <table class="table table-striped">
+
+ <thead>
+ <tr>
+ <th data-translate="moon.model.metadata.table.name">Name</th>
+ </tr>
+ </thead>
+
+ <moon-loader ng-if="list.loadingCatSub"></moon-loader>
+
+ <tbody ng-if="!list.loadingCatSub && list.getSubjectCategories().length > 0">
+ <tr ng-repeat="(key, value) in list.catSub">
+ <td ng-bind="value.name"></td>
+ </tr>
+ </tbody>
+
+
+ <tbody ng-if="!list.loadingCatSub && list.catSub.length === 0">
+ <tr>
+ <td data-translate="moon.model.metadata.subject.notFound">There is no Subjects</td>
+ </tr>
+ </tbody>
+
+ </table>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ <div class="col-md-4">
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.object.title">List associated of Object Categories</h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <div class="table-responsive">
+
+ <table class="table table-striped">
+
+ <thead>
+ <tr>
+ <th data-translate="moon.model.metadata.table.name">Name</th>
+ </tr>
+ </thead>
+
+ <moon-loader ng-if="list.loadingCatObj"></moon-loader>
+
+ <tbody ng-if="!list.loadingCatObj && list.catObj.length > 0">
+ <tr ng-repeat="(key, value) in list.catObj">
+ <td ng-bind="value.name"></td>
+ </tr>
+ </tbody>
+
+ <tbody ng-if="!list.loadingCatObj && list.catObj.length === 0">
+ <tr>
+ <td data-translate="moon.model.metadata.object.notFound">There is no Objects</td>
+ </tr>
+ </tbody>
+
+ </table>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ <div class="col-md-4">
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4 data-translate="moon.model.metadata.action.title">List associated of Action Categories</h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <div class="table-responsive">
+
+ <table class="table table-striped">
+
+ <thead>
+ <tr>
+ <th data-translate="moon.model.metadata.table.name">Name</th>
+ </tr>
+ </thead>
+
+ <moon-loader ng-if="list.loadingCatAct"></moon-loader>
+
+ <tbody ng-if="!list.loadingCatAct && list.catAct.length > 0">
+ <tr ng-repeat="(key, value) in list.catAct">
+ <td ng-bind="value.name"></td>
+ </tr>
+ </tbody>
+
+ <tbody ng-if="!list.loadingCatAct && list.catAct.length === 0">
+ <tr>
+ <td data-translate="moon.model.metadata.action.notFound">There is no Actions</td>
+ </tr>
+ </tbody>
+
+ </table>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+ </div>
+</div> \ No newline at end of file
diff --git a/old/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js b/old/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js
new file mode 100755
index 00000000..ab79b5db
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metadata/metadata.edit.dir.js
@@ -0,0 +1,332 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .directive('moonMetaDataEdit', moonMetaDataEdit);
+
+ moonMetaDataEdit.$inject = [];
+
+ function moonMetaDataEdit() {
+
+ return {
+ templateUrl : 'html/model/edit/metadata/metadata-edit.tpl.html',
+ bindToController : true,
+ controller : moonMetaDataEditController,
+ controllerAs : 'edit',
+ scope : {
+ //Type can be 'ACTION', 'OBJECT', 'SUBJECT'
+ metaDataType: '=',
+ metaRule : '='
+ },
+ restrict : 'E',
+ replace : true
+ };
+ }
+
+ angular
+ .module('moon')
+ .controller('moonMetaDataEditController', moonMetaDataEditController);
+
+ moonMetaDataEditController.$inject = ['$scope', 'metaDataService', 'META_DATA_CST', 'alertService',
+ '$translate', 'formService', 'metaRuleService', 'utilService'];
+
+ function moonMetaDataEditController($scope, metaDataService, META_DATA_CST, alertService,
+ $translate, formService, metaRuleService, utilService) {
+
+ var edit = this;
+
+ edit.metaDataType = $scope.edit.metaDataType;
+ edit.metaRule = $scope.edit.metaRule;
+
+ edit.fromList = true;
+
+ edit.form = {};
+
+ edit.metaData = { name: null, description: null};
+
+ edit.list = [];
+
+ edit.create = createMetaData;
+ edit.addToMetaRule = addToMetaRule;
+ edit.deleteMetaData = deleteMetaData;
+
+ activate();
+
+ /*
+ *
+ */
+
+ function activate(){
+
+ switch(edit.metaDataType){
+
+ case META_DATA_CST.TYPE.SUBJECT:
+
+ metaDataService.subject.findAllWithCallback(callBackList);
+ break;
+
+ case META_DATA_CST.TYPE.OBJECT:
+
+ metaDataService.object.findAllWithCallback(callBackList);
+ break;
+
+ case META_DATA_CST.TYPE.ACTION:
+
+ metaDataService.action.findAllWithCallback(callBackList);
+ break;
+
+ default :
+
+ edit.list = [];
+ break;
+
+ }
+
+ function callBackList(list){
+
+ edit.list = list;
+
+ }
+
+ }
+
+ /**
+ * Add
+ */
+
+ function addToMetaRule(){
+
+ if(!edit.selectedMetaData){
+
+ return;
+
+ }
+
+ var metaRuleToSend = angular.copy(edit.metaRule);
+
+ switch(edit.metaDataType){
+
+ case META_DATA_CST.TYPE.SUBJECT:
+
+ metaRuleToSend.subject_categories.push(edit.selectedMetaData.id);
+ break;
+
+ case META_DATA_CST.TYPE.OBJECT:
+
+ metaRuleToSend.object_categories.push(edit.selectedMetaData.id);
+ break;
+
+ case META_DATA_CST.TYPE.ACTION:
+
+ metaRuleToSend.action_categories.push(edit.selectedMetaData.id);
+ break;
+ }
+
+ metaRuleService.update(metaRuleToSend, updateMetaRuleSuccess, updateMetaRuleError);
+
+ function updateMetaRuleSuccess(data){
+
+ $translate('moon.model.metarules.update.success', { metaRuleName: metaRuleToSend.name }).then( function(translatedValue) {
+
+ alertService.alertSuccess(translatedValue);
+
+ });
+
+ metaRuleToSend = utilService.transformOne(data, 'meta_rules');
+
+ angular.copy(metaRuleToSend, edit.metaRule)
+
+ $scope.$emit('event:updateMetaRuleFromMetaDataAddSuccess', edit.metaRule);
+
+ stopLoading();
+
+ }
+
+ function updateMetaRuleError(reason){
+
+ $translate('moon.model.metarules.update.error', { metaRuleName: metaRuleToSend.name, reason: reason.message}).then( function(translatedValue) {
+
+ alertService.alertError(translatedValue);
+
+ });
+
+ stopLoading();
+
+ }
+
+ }
+
+ /**
+ * Create
+ */
+
+ function createMetaData() {
+
+ if(formService.isInvalid(edit.form)) {
+
+ formService.checkFieldsValidity(edit.form);
+
+ } else {
+
+ startLoading();
+
+ var metaDataToSend = angular.copy(edit.metaData);
+
+ switch(edit.metaDataType){
+
+ case META_DATA_CST.TYPE.SUBJECT:
+
+ metaDataService.subject.add(metaDataToSend, createSuccess, createError);
+ break;
+
+ case META_DATA_CST.TYPE.OBJECT:
+
+ metaDataService.object.add(metaDataToSend, createSuccess, createError);
+ break;
+
+ case META_DATA_CST.TYPE.ACTION:
+
+ metaDataService.action.add(metaDataToSend, createSuccess, createError);
+ break;
+ }
+
+ }
+
+ function createSuccess(data) {
+
+ var created = {};
+
+ switch(edit.metaDataType){
+
+ case META_DATA_CST.TYPE.SUBJECT:
+
+ created = utilService.transformOne(data, 'subject_categories');
+ break;
+
+ case META_DATA_CST.TYPE.OBJECT:
+
+ created = utilService.transformOne(data, 'object_categories');
+ break;
+
+ case META_DATA_CST.TYPE.ACTION:
+
+ created = utilService.transformOne(data, 'action_categories');
+ break;
+ }
+
+ $translate('moon.model.metadata.edit.create.success', { name: created.name }).then(function (translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ stopLoading();
+
+ edit.list.push(created);
+
+ displayList();
+
+ }
+
+ function createError(reason) {
+
+ $translate('moon.model.metadata.edit.create.error', { name: metaDataToSend.name }).then(function (translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ stopLoading();
+
+ }
+
+ }
+
+ function deleteMetaData(){
+
+ if(!edit.selectedMetaData){
+
+ return;
+
+ }
+
+ startLoading();
+
+ var metaDataToDelete = angular.copy(edit.selectedMetaData);
+
+ switch(edit.metaDataType){
+ case META_DATA_CST.TYPE.SUBJECT:
+
+ metaDataService.subject.delete(metaDataToDelete, deleteSuccess, deleteError);
+ break;
+
+ case META_DATA_CST.TYPE.OBJECT:
+
+ metaDataService.object.delete(metaDataToDelete, deleteSuccess, deleteError);
+ break;
+
+ case META_DATA_CST.TYPE.ACTION:
+
+ metaDataService.action.delete(metaDataToDelete, deleteSuccess, deleteError);
+ break;
+ }
+
+
+ function deleteSuccess(data) {
+
+ $translate('moon.model.metadata.edit.delete.success', { name: metaDataToDelete.name }).then(function (translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ metaRuleService.findOneWithMetaData(edit.metaRule.id).then( function(metaRule){
+
+ angular.copy(metaRule, edit.metaRule)
+
+ cleanSelectedValue();
+
+ activate();
+
+ stopLoading();
+
+ $scope.$emit('event:deleteMetaDataFromMetaDataAddSuccess', edit.metaRule);
+
+ });
+
+ }
+
+ function deleteError(reason) {
+
+ $translate('moon.model.metadata.edit.delete.error', { name: metaDataToDelete.name }).then(function (translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ stopLoading();
+
+ }
+ }
+
+ function cleanSelectedValue(){
+
+ delete edit.selectedMetaData;
+
+ }
+
+ function startLoading(){
+
+ edit.loading = true;
+
+ }
+
+ function stopLoading(){
+
+ edit.loading = false;
+
+ }
+
+ function displayList(){
+
+ edit.fromList = true;
+
+ }
+
+ }
+
+})(); \ No newline at end of file
diff --git a/old/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js b/old/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js
new file mode 100755
index 00000000..305192b6
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metadata/metadata.list.dir.js
@@ -0,0 +1,374 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .directive('moonMetaDataList', moonMetaDataList);
+
+ moonMetaDataList.$inject = [];
+
+ function moonMetaDataList() {
+
+ return {
+ templateUrl : 'html/model/edit/metadata/metadata-list.tpl.html',
+ bindToController : true,
+ controller : moonMetaDataListController,
+ controllerAs : 'list',
+ scope : {
+ metaRule: '=',
+ editMode: '=',
+ // shortDisplay : boolean value
+ //shortDisplay: '='
+ },
+ restrict : 'E',
+ replace : true
+ };
+ }
+
+ angular
+ .module('moon')
+ .controller('moonMetaDataListController', moonMetaDataListController);
+
+ moonMetaDataListController.$inject = ['$scope', '$rootScope', 'metaDataService', '$translate', 'alertService', 'metaRuleService', 'META_DATA_CST', 'utilService'];
+
+ function moonMetaDataListController($scope, $rootScope, metaDataService, $translate, alertService, metaRuleService, META_DATA_CST, utilService){
+
+ var list = this;
+
+ list.metaRule = $scope.list.metaRule;
+ list.editMode = $scope.list.editMode;
+ list.shortDisplay = $scope.list.shortDisplay;
+
+ list.typeOfSubject = META_DATA_CST.TYPE.SUBJECT;
+ list.typeOfObject = META_DATA_CST.TYPE.OBJECT;
+ list.typeOfAction = META_DATA_CST.TYPE.ACTION;
+
+ list.unMapSub = unMapSub;
+ list.unMapObj = unMapObj;
+ list.unMapAct = unMapAct;
+
+ // list.deleteSub = deleteSub;
+ // list.deleteObj = deleteObj;
+ // list.deleteAct = deleteAct;
+
+ list.getSubjectCategories = getSubjectCategories;
+ list.getObjectCategories = getObjectCategories;
+ list.getActionCategories = getActionCategories;
+
+ activate();
+
+ function activate(){
+
+ manageSubjectCategories();
+
+ manageObjectCategories();
+
+ manageActionCategories();
+
+ }
+
+ var rootListeners = {
+
+ 'event:updateMetaRuleFromMetaDataAddSuccess': $rootScope.$on('event:updateMetaRuleFromMetaDataAddSuccess', updateMetaRuleCategories),
+
+ 'event:deleteMetaDataFromMetaDataAddSuccess': $rootScope.$on('event:deleteMetaDataFromMetaDataAddSuccess', deleteMetaRuleCategories)
+
+ };
+
+ for (var unbind in rootListeners) {
+ $scope.$on('$destroy', rootListeners[unbind]);
+ }
+
+ function manageSubjectCategories(){
+
+ list.loadingCatSub = true;
+
+ metaDataService.subject.findSomeWithCallback(list.metaRule.subject_categories, function(categories){
+
+ list.catSub = categories;
+ list.loadingCatSub = false;
+
+ });
+ }
+
+ function manageObjectCategories(){
+
+ list.loadingCatObj = true;
+
+ metaDataService.object.findSomeWithCallback(list.metaRule.object_categories, function(categories){
+
+ list.catObj = categories;
+ list.loadingCatObj = false;
+
+ });
+
+ }
+
+ function manageActionCategories(){
+
+ list.loadingCatAct = true;
+
+ metaDataService.action.findSomeWithCallback(list.metaRule.action_categories, function(categories){
+
+ list.catAct = categories;
+ list.loadingCatAct = false;
+
+ });
+
+ }
+
+
+ /**
+ * UnMap
+ */
+
+ function unMapSub(subject){
+
+ subject.loader = true;
+
+ var metaRuleToSend = angular.copy(list.metaRule);
+
+ metaRuleToSend.subject_categories = _.without(metaRuleToSend.subject_categories, subject.id);
+
+ metaRuleService.update(metaRuleToSend, updateMetaRuleSuccess, updateMetaRuleError);
+
+ function updateMetaRuleSuccess(data){
+
+ $translate('moon.model.metarules.update.success', { metaRuleName: list.metaRule.name }).then( function(translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ metaRuleToSend = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules'));
+ angular.copy(metaRuleToSend, list.metaRule);
+
+ activate();
+
+ subject.loader = false;
+
+ }
+
+ function updateMetaRuleError(reason){
+
+ $translate('moon.model.metarules.update.error', { metaRuleName: list.metaRule.name, reason: reason.message}).then( function(translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ subject.loader = false;
+
+ }
+
+ }
+
+ function unMapObj(object){
+
+ object.loader = true;
+
+ var metaRuleToSend = angular.copy(list.metaRule);
+
+ metaRuleToSend.object_categories = _.without(metaRuleToSend.object_categories, object.id);
+
+ metaRuleService.update(metaRuleToSend, updateMetaRuleSuccess, updateMetaRuleError);
+
+ function updateMetaRuleSuccess(data){
+
+ $translate('moon.model.metarules.update.success', { metaRuleName: list.metaRule.name }).then( function(translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ metaRuleToSend = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules'));
+ angular.copy(metaRuleToSend, list.metaRule);
+
+ activate();
+
+ object.loader = false;
+
+ }
+
+ function updateMetaRuleError(reason){
+
+ $translate('moon.model.metarules.update.error', { metaRuleName: list.metaRule.name, reason: reason.message}).then( function(translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ object.loader = false;
+
+ }
+
+ }
+
+ function unMapAct(action){
+
+ action.loader = true;
+
+ var metaRuleToSend = angular.copy(list.metaRule);
+
+ metaRuleToSend.action_categories = _.without(metaRuleToSend.action_categories, action.id);
+
+ metaRuleService.update(metaRuleToSend, updateMetaRuleSuccess, updateMetaRuleError);
+
+ function updateMetaRuleSuccess(data){
+
+ $translate('moon.model.metarules.update.success', { metaRuleName: list.metaRule.name }).then( function(translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ metaRuleToSend = metaRuleService.findMetaDataFromMetaRule(utilService.transformOne(data, 'meta_rules'));
+ angular.copy(metaRuleToSend, list.metaRule);
+
+ activate();
+
+ action.loader = false;
+
+ }
+
+ function updateMetaRuleError(reason){
+
+ $translate('moon.model.metarules.update.error', { metaRuleName: list.metaRule.name, reason: reason.message}).then( function(translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ action.loader = false;
+
+ }
+
+ }
+
+ // /**
+ // * Delete
+ // */
+ //
+ // function deleteSub(subject){
+ //
+ // subject.loader = true;
+ //
+ // metaDataService.subject.delete(subject, deleteSubSuccess, deleteSubError);
+ //
+ // function deleteSubSuccess(data){
+ //
+ // $translate('moon.model.metadata.subject.delete.success', { subjectName: subject.name }).then( function(translatedValue) {
+ // alertService.alertSuccess(translatedValue);
+ // });
+ //
+ // removeSubFromSubList(subject);
+ //
+ // subject.loader = false;
+ //
+ // }
+ //
+ // function deleteSubError(reason){
+ //
+ // $translate('moon.model.metadata.subject.delete.error',
+ // { subjectName: subject.name, reason: reason.message}).then( function(translatedValue) {
+ // alertService.alertError(translatedValue);
+ // });
+ //
+ // subject.loader = false;
+ //
+ // }
+ // }
+ //
+ // function deleteObj(object){
+ //
+ // object.loader = true;
+ //
+ // metaDataService.object.delete(object, deleteObjSuccess, deleteObjError);
+ //
+ // function deleteObjSuccess(data){
+ //
+ // $translate('moon.model.metadata.object.delete.success', { objectName: object.name }).then( function(translatedValue) {
+ // alertService.alertSuccess(translatedValue);
+ // });
+ //
+ // removeObjFromObjList(object);
+ // /*list.catSub = metaDataService.subject.findSome(list.metaRule.subject_categories);
+ // list.catObj = metaDataService.object.findSome(list.metaRule.object_categories);
+ // list.catAct = metaDataService.action.findSome(list.metaRule.action_categories);*/
+ //
+ // object.loader = false;
+ //
+ // }
+ //
+ // function deleteObjError(reason){
+ //
+ // $translate('moon.model.metadata.object.delete.error', { objectName: object.name, reason: reason.message}).then( function(translatedValue) {
+ // alertService.alertError(translatedValue);
+ // });
+ //
+ // object.loader = false;
+ // }
+ // }
+ //
+ // function deleteAct(action){
+ //
+ // action.loader = true;
+ //
+ // metaDataService.action.delete(action, deleteActSuccess, deleteActError);
+ //
+ // function deleteActSuccess(data){
+ //
+ // $translate('moon.model.metadata.action.delete.success', { actionName: action.name }).then( function(translatedValue) {
+ // alertService.alertSuccess(translatedValue);
+ // });
+ //
+ // removeActFromActList(action);
+ //
+ // action.loader = false;
+ //
+ // }
+ //
+ // function deleteActError(reason){
+ //
+ // $translate('moon.model.metadata.action.delete.error', { actionName: action.name, reason: reason.message}).then( function(translatedValue) {
+ // alertService.alertError(translatedValue);
+ // });
+ //
+ // action.loader = false;
+ //
+ // }
+ // }
+
+ function getSubjectCategories(){
+ return list.catSub ? list.catSub : [];
+ }
+
+ function getObjectCategories(){
+ return list.catObj ? list.catObj : [];
+ }
+
+ function getActionCategories(){
+ return list.catAct ? list.catAct : [];
+ }
+
+ // function removeSubFromSubList(subject){
+ // list.catSub = _.without(list.catSub, subject);
+ // }
+ //
+ // function removeObjFromObjList(object){
+ // list.catObj = _.without(list.catObj, object);
+ // }
+ //
+ // function removeActFromActList(action){
+ // list.catAct = _.without(list.catAct, action);
+ // }
+
+ function updateMetaRuleCategories( event, metaRule){
+
+ list.metaRule = metaRule;
+
+ activate();
+
+ }
+
+
+ function deleteMetaRuleCategories( event, metaRule){
+
+ list.metaRule = metaRule;
+
+ activate();
+
+ }
+
+ }
+
+})(); \ No newline at end of file
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-add.tpl.html b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-add.tpl.html
new file mode 100755
index 00000000..a721e6d0
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-add.tpl.html
@@ -0,0 +1,50 @@
+<div class="row">
+
+ <form class="form-horizontal" role="form" name="add.form">
+
+ <div class="form-group" ng-class="{'has-error': add.form.name.$invalid && add.form.name.$dirty}">
+
+ <label for="name" class="col-sm-3 control-label" data-translate="moon.model.metarules.add.form.name">Name</label>
+
+ <div class="col-sm-6">
+
+ <input name="name" id="name" class="form-control" type="text" data-ng-model="add.metaRule.name" required />
+
+ <div class="help-block" ng-show="add.form.name.$dirty && add.form.name.$invalid">
+ <small class="error" ng-show="add.form.name.$error.required" data-translate="moon.model.metarules.add.check.name.required">Name is required</small>
+ </div>
+
+ </div>
+ </div>
+
+ <div class="form-group">
+
+ <label for="description" class="col-sm-3 control-label" data-translate="moon.model.metarules.add.form.description">Description</label>
+ <div class="col-sm-6">
+ <textarea id="description" name="description" class="form-control" data-ng-model="add.metaRule.description"></textarea>
+ </div>
+
+ </div>
+
+
+ <div class="form-group">
+
+ <div class="col-sm-8">
+
+ <div class="pull-right">
+
+ <a href="" ng-disabled="add.loading" ng-click="add.create()" class="btn btn-warning">
+ <span class="glyphicon glyphicon-save"></span>
+ <span data-translate="moon.model.metarules.add.action.create">Create</span>
+ </a>
+
+ <moon-loader ng-if="add.loading"></moon-loader>
+
+ </div>
+
+ </div>
+
+ </div>
+ </form>
+
+</div>
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-map.tpl.html b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-map.tpl.html
new file mode 100755
index 00000000..1830204b
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-map.tpl.html
@@ -0,0 +1,102 @@
+<div ng-controller="moonMetaRulesMapController as map" class="modal" tabindex="-1" data-role="MapMetaRules">
+
+ <div class="modal-dialog">
+
+ <div class="modal-content">
+
+ <div class="modal-header">
+
+ <button type="button" class="close" ng-click="$hide()">&times;</button>
+ <h4 class="modal-title" data-translate="moon.model.metarules.map.title"></h4>
+
+ </div>
+
+ <div class="modal-body">
+
+ <div class="row">
+
+ <div class="col-sm-3">
+
+ <button class="btn btn-primary" style="white-space: normal;" ng-click="map.addMetaRuleToList = !map.addMetaRuleToList">
+
+ <span ng-if="!map.addMetaRuleToList" data-translate="moon.model.metarules.map.action.new">Add a new Meta Rule</span>
+ <span ng-if="map.addMetaRuleToList" data-translate="moon.model.metarules.map.action.list">List of Meta Rules</span>
+
+ </button>
+
+ </div>
+
+ <div class="col-sm-9">
+
+ <form class="form-horizontal" role="form" name="map.form">
+
+ <div class="form-group" ng-if="!map.addMetaRuleToList">
+
+ <label class="col-sm-3 control-label" data-translate="moon.model.metarules.map.form.list">List of Meta Rule</label>
+
+ <div class="col-sm-9">
+
+ <ui-select ng-model="map.selectedMetaRule" name="object">
+
+ <ui-select-match placeholder="(None)" ng-bind="$select.selected.name"></ui-select-match>
+ <ui-select-choices repeat="ametaRule in map.metaRules">
+ <div ng-value="ametaRule" ng-bind="ametaRule.name"></div>
+ </ui-select-choices>
+
+ </ui-select>
+
+ </div>
+
+ </div>
+
+ <div class="form-group" ng-if="!map.addMetaRuleToList">
+
+ <moon-loader ng-if="map.metaRulesLoading || map.mappingLoading" ></moon-loader>
+
+ <div class="col-sm-5">
+ <a href="" ng-disabled="map.metaRulesLoading || map.mappingLoading || !map.selectedMetaRule" ng-click="map.deleteMetaRule()" class="btn btn-warning" style="white-space: normal;">
+ <span class="glyphicon glyphicon-trash"></span>
+ <span data-translate="moon.model.metarules.map.action.delete">Delete the selected Meta Rule</span>
+ </a>
+ </div>
+
+ <div class="col-sm-5 col-sm-offset-2">
+ <a href="" ng-disabled="map.metaRulesLoading || map.mappingLoading || !map.selectedMetaRule" ng-click="map.mapToModel()" class="btn btn-warning" style="white-space: normal;">
+ <span class="glyphicon glyphicon-link"></span>
+ <span data-translate="moon.model.metarules.map.action.add">Add the selected Meta Rule</span>
+ </a>
+ </div>
+
+ </div>
+
+ <div class="form-group" ng-if="map.addMetaRuleToList">
+
+ <moon-meta-rules-add></moon-meta-rules-add>
+
+ </div>
+
+ </form>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ <div class="modal-footer">
+
+ <div class="btn-toolbar" style="float: right;">
+
+ <a href="" ng-click="$hide()" class="btn btn-default">
+ <span data-translate="moon.model.metarules.add.action.cancel">Cancel</span>
+ </a>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+
+</div>
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-unmap.tpl.html b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-unmap.tpl.html
new file mode 100755
index 00000000..bb02aba2
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules-unmap.tpl.html
@@ -0,0 +1,35 @@
+<div ng-controller="MetaRulesUnMapController as unmap" class="modal" tabindex="-1" data-role="modalUnMapMetaRule">
+
+ <div class="modal-dialog">
+
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <button type="button" class="close" ng-click="$hide()">&times;</button>
+ <h4 class="modal-title" data-translate="moon.model.metarules.unmap.title"></h4>
+ </div>
+
+ <div class="modal-body">
+ <span data-translate="moon.model.metarules.unmap.content" data-translate-values="{ modelName: unmap.model.name, metaRuleName: unmap.metaRule.name }"></span>
+ </div>
+
+ <div class="modal-footer">
+
+ <div class="btn-toolbar" style="float: right;">
+ <a href="" ng-click="$hide()" class="btn btn-default">
+ <span data-translate="moon.model.metarules.unmap.action.cancel">Cancel</span>
+ </a>
+ <a href="" ng-disabled="unmap.unMappingLoading" ng-click="unmap.unmap()" class="btn btn-warning">
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span data-translate="moon.model.metarules.unmap.action.unmap">Unmap</span>
+ </a>
+ <moon-loader ng-if="unmap.unMappingLoading" ></moon-loader>
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+
+</div> \ No newline at end of file
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.controller.add.js b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.controller.add.js
new file mode 100755
index 00000000..a95951fa
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.controller.add.js
@@ -0,0 +1,99 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .directive('moonMetaRulesAdd', moonMetaRulesAdd);
+
+ moonMetaRulesAdd.$inject = [];
+
+ function moonMetaRulesAdd() {
+
+ return {
+ templateUrl : 'html/model/edit/metarules/action/mapping/metarules-add.tpl.html',
+ bindToController : true,
+ controller : moonMetaRulesAddController,
+ controllerAs : 'add',
+ scope : {
+ metaRules : '='
+ },
+ restrict : 'E',
+ replace : true
+ };
+ }
+
+
+ angular
+ .module('moon')
+ .controller('moonMetaRulesAddController', moonMetaRulesAddController);
+
+ moonMetaRulesAddController.$inject = ['$scope', 'metaRuleService', 'alertService', '$translate', 'formService', 'utilService'];
+
+ function moonMetaRulesAddController($scope, metaRuleService, alertService, $translate, formService, utilService) {
+
+ var add = this;
+
+ /*
+ *
+ */
+
+ add.laoading = false;
+
+ add.form = {};
+
+ add.metaRule = { name: null, description: null, subject_categories : [], object_categories : [], action_categories : [] };
+
+ add.create = createMetaRule;
+
+ activate();
+
+ function activate(){
+
+ }
+
+ function createMetaRule() {
+
+ if(formService.isInvalid(add.form)) {
+
+ formService.checkFieldsValidity(add.form);
+
+ } else {
+
+ add.loading = true;
+
+ metaRuleService.data.create({}, add.metaRule, createSuccess, createError);
+
+ }
+
+ function createSuccess(data) {
+
+ var createdMetaRule = utilService.transformOne(data, 'meta_rules');
+
+ $translate('moon.model.metarules.add.success', { metaRuleName: createdMetaRule.name }).then(function (translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ add.loading = false;
+
+ $scope.$emit('event:metaRuleCreatedSuccess', createdMetaRule);
+
+ }
+
+ function createError(reason) {
+
+ $translate('moon.model.metarules.add.error', { metaRuleName: add.metaRule.name }).then(function (translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ add.loading = false;
+
+ $scope.$emit('event:metaRuleCreatedError', add.project);
+
+ }
+
+ }
+
+ }
+
+})();
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.map.controller.js b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.map.controller.js
new file mode 100755
index 00000000..cf9ba06c
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.map.controller.js
@@ -0,0 +1,213 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .controller('moonMetaRulesMapController', moonMetaRulesMapController);
+
+ moonMetaRulesMapController.$inject = ['$scope', '$rootScope', 'alertService', '$translate', 'formService', 'metaRuleService', 'modelService', 'utilService'];
+
+ function moonMetaRulesMapController($scope, $rootScope, alertService, $translate, formService, metaRuleService, modelService, utilService ) {
+
+ var map = this;
+
+ /*
+ *
+ */
+
+ map.metaRules = [];
+
+ map.model = $scope.model;
+
+ map.addMetaRuleToList = false;
+
+ map.mapToModel = mapToModel;
+
+ map.deleteMetaRule = deleteMetaRule;
+
+ activate();
+
+ function activate() {
+
+ resolveMetaRules();
+
+ }
+
+ /*
+ * ---- events
+ */
+ var rootListeners = {
+
+ 'event:metaRuleCreatedSuccess': $rootScope.$on('event:metaRuleCreatedSuccess', metaRuleCreatedSuccess),
+ 'event:metaRuleCreatedError': $rootScope.$on('event:metaRuleCreatedError', metaRuleCreatedError)
+
+ };
+
+ for (var unbind in rootListeners) {
+ $scope.$on('$destroy', rootListeners[unbind]);
+ }
+
+
+ /*
+ *
+ */
+
+ function resolveMetaRules() {
+
+ map.metaRulesLoading = true;
+
+ metaRuleService.findAllWithCallback(
+ function(metaRules){
+ map.metaRules = metaRules;
+ map.metaRulesLoading = false;
+ }
+ );
+
+ }
+
+ function mapToModel() {
+
+ if (formService.isInvalid(map.form)) {
+
+ formService.checkFieldsValidity(map.form);
+
+ } else {
+
+ map.mappingLoading = true;
+
+ var modelToSend = angular.copy(map.model);
+
+ modelToSend.meta_rules.push(map.selectedMetaRule.id);
+
+ modelService.update(modelToSend, mapSuccess, mapError);
+
+ }
+
+ function mapSuccess(data) {
+
+ var modelReceived = utilService.transformOne(data, 'models');
+
+ metaRuleService.findSomeWithMetaData(modelReceived.meta_rules).then(function(metaRules){
+
+ modelReceived.meta_rules_values = metaRules;
+
+ $translate('moon.model.metarules.map.success', {
+
+ modelName: modelReceived.name,
+ metaRuleName: map.selectedMetaRule.name
+
+ }).then(function (translatedValue) {
+
+ alertService.alertSuccess(translatedValue);
+
+ });
+
+ map.mappingLoading = false;
+
+ $scope.$emit('event:metaRuleMapToModelSuccess', modelReceived);
+
+ });
+
+ }
+
+ function mapError(response) {
+
+ $translate('moon.model.metarules.map.error', {
+
+ modelName: map.model.name,
+ metaRuleName: map.selectedMetaRule.name
+
+ }).then(function (translatedValue) {
+
+ alertService.alertError(translatedValue);
+
+ });
+
+ map.mappingLoading = false;
+
+ }
+ }
+
+ function cleanSelectedValue(){
+
+ delete map.selectedMetaRule;
+
+ }
+
+
+ function deleteMetaRule(){
+
+ if(!map.selectedMetaRule){
+
+ return;
+
+ }
+
+ map.mappingLoading = true;
+
+ var metaRuleTodelete = angular.copy(map.selectedMetaRule);
+
+ metaRuleService.delete(metaRuleTodelete, deleteSuccess, deleteError);
+
+ function deleteSuccess(data) {
+
+ $translate('moon.model.metarules.delete.success', { metaRuleName: metaRuleTodelete.name }).then(function (translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ cleanSelectedValue();
+
+ map.mappingLoading = false;
+
+ resolveMetaRules();
+
+ // later this event will have to be catch, because the model can use the deleted MetaRule
+ $scope.$emit('event:deleteMetaRule', metaRuleTodelete);
+
+ }
+
+ function deleteError(reason) {
+
+ $translate('moon.model.metarules.delete.error', { metaRuleName: metaRuleTodelete.name }).then(function (translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ map.mappingLoading = false;
+
+ }
+ }
+
+
+
+
+
+
+ /**
+ * This function will add a metaRule to the current list of metaRules
+ * @param event
+ * @param metaRule {...} metaRule to add
+ */
+ function metaRuleCreatedSuccess(event, metaRule) {
+
+ map.metaRules.push(metaRule);
+ showList();
+
+ }
+
+ /**
+ * This function hide the add MetaRule Modal
+ * @param event
+ */
+ function metaRuleCreatedError(event) {
+
+ }
+
+ function showList(){
+ map.addMetaRuleToList = false;
+ }
+
+ }
+
+
+})(); \ No newline at end of file
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js
new file mode 100755
index 00000000..30f32d51
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js
@@ -0,0 +1,74 @@
+/**
+ * @author arnaud marhin<arnaud.marhin@orange.com>
+ */
+
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .controller('MetaRulesUnMapController', MetaRulesUnMapController);
+
+ MetaRulesUnMapController.$inject = ['$scope', '$translate', 'alertService', 'modelService'];
+
+ function MetaRulesUnMapController($scope, $translate, alertService, modelService) {
+
+ var unmap = this;
+
+ /*
+ *
+ */
+
+ unmap.model = $scope.model;
+ unmap.metaRule = $scope.metaRule;
+
+ unmap.unMappingLoading = false;
+
+ unmap.unmap = unMapModelToMetaRule;
+
+ /*
+ *
+ */
+
+ function unMapModelToMetaRule() {
+
+ unmap.unMappingLoading = true;
+
+ var modelToUpdate = angular.copy(unmap.model);
+
+ modelToUpdate.meta_rules = _.without(modelToUpdate.meta_rules, unmap.metaRule.id);
+
+ modelService.update(modelToUpdate, unMapSuccess, unMapError);
+
+ function unMapSuccess(data) {
+
+ $translate('moon.model.metarules.unmap.success', { modelName: unmap.model.name, metaRuleName: unmap.metaRule.name })
+ .then(function (translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ unmap.unMappingLoading = false;
+
+ $scope.$emit('event:metaRuleUnMappedToModelSuccess', modelToUpdate);
+
+ }
+
+ function unMapError(reason) {
+
+ $translate('moon.model.metarules.unmap.error', { modelName: unmap.model.name, metaRuleName: unmap.metaRule.name })
+ .then(function (translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ unmap.unMappingLoading = false;
+
+ $scope.$emit('event:metaRuleUnMappedToModelError');
+
+ }
+
+ }
+
+ }
+
+})();
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/metarules-edit-basic.tpl.html b/old/moon_gui/static/app/model/edit/metarules/action/metarules-edit-basic.tpl.html
new file mode 100755
index 00000000..b6136195
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/metarules-edit-basic.tpl.html
@@ -0,0 +1,67 @@
+<div class="row">
+
+ <form class="form-horizontal" role="form" name="edit.form">
+
+ <div class="form-group">
+
+ <label for="id" class="col-sm-3 control-label" data-translate="moon.model.metarules.edit.basic.form.id">Id</label>
+
+ <div class="col-sm-6">
+
+ <input name="id" id="id" disabled class="form-control" type="text" data-ng-model="edit.metaRuleToEdit.id" required />
+
+ </div>
+
+ </div>
+
+ <div class="form-group" ng-class="{'has-error': edit.form.name.$invalid && edit.form.name.$dirty}">
+
+ <label for="name" class="col-sm-3 control-label" data-translate="moon.model.metarules.edit.basic.form.name">Name</label>
+
+ <div class="col-sm-6">
+
+ <input name="name" id="name" class="form-control" type="text" data-ng-model="edit.metaRuleToEdit.name" required />
+
+ <div class="help-block" ng-show="edit.form.name.$dirty && edit.form.name.$invalid">
+ <small class="error" ng-show="edit.form.name.$error.required" data-translate="moon.model.metarules.edit.basic.check.name.required">Name is required</small>
+ </div>
+
+ </div>
+
+ </div>
+
+ <div class="form-group">
+
+ <label for="description" class="col-sm-3 control-label" data-translate="moon.model.metarules.edit.basic.form.description">Description</label>
+ <div class="col-sm-6">
+ <textarea id="description" name="description" class="form-control" data-ng-model="edit.metaRuleToEdit.description"></textarea>
+ </div>
+
+ </div>
+
+ <div class="form-group">
+
+ <div class="col-sm-2 col-sm-offset-3">
+
+ <a href="" ng-disabled="edit.loading" ng-click="edit.init()" class="btn btn-default">
+ <span data-translate="moon.model.metarules.edit.basic.action.init">Init</span>
+ </a>
+
+ </div>
+
+ <div class="col-sm-4 col-sm-offset-2">
+
+ <a href="" ng-disabled="edit.loading" ng-click="edit.editMetaRule()" class="btn btn-warning">
+ <span class="glyphicon glyphicon-save"></span>
+ <span data-translate="moon.model.metarules.edit.basic.action.update">Update</span>
+ </a>
+
+ <moon-loader ng-if="edit.loading"></moon-loader>
+
+ </div>
+
+ </div>
+
+ </form>
+
+</div> \ No newline at end of file
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/metarules-edit.tpl.html b/old/moon_gui/static/app/model/edit/metarules/action/metarules-edit.tpl.html
new file mode 100755
index 00000000..7b074448
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/metarules-edit.tpl.html
@@ -0,0 +1,62 @@
+<div ng-controller="MetaRulesEditController as edit" class="modal" tabindex="-1" data-role="modalViewProject">
+
+ <div class="modal-dialog">
+
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <button type="button" class="close" ng-click="$hide()">&times;</button>
+ <h4 class="modal-title" data-translate="moon.model.metarules.edit.title" data-translate-values="{metaRuleName: edit.metaRule.name}"></h4>
+ </div>
+
+ <div class="modal-body">
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <h4>
+ <span data-translate="moon.model.edit.basic.title" >Basic Information</span>
+ <a href="" ng-click="edit.editBasic = !edit.editBasic">
+ <span data-translate="moon.model.metarules.edit.update">Update</span>
+ <span class="glyphicon glyphicon-cog"></span>
+ </a>
+ </h4>
+
+ </div>
+
+ <div class="panel-body">
+
+ <div ng-if="edit.editBasic">
+ <moon-meta-rules-edit-basic meta-rule="edit.metaRule"></moon-meta-rules-edit-basic>
+ </div>
+
+ <div ng-if="!edit.editBasic">
+ <dl class="dl-horizontal">
+ <dt>Id</dt>
+ <dd ng-bind="edit.metaRule.id"></dd>
+ <dt>Name</dt>
+ <dd ng-bind="edit.metaRule.name"></dd>
+ <dt>Description</dt>
+ <dd ng-bind="edit.metaRule.description"></dd>
+ </dl>
+ </div>
+ </div>
+
+ </div>
+
+ <moon-meta-data-list edit-mode="true" meta-rule="edit.metaRule"></moon-meta-data-list>
+
+ </div>
+
+ <div class="modal-footer top10">
+ <div class="btn-toolbar" style="float: right;">
+ <button ng-click="$hide()" class="btn btn-default" data-translate="moon.model.view.action.close">Close</button>
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+
+</div>
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/metarules.controller.edit.js b/old/moon_gui/static/app/model/edit/metarules/action/metarules.controller.edit.js
new file mode 100755
index 00000000..de6965d0
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/metarules.controller.edit.js
@@ -0,0 +1,49 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .controller('MetaRulesEditController', MetaRulesEditController);
+
+ MetaRulesEditController.$inject = ['$scope', '$rootScope'];
+
+ function MetaRulesEditController($scope, $rootScope) {
+
+ var edit = this;
+
+ edit.metaRule = $scope.metaRule;
+
+ activate();
+
+ function activate(){
+ }
+
+
+ /*
+ * ---- events
+ */
+ var rootListeners = {
+
+ 'event:metaRuleBasicUpdatedSuccess': $rootScope.$on('event:metaRuleBasicUpdatedSuccess', metaRuleUpdatedSuccess)
+
+ };
+
+ for (var unbind in rootListeners) {
+ $scope.$on('$destroy', rootListeners[unbind]);
+ }
+
+ /**
+ * When the MetaRule is updated, this function refresh the current metaRule with the new changes
+ * @param event
+ * @param metaRule
+ */
+ function metaRuleUpdatedSuccess(event, metaRule){
+
+ angular.copy(metaRule, edit.metaRule);
+
+ }
+
+ }
+
+})();
diff --git a/old/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js b/old/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js
new file mode 100755
index 00000000..b9dcd19c
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js
@@ -0,0 +1,100 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .directive('moonMetaRulesEditBasic', moonMetaRulesEditBasic);
+
+ moonMetaRulesEditBasic.$inject = [];
+
+ function moonMetaRulesEditBasic() {
+
+ return {
+ templateUrl : 'html/model/edit/metarules/action/metarules-edit-basic.tpl.html',
+ bindToController : true,
+ controller : moonMetaRulesEditBasicController,
+ controllerAs : 'edit',
+ scope : {
+ metaRule : '='
+ },
+ restrict : 'E',
+ replace : true
+ };
+
+ }
+
+ angular
+ .module('moon')
+ .controller('moonMetaRulesEditBasicController', moonMetaRulesEditBasicController);
+
+ moonMetaRulesEditBasicController.$inject = ['$scope', 'metaRuleService', 'formService', 'alertService', '$translate', 'utilService'];
+
+ function moonMetaRulesEditBasicController($scope, metaRuleService, formService, alertService, $translate, utilService){
+
+ var edit = this;
+
+ edit.editMetaRule = editMetaRule;
+ edit.init = init;
+
+ edit.form = {};
+
+ activate();
+
+ function activate(){
+
+ edit.metaRule = $scope.edit.metaRule;
+
+ edit.metaRuleToEdit = angular.copy(edit.metaRule);
+
+ }
+
+ function editMetaRule(){
+
+ if(formService.isInvalid(edit.form)) {
+
+ formService.checkFieldsValidity(edit.form);
+
+ }else{
+
+ edit.loading = true;
+
+ metaRuleService.update(edit.metaRuleToEdit, updateSuccess, updateError);
+
+ }
+
+ function updateSuccess(data) {
+
+ var updatedMetaRule = utilService.transformOne(data, 'meta_rules');
+
+ angular.copy(updatedMetaRule, edit.metaRule);
+
+ $translate('moon.model.metarules.edit.basic.success', { metaRuleName: updatedMetaRule.name }).then( function(translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ edit.loading = false;
+
+ $scope.$emit('event:metaRuleBasicUpdatedSuccess', edit.metaRule);
+
+ }
+
+ function updateError(reason) {
+
+ $translate('moon.model.edit.basic.error', { metaRuleName: edit.metaRule.name }).then( function(translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ edit.loading = false;
+
+ }
+ }
+
+ function init(){
+
+ edit.metaRuleToEdit = angular.copy(edit.metaRule);
+
+ }
+ }
+
+})();
diff --git a/old/moon_gui/static/app/model/edit/metarules/metarules-list.tpl.html b/old/moon_gui/static/app/model/edit/metarules/metarules-list.tpl.html
new file mode 100755
index 00000000..ebe307c3
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/metarules-list.tpl.html
@@ -0,0 +1,138 @@
+<div>
+
+
+ <div><h4 data-translate="moon.model.metarules.title">List of Meta Rules</h4></div>
+
+ <div class="table-responsive" data-role="table">
+ <table class="table table-striped table-hover" ng-table="list.table">
+
+ <colgroup>
+ <col class="col-md-2" />
+ <col class="col-md-2" />
+ <col class="col-md-1" />
+ <col class="col-md-1" />
+ <col class="col-md-1" />
+ <col class="col-md-2" />
+ </colgroup>
+
+ <thead>
+
+ <tr>
+
+ <th class="customTables sortable"
+ ng-class="{ 'sort-asc': list.table.isSortBy('name', 'asc'), 'sort-desc': list.table.isSortBy('name', 'desc') }"
+ ng-click="list.table.sorting('name', list.table.isSortBy('name', 'asc') ? 'desc' : 'asc')">
+ <div data-translate="moon.model.metarules.table.name">Name</div>
+ </th>
+
+ <th class="customTables sortable"
+ ng-class="{ 'sort-asc': list.table.isSortBy('description', 'asc'), 'sort-desc': list.table.isSortBy('description', 'desc') }"
+ ng-click="list.table.sorting('description', list.table.isSortBy('description', 'asc') ? 'desc' : 'asc')">
+ <div data-translate="moon.model.metarules.table.description">Description</div>
+ </th>
+
+ <th class="customTables sortable">
+ <div data-translate="moon.model.metarules.table.metadata.subject.number">Number of Subjects</div>
+ </th>
+
+ <th class="customTables sortable">
+ <div data-translate="moon.model.metarules.table.metadata.object.number">Number of Subjects</div>
+ </th>
+
+ <th class="customTables sortable">
+ <div data-translate="moon.model.metarules.table.metadata.action.number">Number of Actions</div>
+ </th>
+
+ <th class="customTables">
+ <div data-translate="moon.model.metarules.action.title">Actions</div>
+ </th>
+ </tr>
+
+ </thead>
+
+ <tbody ng-if="!list.hasMetaRules()">
+ <tr>
+ <td colspan="2"><span data-translate="moon.model.metarules.table.notFound">There is no Meta Rules</span></td>
+ </tr>
+ </tbody>
+
+ <tbody ng-if="list.hasMetaRules()">
+
+ <tr ng-repeat="aMetaRules in $data | filter:list.search.find | orderBy:sort:reverse">
+ <td ng-bind="aMetaRules.name"></td>
+ <td ng-bind="aMetaRules.description"></td>
+ <td ng-bind="aMetaRules.subject_categories.length"></td>
+ <td ng-bind="aMetaRules.object_categories.length"></td>
+ <td ng-bind="aMetaRules.action_categories.length"></td>
+ <td>
+
+ <div ng-if="list.editMode">
+
+ <div ng-if="!value.loader" class="dropdown">
+
+ <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
+ <span data-translate="moon.model.metadata.table.action.title">Actions</span>
+ <span class="caret"></span>
+ </button>
+
+ <ul class="dropdown-menu">
+
+ <li>
+ <a href="" ng-click="list.unmap.showModal(aMetaRules)" >
+ <span class="glyphicon glyphicon-transfer"></span>
+ <span class="control-label" data-translate="moon.model.metarules.action.remove">Remove</span>
+ </a>
+ </li>
+
+ <li>
+ <a href="" ng-click="list.edit.showModal(aMetaRules)">
+ <span class="glyphicon glyphicon-cog"></span>
+ <span class="control-label" data-translate="moon.model.metarules.action.edit">Edit</span>
+ </a>
+ </li>
+
+ </ul>
+
+ </div>
+
+ </div>
+
+ <div ng-if="!list.editMode">
+
+ <a href="" ng-click="list.showDetail(aMetaRules)">
+
+ <span ng-if="aMetaRules.id !== list.getShowDetailValue().id">
+ <span class="glyphicon glyphicon-eye-open"></span>
+ <span class="control-label" data-translate="moon.model.metarules.action.detail.open">Consult</span>
+ </span>
+
+ <span ng-if="aMetaRules.id === list.getShowDetailValue().id">
+ <span class="glyphicon glyphicon-eye-close"></span>
+ <span class="control-label" data-translate="moon.model.metarules.action.detail.close">Close</span>
+ </span>
+
+ </a>
+
+ </div>
+
+ </td>
+ </tr>
+
+ </tbody>
+
+ </table>
+
+ <div ng-if="list.showDetailValue">
+ <moon-meta-data-list edit-mode="list.editMode" meta-rule="list.getShowDetailValue()"></moon-meta-data-list>
+ </div>
+
+ </div>
+
+ <div class="form-group" ng-if="list.editMode">
+ <a href="" ng-click="list.map.showModal()" class="btn btn-default">
+ <span class="glyphicon glyphicon-link"></span>
+ <span data-translate="moon.model.metarules.action.settings">Settings</span>
+ </a>
+ </div>
+
+</div>
diff --git a/old/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js b/old/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js
new file mode 100755
index 00000000..9c1bc72e
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/metarules/metarules.list.dir.js
@@ -0,0 +1,241 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .directive('moonMetaRulesList', moonMetaRulesList);
+
+ moonMetaRulesList.$inject = [];
+
+ function moonMetaRulesList() {
+
+ return {
+ templateUrl : 'html/model/edit/metarules/metarules-list.tpl.html',
+ bindToController : true,
+ controller : moonMetaRulesListController,
+ controllerAs : 'list',
+ scope : {
+ // if edit and delete possibilities are displayed
+ // Value are True or False
+ editMode : '=',
+ mappedModel : '='
+ },
+ restrict : 'E',
+ replace : true
+ };
+ }
+
+ angular
+ .module('moon')
+ .controller('moonMetaRulesListController', moonMetaRulesListController);
+
+ moonMetaRulesListController.$inject = ['$scope', '$rootScope', 'NgTableParams', '$filter', '$modal', 'metaRuleService'];
+
+ function moonMetaRulesListController($scope, $rootScope, NgTableParams, $filter, $modal, metaRuleService ){
+
+ var list = this;
+
+ list.table = {};
+
+ list.editMode = $scope.list.editMode;
+ list.model = $scope.list.mappedModel;
+ list.metaRules = list.model.meta_rules_values;
+
+ list.getMetaRules = getMetaRules;
+ list.hasMetaRules = hasMetaRules;
+ list.showDetail = showDetail;
+ list.getSubjectList = getSubjectList;
+ list.getObjectList = getObjectList;
+ list.getActionlist = getActionlist;
+ list.getShowDetailValue = getShowDetailValue;
+
+ list.showDetailValue = false;
+
+ list.subject_list = [];
+ list.object_list = [];
+ list.action_list = [];
+
+ list.edit = { modal: $modal({ template: 'html/model/edit/metarules/action/metarules-edit.tpl.html', show: false }),
+ showModal: showEditModal };
+
+ /*list.edit.modal.result.finally(function(){
+ console.log('CATCHING');
+ });*/
+
+
+ list.map = { modal: $modal({ template: 'html/model/edit/metarules/action/mapping/metarules-map.tpl.html', show: false }),
+ showModal: showMapModal };
+
+ list.unmap = { modal: $modal({ template: 'html/model/edit/metarules/action/mapping/metarules-unmap.tpl.html', show: false }),
+ showModal: showUnmapModal };
+
+ activate();
+
+ function activate(){
+
+ newMetaRulesTable();
+
+ }
+
+ /*
+ * ---- events
+ */
+ var rootListeners = {
+
+ 'event:metaRuleMapToModelSuccess': $rootScope.$on('event:metaRuleMapToModelSuccess', updateModelFromMapSuccess),
+
+ 'event:metaRuleUnMappedToModelSuccess': $rootScope.$on('event:metaRuleUnMappedToModelSuccess', modelUnmappedSuccess),
+ 'event:metaRuleUnMappedToModelError': $rootScope.$on('event:metaRuleUnMappedToModelError', modelUnmappedError),
+
+
+ };
+
+ for (var unbind in rootListeners) {
+ $scope.$on('$destroy', rootListeners[unbind]);
+ }
+
+
+
+ function newMetaRulesTable() {
+
+ list.table = new NgTableParams({
+
+ page: 1, // show first page
+ count: 10, // count per page
+ sorting: {
+ name: 'asc' // initial sorting
+ }
+
+ }, {
+
+ total: function () { return list.getMetaRules().length; }, // length of data
+ getData: function($defer, params) {
+
+ var orderedData = params.sorting() ? $filter('orderBy')(list.getMetaRules(), params.orderBy()) : list.getMetaRules();
+ $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
+
+ },
+ $scope: { $data: {} }
+
+ });
+
+ return list.table;
+
+ }
+
+ /**
+ * If the directive is not in editMode and displaying MetaData Content, if the editMode change to true, MetaData Content need to be hidden
+ */
+ $scope.$watch('list.editMode', function(newValue, oldValue){
+ list.showDetailValue = false;
+ });
+
+ function getMetaRules() {
+ return (list.metaRules) ? list.metaRules : [];
+ }
+
+ function hasMetaRules() {
+ return list.getMetaRules().length > 0;
+ }
+
+ function showDetail(aMetaRule){
+
+ if(aMetaRule.id === getShowDetailValue().id){
+
+ list.showDetailValue = false;
+ list.subject_list = [];
+ list.object_list = [];
+ list.action_list = [];
+
+ }else{
+
+ list.subject_list = aMetaRule.subject_categories_values;
+ list.object_list = aMetaRule.object_categories_values;
+ list.action_list = aMetaRule.action_categories_values;
+ list.showDetailValue = aMetaRule;
+
+ }
+
+ }
+
+ function showEditModal(aMetaRule) {
+ list.edit.modal.$scope.metaRule = aMetaRule;
+ list.edit.modal.$promise.then(list.edit.modal.show);
+ }
+
+ function getShowDetailValue(){
+ return list.showDetailValue;
+ }
+
+ function getSubjectList(){
+ return list.subject_list;
+ }
+
+ function getObjectList(){
+ return list.object_list;
+ }
+
+ function getActionlist(){
+ return list.action_list;
+ }
+
+ /*
+ * ---- add
+ */
+ function showMapModal() {
+ list.map.modal.$scope.model = list.model;
+ list.map.modal.$promise.then(list.map.modal.show);
+ }
+
+ function refreshRules(){
+
+ list.metaRules = list.model.meta_rules_values;
+ list.table.total(list.getMetaRules().length);
+ list.table.reload();
+
+ }
+
+ function updateModelFromMapSuccess(event, model){
+
+ list.model = model;
+
+ refreshRules();
+
+ list.map.modal.hide();
+
+ }
+
+ /*
+ * ---- unmap
+ */
+
+ function showUnmapModal(metaRule) {
+
+ list.unmap.modal.$scope.model = list.model;
+ list.unmap.modal.$scope.metaRule = metaRule;
+ list.unmap.modal.$promise.then(list.unmap.modal.show);
+
+ }
+
+ function modelUnmappedSuccess(event, model) {
+
+ list.model = model;
+
+ metaRuleService.findSomeWithCallback(list.model.meta_rules, function(meta_rules){
+
+ list.model.meta_rules_values = meta_rules;
+ refreshRules();
+ list.unmap.modal.hide();
+
+ });
+
+ }
+
+ function modelUnmappedError(event) {
+ list.unmap.modal.hide();
+ }
+
+ }
+
+})();
diff --git a/old/moon_gui/static/app/model/edit/model-edit-basic.tpl.html b/old/moon_gui/static/app/model/edit/model-edit-basic.tpl.html
new file mode 100755
index 00000000..bd73b4ef
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/model-edit-basic.tpl.html
@@ -0,0 +1,65 @@
+<div class="row">
+
+ <form class="form-horizontal" role="form" name="edit.form">
+
+ <div class="form-group">
+
+ <label for="id" class="col-sm-3 control-label" data-translate="moon.model.edit.basic.form.id">Id</label>
+
+ <div class="col-sm-6">
+
+ <input name="id" id="id" disabled class="form-control" type="text" data-ng-model="edit.modelToEdit.id" required />
+
+ </div>
+
+ </div>
+
+ <div class="form-group" ng-class="{'has-error': edit.form.name.$invalid && edit.form.name.$dirty}">
+
+ <label for="name" class="col-sm-3 control-label" data-translate="moon.model.edit.basic.form.name">Name</label>
+
+ <div class="col-sm-6">
+
+ <input name="name" id="name" class="form-control" type="text" data-ng-model="edit.modelToEdit.name" required />
+
+ <div class="help-block" ng-show="edit.form.name.$dirty && edit.form.name.$invalid">
+ <small class="error" ng-show="edit.form.name.$error.required" data-translate="moon.model.edit.basic.check.name.required">Name is required</small>
+ </div>
+
+ </div>
+
+ </div>
+
+ <div class="form-group">
+
+ <label for="description" class="col-sm-3 control-label" data-translate="moon.model.edit.basic.form.description">Description</label>
+ <div class="col-sm-6">
+ <textarea id="description" name="description" class="form-control" data-ng-model="edit.modelToEdit.description"></textarea>
+ </div>
+
+ </div>
+
+ <div class="form-group">
+
+ <div class="col-sm-2 col-sm-offset-3">
+
+ <a href="" ng-disabled="edit.loading" ng-click="edit.init()" class="btn btn-default">
+ <span data-translate="moon.model.edit.basic.action.init">Init</span>
+ </a>
+ </div>
+
+ <div class="col-sm-4 col-sm-offset-2">
+
+ <a href="" ng-disabled="edit.loading" ng-click="edit.editModel()" class="btn btn-warning">
+ <span class="glyphicon glyphicon-save"></span>
+ <span data-translate="moon.model.edit.basic.action.update">Update</span>
+ </a>
+
+ <moon-loader ng-if="edit.loading"></moon-loader>
+ </div>
+
+ </div>
+
+ </form>
+
+</div> \ No newline at end of file
diff --git a/old/moon_gui/static/app/model/edit/model-edit.tpl.html b/old/moon_gui/static/app/model/edit/model-edit.tpl.html
new file mode 100755
index 00000000..4955f441
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/model-edit.tpl.html
@@ -0,0 +1,70 @@
+<div class="container">
+
+ <div class="row">
+ <h3 class="pull-left" data-translate="moon.model.edit.title" data-translate-values="{ modelName: edit.model.name }">Edit</h3>
+ </div>
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <span data-translate="moon.model.edit.basic.title" >Basic Information</span>
+ <a href="" ng-click="edit.editBasic = !edit.editBasic">
+ <span data-translate="moon.model.edit.update">Update</span>
+ <span class="glyphicon glyphicon-cog"></span>
+ </a>
+
+ </div>
+
+ <div class="panel-body">
+
+ <div ng-if="edit.editBasic">
+ <moon-model-edit-basic model="edit.model"></moon-model-edit-basic>
+ </div>
+
+ <div ng-if="!edit.editBasic">
+ <dl class="dl-horizontal">
+
+ <dt data-translate="moon.model.edit.basic.form.id">Id</dt>
+ <dd ng-bind="edit.model.id"></dd>
+
+ <dt data-translate="moon.model.edit.basic.form.name">Name</dt>
+ <dd ng-bind="edit.model.name"></dd>
+
+ <dt data-translate="moon.model.edit.basic.form.description">Description</dt>
+ <dd ng-bind="edit.model.description"></dd>
+
+ </dl>
+ </div>
+ </div>
+
+ </div>
+
+ <div class="panel panel-default">
+
+ <div class="panel-heading">
+
+ <span data-translate="moon.model.edit.metarules.title" >Meta Rule</span>
+ <!--<a href="" ng-click="edit.editMetaRules = !edit.editMetaRules">
+ <span data-translate="moon.model.edit.update">Update</span>
+ <span class="glyphicon glyphicon-cog"></span>
+ </a>-->
+
+ </div>
+
+ <div class="panel-body" ng-if="edit.model.meta_rules_values">
+ <div class="">
+
+ <moon-meta-rules-list mapped-model="edit.model" edit-mode="edit.editMetaRules"></moon-meta-rules-list>
+
+ </div>
+ </div>
+
+ <div class="panel-body" ng-if="!edit.model.meta_rules_values">
+ <moon-loader></moon-loader>
+ </div>
+
+ </div>
+
+
+</div>
diff --git a/old/moon_gui/static/app/model/edit/model.controller.edit.js b/old/moon_gui/static/app/model/edit/model.controller.edit.js
new file mode 100755
index 00000000..3e10a533
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/model.controller.edit.js
@@ -0,0 +1,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;
+
+ });
+
+ }
+
+ }
+
+})();
diff --git a/old/moon_gui/static/app/model/edit/model.edit.basic.dir.js b/old/moon_gui/static/app/model/edit/model.edit.basic.dir.js
new file mode 100755
index 00000000..54bb7071
--- /dev/null
+++ b/old/moon_gui/static/app/model/edit/model.edit.basic.dir.js
@@ -0,0 +1,97 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('moon')
+ .directive('moonModelEditBasic', moonModelEditBasic);
+
+ moonModelEditBasic.$inject = [];
+
+ function moonModelEditBasic() {
+
+ return {
+ templateUrl : 'html/model/edit/model-edit-basic.tpl.html',
+ bindToController : true,
+ controller : moonModelEditBasicController,
+ controllerAs : 'edit',
+ scope : {
+ model : '='
+ },
+ restrict : 'E',
+ replace : true
+ };
+ }
+
+ angular
+ .module('moon')
+ .controller('moonModelEditBasicController', moonModelEditBasicController);
+
+ moonModelEditBasicController.$inject = ['$scope', 'modelService', 'formService', 'alertService', '$translate', 'utilService'];
+
+ function moonModelEditBasicController($scope, modelService, formService, alertService, $translate, utilService){
+
+ var edit = this;
+
+ edit.editModel = editModel;
+ edit.init = init;
+
+ edit.form = {};
+
+ activate();
+
+ function activate(){
+
+ edit.model = $scope.edit.model;
+
+ edit.modelToEdit = angular.copy(edit.model);
+
+ }
+
+ function editModel(){
+
+ if(formService.isInvalid(edit.form)) {
+
+ formService.checkFieldsValidity(edit.form);
+
+ }else{
+
+ edit.loading = true;
+
+ modelService.update(edit.modelToEdit, updateSuccess, updateError);
+
+ }
+
+ function updateSuccess(data) {
+
+ var updatedModel = utilService.transformOne(data, 'models');
+
+ $translate('moon.model.edit.basic.success', { modelName: updatedModel.name }).then( function(translatedValue) {
+ alertService.alertSuccess(translatedValue);
+ });
+
+ edit.loading = false;
+
+ $scope.$emit('event:modelUpdatedSuccess', updatedModel);
+
+ }
+
+ function updateError(reason) {
+
+ $translate('moon.model.edit.basic.error', { modelName: edit.model.name }).then( function(translatedValue) {
+ alertService.alertError(translatedValue);
+ });
+
+ edit.loading = false;
+
+ }
+ }
+
+ function init(){
+
+ edit.modelToEdit = angular.copy(edit.model);
+
+ }
+ }
+
+})();