Name and Value Selects that depend on Model / View
This commit is contained in:
parent
c699aa5998
commit
6684b31305
|
@ -0,0 +1,22 @@
|
||||||
|
<script>
|
||||||
|
import OptionSelect from "./OptionSelect.svelte"
|
||||||
|
import { backendUiStore } from "builderStore"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
|
export let componentInstance = {}
|
||||||
|
|
||||||
|
let datasource = componentInstance.datasource
|
||||||
|
const models = $backendUiStore.models
|
||||||
|
|
||||||
|
let options = []
|
||||||
|
|
||||||
|
$: model = datasource ? models.find(m => m._id === datasource.modelId) : null
|
||||||
|
|
||||||
|
$: if (model) {
|
||||||
|
options = datasource.isModel
|
||||||
|
? Object.keys(model.schema)
|
||||||
|
: Object.keys(model.views[datasource.name].schema)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<OptionSelect {options} />
|
|
@ -2,6 +2,7 @@
|
||||||
import { onMount, beforeUpdate, afterUpdate } from "svelte"
|
import { onMount, beforeUpdate, afterUpdate } from "svelte"
|
||||||
import Portal from "svelte-portal"
|
import Portal from "svelte-portal"
|
||||||
import { buildStyle } from "../../helpers.js"
|
import { buildStyle } from "../../helpers.js"
|
||||||
|
|
||||||
export let options = []
|
export let options = []
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let styleBindingProperty
|
export let styleBindingProperty
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
{ key: "favicon", label: "Favicon", control: Input },
|
{ key: "favicon", label: "Favicon", control: Input },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const canRenderControl = (key, dependsOn) =>
|
||||||
|
propExistsOnComponentDef(key) &&
|
||||||
|
(!dependsOn || componentInstance[dependsOn])
|
||||||
|
|
||||||
$: isPage = screenOrPageInstance && screenOrPageInstance.favicon
|
$: isPage = screenOrPageInstance && screenOrPageInstance.favicon
|
||||||
$: screenOrPageDefinition = isPage ? pageDefinition : screenDefinition
|
$: screenOrPageDefinition = isPage ? pageDefinition : screenDefinition
|
||||||
</script>
|
</script>
|
||||||
|
@ -58,14 +62,17 @@
|
||||||
|
|
||||||
{#if panelDefinition && panelDefinition.length > 0}
|
{#if panelDefinition && panelDefinition.length > 0}
|
||||||
{#each panelDefinition as definition}
|
{#each panelDefinition as definition}
|
||||||
{#if propExistsOnComponentDef(definition.key)}
|
{#if canRenderControl(definition.key, definition.dependsOn)}
|
||||||
<PropertyControl
|
<PropertyControl
|
||||||
control={definition.control}
|
control={definition.control}
|
||||||
label={definition.label}
|
label={definition.label}
|
||||||
key={definition.key}
|
key={definition.key}
|
||||||
value={componentInstance[definition.key]}
|
value={componentInstance[definition.key]}
|
||||||
{onChange}
|
{onChange}
|
||||||
props={{ ...excludeProps(definition, ['control', 'label']) }} />
|
props={{ componentInstance, ...excludeProps(definition, [
|
||||||
|
'control',
|
||||||
|
'label',
|
||||||
|
]) }} />
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import OptionSelect from "./OptionSelect.svelte"
|
||||||
import Checkbox from "../common/Checkbox.svelte"
|
import Checkbox from "../common/Checkbox.svelte"
|
||||||
import ModelSelect from "components/userInterface/ModelSelect.svelte"
|
import ModelSelect from "components/userInterface/ModelSelect.svelte"
|
||||||
import ModelViewSelect from "components/userInterface/ModelViewSelect.svelte"
|
import ModelViewSelect from "components/userInterface/ModelViewSelect.svelte"
|
||||||
|
import ModelViewFieldSelect from "components/userInterface/ModelViewFieldSelect.svelte"
|
||||||
|
|
||||||
import { all } from "./propertyCategories.js"
|
import { all } from "./propertyCategories.js"
|
||||||
/*
|
/*
|
||||||
|
@ -582,6 +583,18 @@ export default {
|
||||||
key: "datasource",
|
key: "datasource",
|
||||||
control: ModelViewSelect,
|
control: ModelViewSelect,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Name Field",
|
||||||
|
key: "nameKey",
|
||||||
|
dependsOn: "datasource",
|
||||||
|
control: ModelViewFieldSelect,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Value Field",
|
||||||
|
key: "valueKey",
|
||||||
|
dependsOn: "datasource",
|
||||||
|
control: ModelViewFieldSelect,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Animate Chart",
|
label: "Animate Chart",
|
||||||
key: "isAnimated",
|
key: "isAnimated",
|
||||||
|
@ -617,16 +630,6 @@ export default {
|
||||||
"yellow",
|
"yellow",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: "Name Field",
|
|
||||||
key: "nameKey",
|
|
||||||
control: Input,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Value Field",
|
|
||||||
key: "valueKey",
|
|
||||||
control: Input,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: "External Radius",
|
label: "External Radius",
|
||||||
key: "externalRadius",
|
key: "externalRadius",
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
node_modules
|
node_modules
|
||||||
yarn.lock
|
yarn.lock
|
||||||
package-lock.json
|
package-lock.json
|
||||||
dist/index.js
|
dist
|
||||||
dist/index.js.map
|
|
||||||
|
|
|
@ -358,6 +358,7 @@
|
||||||
"data": true,
|
"data": true,
|
||||||
"props": {
|
"props": {
|
||||||
"datasource": "string",
|
"datasource": "string",
|
||||||
|
"data": "string",
|
||||||
"color": "string",
|
"color": "string",
|
||||||
"height": "number",
|
"height": "number",
|
||||||
"width": "number",
|
"width": "number",
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (chart) {
|
if (chart) {
|
||||||
if (model) {
|
if (datasource) {
|
||||||
let _data = await fetchData(datasource)
|
let _data = await fetchData(datasource)
|
||||||
data = checkAndReformatData(_data)
|
data = checkAndReformatData(_data)
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
|
|
Loading…
Reference in New Issue