aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models
diff options
context:
space:
mode:
authorguangxingwang <gw1218@att.com>2018-02-07 15:07:27 -0600
committerguangxingwang <gw1218@att.com>2018-02-07 15:08:05 -0600
commit4ec7cf25fc91f14e8ed80daa43792e3ab69f91f5 (patch)
tree7aa03ba406326d55bdb3efaeeb863792277b96cd /POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models
parent6a44b2926f33b427904c2f3e7962d0dfc360c482 (diff)
FFix the Bug of Missing fields on View Screen
Missing extra fields added by clicking add buton if they are more than 10 on view screen Issue-ID: POLICY-613 Change-Id: I9e718b62301f24b71a4f6506d3e63e6185e0b1ce Signed-off-by: guangxingwang <gw1218@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models')
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js65
1 files changed, 47 insertions, 18 deletions
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
index 2b3b743d4..6f316c1e3 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -223,7 +223,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
for(var i=0; i<inputs.length; i++){
if ($scope.temp.policy.ruleData!=undefined){
var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
- if (checkValue!=undefined){
+ if (checkValue!=undefined && checkValue != "undefined"){
if($scope.temp.policy.ruleData != null){
var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
document.getElementById(inputs[i].id).value = $scope.temp.policy.ruleData[inputs[i].id];
@@ -241,7 +241,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
for(var i=0; i<selects.length; i++){
if ($scope.temp.policy.ruleData!=undefined){
var checkValue = $scope.temp.policy.ruleData[selects[i].id];
- if (checkValue!=undefined){
+ if (checkValue!=undefined && checkValue!="undefined"){
if($scope.temp.policy.ruleData != null){
var checkValue = $scope.temp.policy.ruleData[selects[i].id];
document.getElementById(selects[i].id).value = $scope.temp.policy.ruleData[selects[i].id];
@@ -412,19 +412,25 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
//--- Populate these extra elements created by clicked add button
- for(a = 0; a < extraElements.length; a++){
- if(extraElements[a].includes("@")){
- var n = extraElements[a].lastIndexOf("@");
- if(n > 0){
- var key = extraElements[a].substring(0, n+2); //include @x in key also by n+2 since x can be 1, or 2, or 3
- checkData.push(key);
- }
- }
- }
+ for(a = 0; a < extraElements.length; a++){
+ if(extraElements[a].includes("@")){
+ var index = extraElements[a].lastIndexOf("@");
+ if(index > 0){
+ // Get the number after @
+ var n = getNumOfDigits(extraElements[a], index+1);
+
+ var key = extraElements[a].substring(0, index+n+1); //include @x in key also by n+2 since x can be 1,12, etc
+ console.log("key: " + key);
+ checkData.push(key);
+ }
+ }
+ }
var unique = checkData.filter(onlyUnique);
for(i =0; i < unique.length; i++){
//remove @x and let addNewChoice add @1 or @2...
- var newKey = unique[i].substring(0, unique[i].length-2);
+ //var newKey = unique[i].substring(0, unique[i].length-2);
+ var index = unique[i].lastIndexOf("@");
+ var newKey = unique[i].substring(0, index);
console.log("newKey: " + newKey);
$scope.addNewChoice(newKey);
}
@@ -444,6 +450,22 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
};
+ function getNumOfDigits(str_value, index){
+ // Get the number after @
+ var str = str_value.substring(index, str_value.length);
+ var c = '';
+ var n = 0;
+ for (var x = 0; x < str.length; x++){
+ c = str.charAt(x);
+ if(!isNaN(c)){
+ n++;
+ }else{
+ break;
+ }
+ }
+ return n;
+ }
+
function getDictionary(attribute){
var dicName = attribute;
if(attribute){
@@ -738,16 +760,22 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
defaultValue = "";
}
}
- document.getElementById(checkKey).value = defaultValue;
+ if(defaultValue != "undefined" && defaultValue != undefined){
+ document.getElementById(checkKey).value = defaultValue;
+ }
}
if($scope.temp.policy.ruleData != null){
//document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
if (attributeManyKey){
var newCheckKey = checkKey.replace(attibuteKey + '@0',attibuteKey);
- document.getElementById(newCheckKey +'@0').value = $scope.temp.policy.ruleData[newCheckKey +'@0'];
+ if($scope.temp.policy.ruleData[newCheckKey +'@0'] != undefined && $scope.temp.policy.ruleData[newCheckKey +'@0'] != "undefined"){
+ document.getElementById(newCheckKey +'@0').value = $scope.temp.policy.ruleData[newCheckKey +'@0'];
+ }
}else{
- document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
+ if($scope.temp.policy.ruleData[checkKey] != undefined && $scope.temp.policy.ruleData[checkKey] != "undefined"){
+ document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
+ }
}
}
plainAttributeKeys.push(labelValue + attibuteKey+'*'+attributeManyKey);
@@ -900,8 +928,9 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
}
}else {
- document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName];
-
+ if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){
+ document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName];
+ }
}
}
};