From e7f9dc1a0accba89dacff0f836047704f0f0ccc5 Mon Sep 17 00:00:00 2001 From: KIRAN KASHALKAR Date: Mon, 27 Mar 2017 19:59:37 -0400 Subject: [PATCH] RIFT-15931, RIFT-15945: Leafref for rsp and internal-interface restored Signed-off-by: KIRAN KASHALKAR --- .../composer/src/src/libraries/utils.js | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/skyquake/plugins/composer/src/src/libraries/utils.js b/skyquake/plugins/composer/src/src/libraries/utils.js index ef37a0bdc..b0fcfc6eb 100644 --- a/skyquake/plugins/composer/src/src/libraries/utils.js +++ b/skyquake/plugins/composer/src/src/libraries/utils.js @@ -327,13 +327,21 @@ export default { } else if (fieldKeyArray.length == 2) { for (let key in catalogs) { for (let subKey in catalogs[key]) { - let found = _find(catalogs[key][subKey], {id: fieldKeyArray[0]}); + console.log(key, subKey); + var found = _find(catalogs[key][subKey], {id: fieldKeyArray[0]}); if (found) { for (let foundKey in found) { - // let topLevel = _find(found[foundKey], {id: fieldKeyArray[1]}); - if (foundKey == fieldKeyArray[1]) { - results = this.getAbsoluteResults(found[foundKey], pathArray.splice(-i, i)); - return results; + if (_isArray(found[foundKey])) { + let topLevel = _find(found[foundKey], {id: fieldKeyArray[1]}); + if (topLevel) { + results = this.getAbsoluteResults(topLevel, pathArray.splice(-i, i)); + return results; + } + } else { + if (foundKey == fieldKeyArray[1]) { + results = this.getAbsoluteResults(found[foundKey], pathArray.splice(-i, i)); + return results; + } } } } @@ -342,13 +350,20 @@ export default { } else if (fieldKeyArray.length == 3) { for (let key in catalogs) { for (let subKey in catalogs[key]) { - let found = _.find(catalogs[key][subKey], {id: fieldKeyArray[0]}); + let found = _find(catalogs[key][subKey], {id: fieldKeyArray[0]}); if (found) { for (let foundKey in found) { - let topLevel = _.find(found[foundKey], {id: fieldKeyArray[1]}); - if (topLevel) { - results = this.getAbsoluteResults(topLevel, pathArray.splice(-i, i)); - return results; + if (_isArray(found[foundKey])) { + let topLevel = _find(found[foundKey], {id: fieldKeyArray[1]}); + if (topLevel) { + results = this.getAbsoluteResults(topLevel, pathArray.splice(-i, i)); + return results; + } + } else { + if (foundKey == fieldKeyArray[1]) { + results = this.getAbsoluteResults(found[foundKey], pathArray.splice(-i, i)); + return results; + } } } } -- 2.17.1