Controlling JSON syntax at UI Objects properties

This commit is contained in:
Luis Fernando Molina committed 2019-11-30 10:09:30 +01:00
1 parent c2d0876806
commit c80c31e7bb
2 files changed
+11 -2

No files matched your search

+8
View File
@@ -71,6 +71,13 @@ function newCodeEditor () {
let textArea = document.getElementById('textArea')
textArea.style.display = 'none'
thisObject.payload.node.code = textArea.value
if (thisObject.payload.node.type !== 'Code' && thisObject.payload.node.type !== 'Formula') {
try {
let code = JSON.parse(thisObject.payload.node.code)
} catch (err) {
thisObject.payload.uiObject.setErrorMessage(err.message, 10)
}
}
}
}
@@ -80,6 +87,7 @@ function newCodeEditor () {
thisObject.rawRadius = 8
thisObject.targetRadius = thisObject.container.frame.radius
thisObject.currentRadius = 0
thisObject.payload.uiObject.setErrorMessage('', 0)
let textArea = document.getElementById('textArea')
textArea.value = payload.node.code
+3 -2
View File
@@ -835,11 +835,12 @@ function newUiObject () {
highlightCounter = 30
}
function setErrorMessage (message) {
function setErrorMessage (message, duration) {
if (message !== undefined) {
errorMessage = message
hasError = true
errorMessageCounter = 100
if (duration === undefined) { duration = 1 }
errorMessageCounter = 100 * duration
}
}