aboutsummaryrefslogtreecommitdiffstats
path: root/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js
diff options
context:
space:
mode:
authorWuKong <rebirthmonkey@gmail.com>2017-12-23 21:49:35 +0100
committerWuKong <rebirthmonkey@gmail.com>2017-12-23 21:49:58 +0100
commit1100c66ce03a059ebe7ece9734e799b49b3a5a9e (patch)
treea057e7e7511f6675a9327b79e6919f07c5f89f07 /moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js
parent7a4dfdde6314476ae2a1a1c881ff1e3c430f790e (diff)
moonv4 cleanup
Change-Id: Icef927f3236d985ac13ff7376f6ce6314b2b39b0 Signed-off-by: WuKong <rebirthmonkey@gmail.com>
Diffstat (limited to 'moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js')
-rwxr-xr-xmoon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js b/moon_gui/static/app/model/edit/metarules/action/mapping/metarules.unmap.controller.js
new file mode 100755
index 00000000..30f32d51
--- /dev/null
+++ b/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');
+
+ }
+
+ }
+
+ }
+
+})();