1
0
Fork 0
mirror of synced 2024-07-09 00:06:05 +12:00

Merge branch 'form-builder' into relationship-one-to-many

This commit is contained in:
Keviin Åberg Kultalahti 2021-02-09 14:05:34 +01:00
commit cf31ddb8dc
7 changed files with 69 additions and 47 deletions

View file

@ -63,7 +63,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.58.2", "@budibase/bbui": "^1.58.4",
"@budibase/client": "^0.7.6", "@budibase/client": "^0.7.6",
"@budibase/colorpicker": "1.0.1", "@budibase/colorpicker": "1.0.1",
"@budibase/string-templates": "^0.7.6", "@budibase/string-templates": "^0.7.6",

View file

@ -842,10 +842,17 @@
lodash "^4.17.19" lodash "^4.17.19"
to-fast-properties "^2.0.0" to-fast-properties "^2.0.0"
"@budibase/bbui@^1.58.2": <<<<<<< HEAD
version "1.58.2" "@budibase/bbui@^1.58.4":
resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.58.2.tgz#1b9a5b1bf20597c1ea85ebba69acfec01ef6edce" version "1.58.4"
integrity sha512-Gn4yCNpoVhtVhRDuWEYdaBK/oAfccTvehywgbyH4sHKaY7aQ7v0679nsJsOHBjNPleKy5YN3ZLhneh5k3F1O2Q== resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.58.4.tgz#a74d66b3dd715b0a9861a0f86bc0b863fd8f1d44"
integrity sha512-1oEVt7zMREM594CAUIXqOtiuP4Sx4FbfgPBHTZ+t4RhFfbFqvU7yyakqPZM2LhTAmO5Rfa+c+dfFLh+y1++KaA==
=======
"@budibase/bbui@^1.58.3":
version "1.58.3"
resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.58.3.tgz#86ad6aa68eec7426e1ccdf1f7e7fc957cb57d3a3"
integrity sha512-PpbxfBhVpmP0EO1nPBhrz486EHCIgtJlXELC/ElzjG+FCQZSCvDSM7mq/97FOW35iYdTiQTlwFgOtvOgT1P8IQ==
>>>>>>> 10f6d871354dace180c86aefb389a97f7925b902
dependencies: dependencies:
markdown-it "^12.0.2" markdown-it "^12.0.2"
quill "^1.3.7" quill "^1.3.7"

View file

@ -11,16 +11,21 @@
// Clone and create new data context for this component tree // Clone and create new data context for this component tree
const context = getContext("context") const context = getContext("context")
const component = getContext("component") const component = getContext("component")
const newContext = createContextStore($context) const newContext = createContextStore()
setContext("context", newContext) setContext("context", newContext)
let initiated = false
$: providerKey = key || $component.id $: providerKey = key || $component.id
// Add data context
$: {
newContext.actions.provideData(providerKey, $context, data)
initiated = true
}
// Instance ID is unique to each instance of a provider // Instance ID is unique to each instance of a provider
let instanceId let instanceId
// Add data context
$: data !== undefined && newContext.actions.provideData(providerKey, data)
// Add actions context // Add actions context
$: { $: {
if (instanceId) { if (instanceId) {
@ -51,4 +56,6 @@
}) })
</script> </script>
<slot /> {#if initiated}
<slot />
{/if}

View file

@ -1,22 +1,20 @@
import { writable } from "svelte/store" import { writable } from "svelte/store"
export const createContextStore = existingContext => { export const createContextStore = () => {
const store = writable({ ...existingContext }) const store = writable({})
// Adds a data context layer to the tree // Adds a data context layer to the tree
const provideData = (providerId, data) => { const provideData = (providerId, context, data) => {
if (!providerId) { let newData = { ...context }
return if (providerId && data !== undefined) {
} newData[providerId] = data
store.update(state => {
state[providerId] = data
// Keep track of the closest component ID so we can later hydrate a "data" prop. // Keep track of the closest component ID so we can later hydrate a "data" prop.
// This is only required for legacy bindings that used "data" rather than a // This is only required for legacy bindings that used "data" rather than a
// component ID. // component ID.
state.closestComponentId = providerId newData.closestComponentId = providerId
return state }
}) store.set(newData)
} }
// Adds an action context layer to the tree // Adds an action context layer to the tree
@ -32,7 +30,6 @@ export const createContextStore = existingContext => {
return { return {
subscribe: store.subscribe, subscribe: store.subscribe,
update: store.update,
actions: { provideData, provideAction }, actions: { provideData, provideAction },
} }
} }

View file

@ -40,7 +40,7 @@
"gitHead": "1a80b09fd093f2599a68f7db72ad639dd50922dd", "gitHead": "1a80b09fd093f2599a68f7db72ad639dd50922dd",
"dependencies": { "dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.1.0", "@adobe/spectrum-css-workflow-icons": "^1.1.0",
"@budibase/bbui": "^1.55.1", "@budibase/bbui": "^1.58.4",
"@budibase/svelte-ag-grid": "^0.0.16", "@budibase/svelte-ag-grid": "^0.0.16",
"@spectrum-css/actionbutton": "^1.0.0-beta.1", "@spectrum-css/actionbutton": "^1.0.0-beta.1",
"@spectrum-css/button": "^3.0.0-beta.6", "@spectrum-css/button": "^3.0.0-beta.6",

View file

@ -1,46 +1,57 @@
<script> <script>
import { onMount, getContext } from "svelte" import { onMount, getContext } from "svelte"
const { API, screenStore, routeStore, Provider, styleable } = getContext(
"sdk"
)
const component = getContext("component")
export let table export let table
const {
API,
screenStore,
routeStore,
Provider,
styleable,
ActionTypes,
} = getContext("sdk")
const component = getContext("component")
let headers = [] let headers = []
let row let row
async function fetchFirstRow() { const fetchFirstRow = async tableId => {
const rows = await API.fetchTableData(table) const rows = await API.fetchTableData(tableId)
return Array.isArray(rows) && rows.length ? rows[0] : { tableId: table } return Array.isArray(rows) && rows.length ? rows[0] : { tableId }
} }
async function fetchData() { const fetchData = async (rowId, tableId) => {
if (!table) { if (!tableId) {
return return
} }
const pathParts = window.location.pathname.split("/") const pathParts = window.location.pathname.split("/")
const routeParamId = $routeStore.routeParams.id
// if srcdoc, then we assume this is the builder preview // if srcdoc, then we assume this is the builder preview
if ((pathParts.length === 0 || pathParts[0] === "srcdoc") && table) { if ((pathParts.length === 0 || pathParts[0] === "srcdoc") && tableId) {
row = await fetchFirstRow() row = await fetchFirstRow(tableId)
} else if (routeParamId) { } else if (rowId) {
row = await API.fetchRow({ tableId: table, rowId: routeParamId }) row = await API.fetchRow({ tableId, rowId })
} else { } else {
throw new Error("Row ID was not supplied to RowDetail") throw new Error("Row ID was not supplied to RowDetail")
} }
} }
onMount(fetchData) $: actions = [
{
type: ActionTypes.RefreshDatasource,
callback: () => fetchData($routeStore.routeParams.id, table),
metadata: { datasource: { type: "table", tableId: table } },
},
]
onMount(() => fetchData($routeStore.routeParams.id, table))
</script> </script>
{#if row} {#if row}
<Provider data={row} {actions}>
<div use:styleable={$component.styles}> <div use:styleable={$component.styles}>
<Provider data={row}>
<slot /> <slot />
</Provider>
</div> </div>
</Provider>
{/if} {/if}

View file

@ -44,10 +44,10 @@
lodash "^4.17.19" lodash "^4.17.19"
to-fast-properties "^2.0.0" to-fast-properties "^2.0.0"
"@budibase/bbui@^1.55.1": "@budibase/bbui@^1.58.4":
version "1.56.2" version "1.58.4"
resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.56.2.tgz#bb8f7d9b9b5ed06a22df877fbe028780d7602471" resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.58.4.tgz#a74d66b3dd715b0a9861a0f86bc0b863fd8f1d44"
integrity sha512-cWYkT1FNwNGTjisxtC5/MlQ1zeu7MYbMJsD6UyCEW3Ku6JIQZ6jyOkV6HKrmNND8VzVfddEGpzR37q+NoDpDFQ== integrity sha512-1oEVt7zMREM594CAUIXqOtiuP4Sx4FbfgPBHTZ+t4RhFfbFqvU7yyakqPZM2LhTAmO5Rfa+c+dfFLh+y1++KaA==
dependencies: dependencies:
markdown-it "^12.0.2" markdown-it "^12.0.2"
quill "^1.3.7" quill "^1.3.7"