Merge branch 'master' into wrap-field-labels
This commit is contained in:
commit
214499d809
|
@ -11,6 +11,7 @@
|
||||||
import {
|
import {
|
||||||
decodeJSBinding,
|
decodeJSBinding,
|
||||||
encodeJSBinding,
|
encodeJSBinding,
|
||||||
|
processObjectSync,
|
||||||
processStringSync,
|
processStringSync,
|
||||||
} from "@budibase/string-templates"
|
} from "@budibase/string-templates"
|
||||||
import { readableToRuntimeBinding } from "dataBinding"
|
import { readableToRuntimeBinding } from "dataBinding"
|
||||||
|
@ -153,13 +154,6 @@
|
||||||
debouncedEval(expression, context, snippets)
|
debouncedEval(expression, context, snippets)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getBindingValue = (binding, context, snippets) => {
|
|
||||||
const js = `return $("${binding.runtimeBinding}")`
|
|
||||||
const hbs = encodeJSBinding(js)
|
|
||||||
const res = processStringSync(hbs, { ...context, snippets })
|
|
||||||
return JSON.stringify(res, null, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
const highlightJSON = json => {
|
const highlightJSON = json => {
|
||||||
return formatHighlight(json, {
|
return formatHighlight(json, {
|
||||||
keyColor: "#e06c75",
|
keyColor: "#e06c75",
|
||||||
|
@ -172,11 +166,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const enrichBindings = (bindings, context, snippets) => {
|
const enrichBindings = (bindings, context, snippets) => {
|
||||||
return bindings.map(binding => {
|
// Create a single big array to enrich in one go
|
||||||
|
const bindingStrings = bindings.map(binding => {
|
||||||
|
if (binding.runtimeBinding.startsWith('trim "')) {
|
||||||
|
// Account for nasty hardcoded HBS bindings for roles, for legacy
|
||||||
|
// compatibility
|
||||||
|
return `{{ ${binding.runtimeBinding} }}`
|
||||||
|
} else {
|
||||||
|
return `{{ literal ${binding.runtimeBinding} }}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const bindingEvauations = processObjectSync(bindingStrings, {
|
||||||
|
...context,
|
||||||
|
snippets,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Enrich bindings with evaluations and highlighted HTML
|
||||||
|
return bindings.map((binding, idx) => {
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return binding
|
return binding
|
||||||
}
|
}
|
||||||
const value = getBindingValue(binding, context, snippets)
|
const value = JSON.stringify(bindingEvauations[idx], null, 2)
|
||||||
return {
|
return {
|
||||||
...binding,
|
...binding,
|
||||||
value,
|
value,
|
||||||
|
|
|
@ -75,13 +75,6 @@
|
||||||
if (!context || !binding.value || binding.value === "") {
|
if (!context || !binding.value || binding.value === "") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Roles have always been broken for JS. We need to exclude them from
|
|
||||||
// showing a popover as it will show "Error while executing JS".
|
|
||||||
if (binding.category === "Role") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
stopHidingPopover()
|
stopHidingPopover()
|
||||||
popoverAnchor = target
|
popoverAnchor = target
|
||||||
hoverTarget = {
|
hoverTarget = {
|
||||||
|
|
Loading…
Reference in New Issue