diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b987af..6dabbb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ This log documents significant changes for each release. This project follows [Semantic Versioning](http://semver.org/). +## [0.12.2] - 2019-05-15 +### Fixed +- Corrected output in the demo website for results containing dates and times. +- Cleaned up the error message output for parsing errors. + ## [0.12.1] - 2019-05-13 ### Fixed - Updated links to the repository to point to the new location. diff --git a/demo/public/app.css b/demo/public/app.css index 26b6cf1..71a021d 100644 --- a/demo/public/app.css +++ b/demo/public/app.css @@ -23,8 +23,10 @@ body { display: flex; flex-direction: row; } -#input { +#inputWrapper { flex: 1; +} +#input { margin-top: 3px; } diff --git a/demo/public/app.js b/demo/public/app.js index 1eb01d2..2165075 100644 --- a/demo/public/app.js +++ b/demo/public/app.js @@ -29,13 +29,24 @@ function evaluate(){ try { var inputType = document.querySelector('input[name="inputType"]:checked').value var inputText = cm.getValue(); - var res = inputType === 'yaml' ? yaml.safeLoad(inputText) : JSON.parse(inputText); - console.log(pathNode.value, res); - var result = fhirpath.evaluate(res, pathNode.value); - outNode.innerHTML = '
'; - outNode.childNodes.item(0).textContent = yaml.dump(result); + var expr = pathNode.value; + if (expr.trim() != '') { + var res = inputType === 'yaml' ? yaml.safeLoad(inputText) : JSON.parse(inputText); + console.log(pathNode.value, res); + var result = fhirpath.evaluate(res, expr); + outNode.innerHTML = ''; + // yaml.dump will pick up internal keys, e.g. "asStr" in the FP_Type + // objects (dates and times). Apparently, toString() is not called on the + // objects during yaml.dump, so we take care of that by calling toJSON + // first, parsing that, and then creating the yaml output. + outNode.childNodes.item(0).textContent = + yaml.dump(JSON.parse(JSON.stringify(result))); + } } catch (e) { - outNode.innerHTML = ''; + + outNode.innerHTML = ''; + var msg = e.toString(); + msg.replace(/\n/, '