Remove SDC query
[clamp.git] / src / main / resources / META-INF / resources / designer / scripts / GlobalPropertiesCtrl.js
index 1652c48..21572a5 100644 (file)
@@ -31,19 +31,19 @@ app.controller('GlobalPropertiesCtrl', [
 function($scope, $rootScope, $uibModalInstance, cldsModelService, $location,
          dialogs, cldsTemplateService) {
        $scope.$watch('name', function(newValue, oldValue) {
-               var services = asdc_Services
+
                setASDCFields()
-               // add blank service item as the default service, to force user chose
-               // the correct service by themselves
-               $("#service").append("<option></option>")
-               for (k in services) {
-                       $("#service").append(
-                       "<option value=" + k + ">" + services[k] + "</option>")
-               }
+
                var el = elementMap["global"];
                if (el !== undefined) {
                        for (var i = 0; i < el.length; i++) {
-                               $("#" + el[i].name).val(el[i].value);
+                               if (el[i].name === 'deployParameters')
+                               {
+                                       // This is a special case, that value is not a string but a JSON
+                                       $("#" + el[i].name).val(JSON.stringify(el[i].value));
+                               } else {
+                                       $("#" + el[i].name).val(el[i].value);
+                               }
                        }
                }
                setMultiSelect();
@@ -66,4 +66,56 @@ function($scope, $rootScope, $uibModalInstance, cldsModelService, $location,
                console.log("close");
                $uibModalInstance.close("closed");
        };
+    $scope.convertDeployParametersJsonToString = function() {
+        var index = elementMap["global"].findIndex(function(e) {
+               return (typeof e == "object" && !(e instanceof Array))
+               && "deployParameters" == e["name"];
+        });
+        if (index != -1) {
+               $('#deployParameters').val(JSON.stringify(elementMap["global"][index].value));
+        }
+    }
+    
+    function noRepeats(form) {
+        var select = {};
+        for (var i = 0; i < form.length; i++) {
+               if (form[i].hasOwnProperty("name")) {
+                       if (form[i].name === 'deployParameters') {
+                                       // This is a special case, that value MUST not be a string but a JSON
+                               select[form[i].name]=JSON.parse(form[i].value);
+                       } else {
+                               if (select[form[i].name] === undefined)
+                                       select[form[i].name] = []
+                               select[form[i].name].push(form[i].value);
+                       }
+               }
+        }
+        var arr = []
+        for (s in select) {
+               var f = {}
+               f.name = s
+               f.value = select[s]
+               if (!(s == "service" && f.value == "")) {
+                       arr.push(f)
+               }
+        }
+        return arr
+    }
+    
+    $scope.submitForm = function() {
+        saveGlobalProperties(noRepeats($("#saveProps").serializeArray()))
+        //module reset, based on property updates
+        if (elementMap["global"]) {
+               $.each(Object.keys(elementMap), function(i, v) {
+                       if ((v.match(/^Policy/)) && asDiff) {
+                               elementMap[v] = {};
+                       }
+                       if ((v.match(/^TCA/)) && (vfDiff || serDiff)) {
+                               elementMap[v] = {};
+                       }
+               });
+        }
+        $uibModalInstance.close();
+    }
+  
 } ]);