Fix to ensure runtimeTime binding is used is automation js modal

This commit is contained in:
Dean 2024-03-25 12:36:56 +00:00
parent 6bd6ee779b
commit 9b4c22727f
2 changed files with 14 additions and 4 deletions

View File

@ -31,7 +31,7 @@
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte" import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
import CodeEditor from "components/common/CodeEditor/CodeEditor.svelte" import CodeEditor from "components/common/CodeEditor/CodeEditor.svelte"
import BindingSidePanel from "components/common/bindings/BindingSidePanel.svelte" import BindingSidePanel from "components/common/bindings/BindingSidePanel.svelte"
import { BindingHelpers } from "components/common/bindings/utils" import { BindingHelpers, BindingType } from "components/common/bindings/utils"
import { import {
bindingsToCompletions, bindingsToCompletions,
hbAutocomplete, hbAutocomplete,
@ -576,6 +576,7 @@
{ {
js: true, js: true,
dontDecode: true, dontDecode: true,
type: BindingType.RUNTIME,
} }
)} )}
mode="javascript" mode="javascript"

View File

@ -1,6 +1,11 @@
import { decodeJSBinding } from "@budibase/string-templates" import { decodeJSBinding } from "@budibase/string-templates"
import { hbInsert, jsInsert } from "components/common/CodeEditor" import { hbInsert, jsInsert } from "components/common/CodeEditor"
export const BindingType = {
READABLE: "readableBinding",
RUNTIME: "runtimeBinding",
}
export class BindingHelpers { export class BindingHelpers {
constructor(getCaretPosition, insertAtPos, { disableWrapping } = {}) { constructor(getCaretPosition, insertAtPos, { disableWrapping } = {}) {
this.getCaretPosition = getCaretPosition this.getCaretPosition = getCaretPosition
@ -25,16 +30,20 @@ export class BindingHelpers {
} }
// Adds a data binding to the expression // Adds a data binding to the expression
onSelectBinding(value, binding, { js, dontDecode }) { onSelectBinding(
value,
binding,
{ js, dontDecode, type = BindingType.READABLE }
) {
const { start, end } = this.getCaretPosition() const { start, end } = this.getCaretPosition()
if (js) { if (js) {
const jsVal = dontDecode ? value : decodeJSBinding(value) const jsVal = dontDecode ? value : decodeJSBinding(value)
const insertVal = jsInsert(jsVal, start, end, binding.readableBinding, { const insertVal = jsInsert(jsVal, start, end, binding[type], {
disableWrapping: this.disableWrapping, disableWrapping: this.disableWrapping,
}) })
this.insertAtPos({ start, end, value: insertVal }) this.insertAtPos({ start, end, value: insertVal })
} else { } else {
const insertVal = hbInsert(value, start, end, binding.readableBinding) const insertVal = hbInsert(value, start, end, binding[type])
this.insertAtPos({ start, end, value: insertVal }) this.insertAtPos({ start, end, value: insertVal })
} }
} }