From: KIRAN KASHALKAR Date: Tue, 7 Feb 2017 06:26:19 +0000 (-0500) Subject: RIFT-15222: Several relative leafref paths need to be fixed to include reference... X-Git-Tag: v1.1.0~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=37c9d56c7c9460074e582c639c6277d661797018;p=osm%2FUI.git RIFT-15222: Several relative leafref paths need to be fixed to include reference to current node Signed-off-by: KIRAN KASHALKAR --- diff --git a/skyquake/plugins/composer/src/src/libraries/utils.js b/skyquake/plugins/composer/src/src/libraries/utils.js index 1d54a6f5b..ee4163cd2 100644 --- a/skyquake/plugins/composer/src/src/libraries/utils.js +++ b/skyquake/plugins/composer/src/src/libraries/utils.js @@ -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