From 7bb53c64da2dcf88894bfd31503accdd81498f3d Mon Sep 17 00:00:00 2001 From: Thomas Duval Date: Wed, 3 Jun 2020 10:06:52 +0200 Subject: Update to new version 5.4 Signed-off-by: Thomas Duval Change-Id: Idcd868133d75928a1ffd74d749ce98503e0555ea --- .../metarules/action/metarules.edit.basic.dir.js | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 old/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js (limited to 'old/moon_gui/static/app/model/edit/metarules/action/metarules.edit.basic.dir.js') 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); + + } + } + +})(); -- cgit 1.2.3-korg