readable to writable bindings
This commit is contained in:
parent
f7383f37da
commit
23d83739b0
|
@ -142,7 +142,7 @@ export const getBackendUiStore = () => {
|
||||||
delete: async queryId => {
|
delete: async queryId => {
|
||||||
await api.delete(`/api/queries/${queryId}`)
|
await api.delete(`/api/queries/${queryId}`)
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state.datasources = state.queries.filter(
|
state.queries = state.queries.filter(
|
||||||
existing => existing._id !== queryId
|
existing => existing._id !== queryId
|
||||||
)
|
)
|
||||||
if (state.selectedQueryId === queryId) {
|
if (state.selectedQueryId === queryId) {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
import { Button, TextArea, Label, Input, Heading } from "@budibase/bbui"
|
import { Button, TextArea, Label, Input, Heading } from "@budibase/bbui"
|
||||||
import BindableInput from "components/userInterface/BindableInput.svelte"
|
import BindableInput from "components/userInterface/BindableInput.svelte"
|
||||||
|
import {
|
||||||
|
readableToRuntimeBinding,
|
||||||
|
runtimeToReadableBinding,
|
||||||
|
} from "builderStore/replaceBindings"
|
||||||
|
|
||||||
export let bindable = true
|
export let bindable = true
|
||||||
export let parameters = []
|
export let parameters = []
|
||||||
|
@ -15,6 +19,12 @@
|
||||||
parameters.splice(idx, 1)
|
parameters.splice(idx, 1)
|
||||||
parameters = parameters
|
parameters = parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onBindingChange(param, valueToParse) {
|
||||||
|
const parsedBindingValue = readableToRuntimeBinding(bindings, valueToParse)
|
||||||
|
console.log(parsedBindingValue)
|
||||||
|
customParams[param] = parsedBindingValue
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -33,7 +43,11 @@
|
||||||
<BindableInput
|
<BindableInput
|
||||||
type="string"
|
type="string"
|
||||||
thin
|
thin
|
||||||
bind:value={customParams[parameter.name]}
|
on:change={evt => {
|
||||||
|
console.log('changing', evt.detail)
|
||||||
|
onBindingChange(parameter.name, evt.detail)
|
||||||
|
}}
|
||||||
|
value={runtimeToReadableBinding(bindings, customParams[parameter.name])}
|
||||||
{bindings} />
|
{bindings} />
|
||||||
{/if}
|
{/if}
|
||||||
<i
|
<i
|
||||||
|
|
|
@ -126,6 +126,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
<Heading>{query.name}</Heading>
|
||||||
<div class="config">
|
<div class="config">
|
||||||
<Label extraSmall grey>Query Name</Label>
|
<Label extraSmall grey>Query Name</Label>
|
||||||
<Input thin bind:value={query.name} />
|
<Input thin bind:value={query.name} />
|
||||||
|
|
|
@ -16,11 +16,18 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<ParameterBuilder bind:parameters={query.parameters} bindable={false} />
|
||||||
|
<Spacer large />
|
||||||
|
|
||||||
|
<Label grey medium>Query</Label>
|
||||||
|
|
||||||
{#if query.queryType === QueryTypes.SQL}
|
{#if query.queryType === QueryTypes.SQL}
|
||||||
<ParameterBuilder bind:parameters={query.parameters} bindable={false} />
|
|
||||||
<Spacer large />
|
|
||||||
<TextArea bind:value={query.queryString} />
|
<TextArea bind:value={query.queryString} />
|
||||||
<!-- <Editor label="Query" on:change={updateQuery} value={query.queryString} /> -->
|
<!-- <Editor label="Query" on:change={updateQuery} value={query.queryString} /> -->
|
||||||
{:else if query.queryType === QueryTypes.JSON}
|
{:else if query.queryType === QueryTypes.JSON}
|
||||||
|
<!-- <ParameterBuilder bind:parameters={query.parameters} bindable={false} />
|
||||||
{:else if query.queryType === QueryTypes.FIELDS}{/if}
|
<Spacer large />
|
||||||
|
<TextArea bind:value={query.queryString} /> -->
|
||||||
|
{:else if query.queryType === QueryTypes.FIELDS}
|
||||||
|
<!-- {#each Object.keys()} -->
|
||||||
|
{/if}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
import GenericBindingPopover from "./GenericBindingPopover.svelte"
|
import GenericBindingPopover from "./GenericBindingPopover.svelte"
|
||||||
import { Input, Icon } from "@budibase/bbui"
|
import { Input, Icon } from "@budibase/bbui"
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let bindings = []
|
export let bindings = []
|
||||||
export let value
|
export let value
|
||||||
|
|
||||||
let anchor
|
let anchor
|
||||||
let popover = undefined
|
let popover = undefined
|
||||||
let enrichedValue
|
let enrichedValue
|
||||||
|
@ -14,6 +18,7 @@
|
||||||
let { bindings, ...otherProps } = $$props
|
let { bindings, ...otherProps } = $$props
|
||||||
inputProps = otherProps
|
inputProps = otherProps
|
||||||
}
|
}
|
||||||
|
$: value && dispatch("change", value)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container" bind:this={anchor}>
|
<div class="container" bind:this={anchor}>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
...property,
|
...property,
|
||||||
category: property.type === "instance" ? "Component" : "Table",
|
category: property.type === "instance" ? "Component" : "Table",
|
||||||
label: property.readableBinding,
|
label: property.readableBinding,
|
||||||
path: property.runtimeBinding,
|
path: property.readableBinding,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
function closeDatabindingDrawer() {
|
function closeDatabindingDrawer() {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
...property,
|
...property,
|
||||||
category: property.type === "instance" ? "Component" : "Table",
|
category: property.type === "instance" ? "Component" : "Table",
|
||||||
label: property.readableBinding,
|
label: property.readableBinding,
|
||||||
path: property.runtimeBinding,
|
path: property.readableBinding,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
$: query =
|
$: query =
|
||||||
|
|
|
@ -63,11 +63,9 @@
|
||||||
...property,
|
...property,
|
||||||
category: property.type === "instance" ? "Component" : "Table",
|
category: property.type === "instance" ? "Component" : "Table",
|
||||||
label: property.readableBinding,
|
label: property.readableBinding,
|
||||||
path: property.runtimeBinding,
|
path: property.readableBinding,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
$: console.log("selected", value)
|
|
||||||
|
|
||||||
$: links = bindableProperties
|
$: links = bindableProperties
|
||||||
.filter(x => x.fieldSchema?.type === "link")
|
.filter(x => x.fieldSchema?.type === "link")
|
||||||
.map(property => {
|
.map(property => {
|
||||||
|
|
|
@ -39,13 +39,12 @@ function generateQueryValidation() {
|
||||||
function generateQueryPreviewValidation() {
|
function generateQueryPreviewValidation() {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
return joiValidator.body(Joi.object({
|
return joiValidator.body(Joi.object({
|
||||||
query: Joi.string().required(),
|
query: Joi.string(),
|
||||||
datasourceId: Joi.string().required(),
|
datasourceId: Joi.string().required(),
|
||||||
parameters: Joi.object({}).required().unknown(true)
|
parameters: Joi.object({}).required().unknown(true)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: sort out auth so apps have the right permissions
|
|
||||||
router
|
router
|
||||||
.get("/api/queries", authorized(BUILDER), queryController.fetch)
|
.get("/api/queries", authorized(BUILDER), queryController.fetch)
|
||||||
.post(
|
.post(
|
||||||
|
|
Loading…
Reference in New Issue