Merge branch 'v1.1'
authorKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Mon, 13 Feb 2017 15:43:22 +0000 (10:43 -0500)
committerKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Mon, 13 Feb 2017 15:43:22 +0000 (10:43 -0500)
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