1
0
Fork 0
mirror of synced 2024-06-30 20:10:54 +12:00

Merge pull request #13346 from Budibase/fix/automation-step-js-bindings

Fix to ensure runtimeTime binding is used is automation js modal
This commit is contained in:
deanhannigan 2024-04-02 09:23:22 +01:00 committed by GitHub
commit 5ba59adda7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View file

@ -31,7 +31,7 @@
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
import CodeEditor from "components/common/CodeEditor/CodeEditor.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 {
bindingsToCompletions,
hbAutocomplete,
@ -576,6 +576,7 @@
{
js: true,
dontDecode: true,
type: BindingType.RUNTIME,
}
)}
mode="javascript"

View file

@ -1,6 +1,11 @@
import { decodeJSBinding } from "@budibase/string-templates"
import { hbInsert, jsInsert } from "components/common/CodeEditor"
export const BindingType = {
READABLE: "readableBinding",
RUNTIME: "runtimeBinding",
}
export class BindingHelpers {
constructor(getCaretPosition, insertAtPos, { disableWrapping } = {}) {
this.getCaretPosition = getCaretPosition
@ -25,16 +30,20 @@ export class BindingHelpers {
}
// 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()
if (js) {
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,
})
this.insertAtPos({ start, end, value: insertVal })
} else {
const insertVal = hbInsert(value, start, end, binding.readableBinding)
const insertVal = hbInsert(value, start, end, binding[type])
this.insertAtPos({ start, end, value: insertVal })
}
}