commit
381c43f1e3
|
@ -90,6 +90,8 @@ const contextToBindables = (models, walkResult) => context => {
|
||||||
runtimeBinding: `${contextParentPath}data.${key}`,
|
runtimeBinding: `${contextParentPath}data.${key}`,
|
||||||
// how the binding exressions looks to the user of the builder
|
// how the binding exressions looks to the user of the builder
|
||||||
readableBinding: `${context.instance._instanceName}.${model.name}.${key}`,
|
readableBinding: `${context.instance._instanceName}.${model.name}.${key}`,
|
||||||
|
// model / view info
|
||||||
|
model: context.model,
|
||||||
})
|
})
|
||||||
|
|
||||||
// see ModelViewSelect.svelte for the format of context.model
|
// see ModelViewSelect.svelte for the format of context.model
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function fieldOptions(field) {
|
function fieldOptions(field) {
|
||||||
return viewModel.schema[field].type === "string"
|
return viewModel.schema[field].type === "options"
|
||||||
? viewModel.schema[field].constraints.inclusion
|
? viewModel.schema[field].constraints.inclusion
|
||||||
: [true, false]
|
: [true, false]
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import { Input, Button, Spacer, Select, ModalContent } from "@budibase/bbui"
|
import { Input, Button, Spacer, Select, ModalContent } from "@budibase/bbui"
|
||||||
import getTemplates from "builderStore/store/screenTemplates"
|
import getTemplates from "builderStore/store/screenTemplates"
|
||||||
import { some } from "lodash/fp"
|
import { some } from "lodash/fp"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
const CONTAINER = "@budibase/standard-components/container"
|
const CONTAINER = "@budibase/standard-components/container"
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@
|
||||||
|
|
||||||
const templateChanged = newTemplateIndex => {
|
const templateChanged = newTemplateIndex => {
|
||||||
if (newTemplateIndex === undefined) return
|
if (newTemplateIndex === undefined) return
|
||||||
|
const template = templates[newTemplateIndex]
|
||||||
draftScreen = templates[newTemplateIndex].create()
|
draftScreen = templates[newTemplateIndex].create()
|
||||||
if (draftScreen.props._instanceName) {
|
if (draftScreen.props._instanceName) {
|
||||||
name = draftScreen.props._instanceName
|
name = draftScreen.props._instanceName
|
||||||
|
@ -63,6 +64,13 @@
|
||||||
|
|
||||||
store.createScreen(draftScreen)
|
store.createScreen(draftScreen)
|
||||||
|
|
||||||
|
if (templateIndex !== undefined) {
|
||||||
|
const template = templates[templateIndex]
|
||||||
|
analytics.captureEvent("Screen Created", {
|
||||||
|
template: template.id || template.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
finished()
|
finished()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,75 @@
|
||||||
<script>
|
<script>
|
||||||
import { DataList } from "@budibase/bbui"
|
import { DataList } from "@budibase/bbui"
|
||||||
import { createEventDispatcher } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
import { store } from "builderStore"
|
import { store, backendUiStore } from "builderStore"
|
||||||
|
import fetchBindableProperties from "builderStore/fetchBindableProperties"
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let value = ""
|
export let value = ""
|
||||||
|
|
||||||
|
$: urls = getUrls()
|
||||||
|
|
||||||
const handleBlur = () => dispatch("change", value)
|
const handleBlur = () => dispatch("change", value)
|
||||||
|
|
||||||
|
// this will get urls of all screens, but only
|
||||||
|
// choose detail screens that are usable in the current context
|
||||||
|
// and substitute the :id param for the actual {{ ._id }} binding
|
||||||
|
const getUrls = () => {
|
||||||
|
const urls = [
|
||||||
|
...$store.screens
|
||||||
|
.filter(screen => !screen.props._component.endsWith("/rowdetail"))
|
||||||
|
.map(screen => ({
|
||||||
|
name: screen.props._instanceName,
|
||||||
|
url: screen.route,
|
||||||
|
sort: screen.props._component,
|
||||||
|
})),
|
||||||
|
]
|
||||||
|
|
||||||
|
const bindableProperties = fetchBindableProperties({
|
||||||
|
componentInstanceId: $store.currentComponentInfo._id,
|
||||||
|
components: $store.components,
|
||||||
|
screen: $store.currentPreviewItem,
|
||||||
|
models: $backendUiStore.models,
|
||||||
|
})
|
||||||
|
|
||||||
|
const detailScreens = $store.screens.filter(screen =>
|
||||||
|
screen.props._component.endsWith("/rowdetail")
|
||||||
|
)
|
||||||
|
|
||||||
|
for (let detailScreen of detailScreens) {
|
||||||
|
const idBinding = bindableProperties.find(p => {
|
||||||
|
if (
|
||||||
|
p.type === "context" &&
|
||||||
|
p.runtimeBinding.endsWith("._id") &&
|
||||||
|
p.model
|
||||||
|
) {
|
||||||
|
const modelId =
|
||||||
|
typeof p.model === "string" ? p.model : p.model.modelId
|
||||||
|
return modelId === detailScreen.props.model
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
if (idBinding) {
|
||||||
|
urls.push({
|
||||||
|
name: detailScreen.props._instanceName,
|
||||||
|
url: detailScreen.route.replace(
|
||||||
|
":id",
|
||||||
|
`{{ ${idBinding.runtimeBinding} }}`
|
||||||
|
),
|
||||||
|
sort: detailScreen.props._component,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return urls
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DataList editable secondary on:blur={handleBlur} on:change bind:value>
|
<DataList editable secondary on:blur={handleBlur} on:change bind:value>
|
||||||
<option value="" />
|
<option value="" />
|
||||||
{#each $store.allScreens as screen}
|
{#each urls as url}
|
||||||
<option value={screen.route}>{screen.props._instanceName}</option>
|
<option value={url.url}>{url.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</DataList>
|
</DataList>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { isString, isUndefined } from "lodash/fp"
|
import { isString, isUndefined, cloneDeep } from "lodash/fp"
|
||||||
import { TYPE_MAP } from "./types"
|
import { TYPE_MAP } from "./types"
|
||||||
import { assign } from "lodash"
|
import { assign } from "lodash"
|
||||||
import { uuid } from "builderStore/uuid"
|
import { uuid } from "builderStore/uuid"
|
||||||
|
@ -83,13 +83,13 @@ const parsePropDef = propDef => {
|
||||||
if (isString(propDef)) {
|
if (isString(propDef)) {
|
||||||
if (!TYPE_MAP[propDef]) return error(`Type ${propDef} is not recognised.`)
|
if (!TYPE_MAP[propDef]) return error(`Type ${propDef} is not recognised.`)
|
||||||
|
|
||||||
return TYPE_MAP[propDef].default
|
return cloneDeep(TYPE_MAP[propDef].default)
|
||||||
}
|
}
|
||||||
|
|
||||||
const type = TYPE_MAP[propDef.type]
|
const type = TYPE_MAP[propDef.type]
|
||||||
if (!type) return error(`Type ${propDef.type} is not recognised.`)
|
if (!type) return error(`Type ${propDef.type} is not recognised.`)
|
||||||
|
|
||||||
return propDef.default
|
return cloneDeep(propDef.default)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const arrayElementComponentName = (parentComponentName, arrayPropName) =>
|
export const arrayElementComponentName = (parentComponentName, arrayPropName) =>
|
||||||
|
|
|
@ -10,7 +10,6 @@ export const TYPE_MAP = {
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
default: [],
|
default: [],
|
||||||
options: [],
|
|
||||||
},
|
},
|
||||||
event: {
|
event: {
|
||||||
default: [],
|
default: [],
|
||||||
|
|
|
@ -356,7 +356,7 @@ export default {
|
||||||
{
|
{
|
||||||
label: "destinationUrl",
|
label: "destinationUrl",
|
||||||
key: "destinationUrl",
|
key: "destinationUrl",
|
||||||
control: Input,
|
control: ScreenSelect,
|
||||||
placeholder: "/table/_id",
|
placeholder: "/table/_id",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -405,7 +405,7 @@ export default {
|
||||||
{
|
{
|
||||||
label: "Link Url",
|
label: "Link Url",
|
||||||
key: "linkUrl",
|
key: "linkUrl",
|
||||||
control: Input,
|
control: ScreenSelect,
|
||||||
placeholder: "Link URL",
|
placeholder: "Link URL",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -480,7 +480,7 @@ export default {
|
||||||
{
|
{
|
||||||
label: "Link Url",
|
label: "Link Url",
|
||||||
key: "linkUrl",
|
key: "linkUrl",
|
||||||
control: Input,
|
control: ScreenSelect,
|
||||||
placeholder: "Link URL",
|
placeholder: "Link URL",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ export const FIELDS = {
|
||||||
type: "options",
|
type: "options",
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
presence: { allowEmpty: true },
|
presence: false,
|
||||||
inclusion: [],
|
inclusion: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -67,7 +67,7 @@ export const FIELDS = {
|
||||||
type: "link",
|
type: "link",
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "array",
|
type: "array",
|
||||||
presence: { allowEmpty: true },
|
presence: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue