From 8580a3916b7d862e3d3dad1c79176b2842c25f81 Mon Sep 17 00:00:00 2001 From: ibevers Date: Thu, 15 Aug 2024 11:12:55 -0400 Subject: [PATCH 1/2] Fix first element issue in isVis checks --- src/components/Section/Section.vue | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/Section/Section.vue b/src/components/Section/Section.vue index a76c36f..f187a47 100644 --- a/src/components/Section/Section.vue +++ b/src/components/Section/Section.vue @@ -146,7 +146,7 @@ export default { visibilityMapper[responseMapper[a[`${this.reprotermsUrl}variableName`][0]['@value']].ref] = val; } }); - // console.log(142, 'in section', visibilityMapper); + //console.log(142, 'in section', visibilityMapper); return visibilityMapper; } return {}; @@ -184,24 +184,31 @@ export default { return outMapper; }, evaluateString(string, responseMapper) { - // console.log(176, string, responseMapper); - const keys = Object.keys(responseMapper); + + //console.log(176, string, responseMapper); + //const keys = Object.keys(responseMapper); let output = string; _.map(keys, (k) => { + //console.log(k, output) + // grab the value of the key from responseMapper let val = responseMapper[k].val; - if (Array.isArray(responseMapper[k].val)) { - val = responseMapper[k].val[0]; - } if (val !== 'http://schema.repronim.org/Skipped' && val !== 'http://schema.repronim.org/DontKnow') { if (_.isString(val)) { val = `'${val}'`; // put the string in quotes } + else if (_.isArray(val)) { + val = `[${val}]`; // enclose val in [] + } + else if (!val && string.includes('includes')) { // if val is undefined and is supposed to be a list + val = `[]`; + } output = output.replace(new RegExp(`\\b${k}\\b`), val); } else { output = output.replace(new RegExp(`\\b${k}\\b`), 0); } }); + //console.log(output) return Function('return ' + output)(); }, restart() { From 7a71ebaf128e795e2ff90f9e6c64089bbab9a4c4 Mon Sep 17 00:00:00 2001 From: ibevers Date: Thu, 15 Aug 2024 11:31:47 -0400 Subject: [PATCH 2/2] Uncomment accidentally commented line --- src/components/Section/Section.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Section/Section.vue b/src/components/Section/Section.vue index f187a47..e746994 100644 --- a/src/components/Section/Section.vue +++ b/src/components/Section/Section.vue @@ -186,7 +186,7 @@ export default { evaluateString(string, responseMapper) { //console.log(176, string, responseMapper); - //const keys = Object.keys(responseMapper); + const keys = Object.keys(responseMapper); let output = string; _.map(keys, (k) => { //console.log(k, output)