bindings wip
This commit is contained in:
parent
deca9d4e6c
commit
bfa2d53e39
|
@ -54,6 +54,7 @@
|
||||||
export let autofocus = false
|
export let autofocus = false
|
||||||
export let jsBindingWrapping = true
|
export let jsBindingWrapping = true
|
||||||
export let readonly = false
|
export let readonly = false
|
||||||
|
export let readonlyLineNumbers = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -240,6 +241,9 @@
|
||||||
|
|
||||||
if (readonly) {
|
if (readonly) {
|
||||||
complete.push(EditorState.readOnly.of(true))
|
complete.push(EditorState.readOnly.of(true))
|
||||||
|
if (readonlyLineNumbers) {
|
||||||
|
complete.push(lineNumbers())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
complete = [
|
complete = [
|
||||||
...complete,
|
...complete,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Block, Subject, JSONProperty, Property, Section } from './components'
|
import { BindingProperty, Block, Subject, JSONProperty, Property, Section } from './components'
|
||||||
|
|
||||||
export let schema
|
export let schema
|
||||||
export let columnName
|
export let columnName
|
||||||
|
@ -62,10 +62,21 @@
|
||||||
</Property>
|
</Property>
|
||||||
{/each}
|
{/each}
|
||||||
{:else if schema.type === "json"}
|
{:else if schema.type === "json"}
|
||||||
<JSONProperty
|
<Property name="Schema">
|
||||||
name="Schema"
|
<JSONProperty
|
||||||
value={JSON.stringify(schema?.schema ?? {}, null, 2)}
|
value={JSON.stringify(schema?.schema ?? {}, null, 2)}
|
||||||
|
/>
|
||||||
|
</Property>
|
||||||
|
{:else if schema.type === "formula"}
|
||||||
|
<Property
|
||||||
|
name="Formula type"
|
||||||
|
value={schema?.formulaType === "dynamic" ? "Dynamic" : "Static"}
|
||||||
/>
|
/>
|
||||||
|
<Property name="Formula">
|
||||||
|
<BindingProperty
|
||||||
|
value={schema?.formula}
|
||||||
|
/>
|
||||||
|
</Property>
|
||||||
{/if}
|
{/if}
|
||||||
<Property
|
<Property
|
||||||
name="Required"
|
name="Required"
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
decodeJSBinding,
|
||||||
|
} from "@budibase/string-templates"
|
||||||
|
import CodeEditor from "components/common/CodeEditor/CodeEditor.svelte"
|
||||||
|
import {
|
||||||
|
EditorModes,
|
||||||
|
} from "components/common/CodeEditor"
|
||||||
|
import {
|
||||||
|
readableToRuntimeBinding,
|
||||||
|
runtimeToReadableBinding,
|
||||||
|
getDatasourceForProvider
|
||||||
|
} from "dataBinding"
|
||||||
|
import { tables, datasources, selectedScreen, selectedComponent } from "stores/builder"
|
||||||
|
import { getBindings } from "components/backend/DataTable/formula"
|
||||||
|
|
||||||
|
export let value
|
||||||
|
$: datasource = getDatasourceForProvider($selectedScreen, $selectedComponent)
|
||||||
|
$: tableId = datasource.tableId
|
||||||
|
$: table = $tables?.list?.find(table => table._id === tableId)
|
||||||
|
$: bindings = getBindings({ table });
|
||||||
|
|
||||||
|
$: readableBinding = runtimeToReadableBinding(bindings, value)
|
||||||
|
|
||||||
|
$: isJs = value?.startsWith?.("{{ js ")
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CodeEditor
|
||||||
|
readonly
|
||||||
|
readonlyLineNumbers
|
||||||
|
value={isJs ? decodeJSBinding(readableBinding) : readableBinding}
|
||||||
|
jsBindingWrapping={isJs}
|
||||||
|
mode={isJs ? EditorModes.JS :EditorModes.Handlebars}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
|
@ -1,35 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
export let name;
|
|
||||||
export let value;
|
export let value;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="property">
|
<pre class="pre">
|
||||||
<span class="propertyName">
|
{value}
|
||||||
<slot name="name">
|
</pre>
|
||||||
{name}
|
|
||||||
</slot>
|
|
||||||
</span>
|
|
||||||
<span class="propertyDivider">-</span>
|
|
||||||
<pre class="pre propertyValue">
|
|
||||||
<slot>
|
|
||||||
{value}
|
|
||||||
</slot>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.property {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.propertyName {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.propertyDivider {
|
|
||||||
padding: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pre {
|
.pre {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export { default as Subject } from "./Subject.svelte"
|
export { default as Subject } from "./Subject.svelte"
|
||||||
export { default as Property } from "./Property.svelte"
|
export { default as Property } from "./Property.svelte"
|
||||||
export { default as JSONProperty } from "./JSONProperty.svelte"
|
export { default as JSONProperty } from "./JSONProperty.svelte"
|
||||||
|
export { default as BindingProperty } from "./BindingProperty.svelte"
|
||||||
export { default as Section } from "./Section.svelte"
|
export { default as Section } from "./Section.svelte"
|
||||||
export { default as Block } from "./Block.svelte"
|
export { default as Block } from "./Block.svelte"
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
$: options = Object.keys(schema || {})
|
$: options = Object.keys(schema || {})
|
||||||
$: boundValue = getValidOptions(value, options)
|
$: boundValue = getValidOptions(value, options)
|
||||||
|
|
||||||
|
|
||||||
const getValidOptions = (selectedOptions, allOptions) => {
|
const getValidOptions = (selectedOptions, allOptions) => {
|
||||||
// Fix the hardcoded default string value
|
// Fix the hardcoded default string value
|
||||||
if (!Array.isArray(selectedOptions)) {
|
if (!Array.isArray(selectedOptions)) {
|
||||||
|
|
|
@ -1638,8 +1638,11 @@
|
||||||
"typeSupport": {
|
"typeSupport": {
|
||||||
"supported": ["number", "boolean"],
|
"supported": ["number", "boolean"],
|
||||||
"partialSupport": [
|
"partialSupport": [
|
||||||
|
{ "type": "longform", "message": "stringAsNumber" },
|
||||||
{ "type": "string", "message": "stringAsNumber" },
|
{ "type": "string", "message": "stringAsNumber" },
|
||||||
|
{ "type": "bigint", "message": "stringAsNumber" },
|
||||||
{ "type": "options", "message": "stringAsNumber" },
|
{ "type": "options", "message": "stringAsNumber" },
|
||||||
|
{ "type": "formula", "message": "stringAsNumber" },
|
||||||
{ "type": "datetime", "message": "dateAsNumber"}
|
{ "type": "datetime", "message": "dateAsNumber"}
|
||||||
],
|
],
|
||||||
"unsupported": [
|
"unsupported": [
|
||||||
|
|
Loading…
Reference in New Issue