RIFT-15222: Several relative leafref paths need to be fixed to include reference... 73/1073/1
authorKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Tue, 7 Feb 2017 06:26:19 +0000 (01:26 -0500)
committerKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Tue, 7 Feb 2017 06:26:19 +0000 (01:26 -0500)
Signed-off-by: KIRAN KASHALKAR <kiran.kashalkar@riftio.com>
skyquake/plugins/composer/src/src/libraries/utils.js

index 1d54a6f..ee4163c 100644 (file)
@@ -212,9 +212,27 @@ export default {
                                                let key = fragment.split('[')[0];
                                                let searchObject = {};
                                                searchObject[predicateKey] = predicateValue;
-                                               objectCopy = _.find(objectCopy[key], searchObject);
-                                               if (!objectCopy) {
-                                                       return [];
+                                               let found = _.find(objectCopy[key], searchObject);
+                                               if (found) {
+                                                       objectCopy = found;
+                                               } else {
+                                                       // check for numerical value
+                                                       if (predicateValue != "" &&
+                                                               predicateValue != null &&
+                                                               predicateValue != NaN &&
+                                                               predicateValue != Infinity &&
+                                                               predicateValue != -Infinity) {
+                                                               let numericalPredicateValue = _.toNumber(predicateValue);
+                                                               if (_.isNumber(numericalPredicateValue)) {
+                                                                       searchObject[predicateKey] = numericalPredicateValue;
+                                                                       found = _.find(objectCopy[key], searchObject);
+                                                               }
+                                                       }
+                                                       if (found) {
+                                                               objectCopy = found;
+                                                       } else {
+                                                               return [];
+                                                       }
                                                }
                                        } else {
                                                // contains no predicate