- if($scope.temp.policy.ruleData != null){
- var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData);
- propNames.forEach(function(name) {
- data.push(name);
- });
- for(a = 0; a < data.length; a++){
- var splitPlainAttributeKey1 = data[a].split(".");
- if(splitPlainAttributeKey1[0].indexOf("@") != -1){
- var key = splitPlainAttributeKey1[0];
- checkData.push(key);
- }
- }
- var unique = checkData.filter(onlyUnique);
- for(i =0; i < unique.length; i++){
- if(unique[i].indexOf("@0") == -1){
- var finalkey = unique[i].split("@")[0];
- $scope.addNewChoice(finalkey);
- }
- }
- }
+ if($scope.temp.policy.ruleData != null){
+ var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData);
+ propNames.forEach(function(name) {
+ data.push(name);
+ });
+
+ var extraElements = data;
+
+ if(plainAttributeKeys != null){
+ for(b = 0; b < plainAttributeKeys.length; b++){ // remove already populated elements from extraElements array
+ var newValue = plainAttributeKeys[b].split("*");
+ for(a = 0; a < data.length; a++){
+ if(data[a] === newValue[0]){
+ extraElements.splice(a, 1);
+ }
+ }
+ }
+
+ //--- populate these extral elements generated from clicking add button
+ for(a = 0; a < extraElements.length; a++){
+ if(extraElements[a].includes("@")){
+ var n = extraElements[a].lastIndexOf("@");
+ 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);
+ }
+ }
+ 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);
+ $scope.addNewChoice(newKey);
+ }
+ }
+ }
+