Refactor some app components to remove dependency on static props

This commit is contained in:
Andrew Kingston 2021-11-16 17:52:00 +00:00
parent cc5e42e933
commit 69422f374b
3 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,5 @@
<script> <script>
import { onMount, getContext } from "svelte" import { getContext } from "svelte"
import Block from "components/Block.svelte" import Block from "components/Block.svelte"
import BlockComponent from "components/BlockComponent.svelte" import BlockComponent from "components/BlockComponent.svelte"
import { Heading } from "@budibase/bbui" import { Heading } from "@budibase/bbui"
@ -46,6 +46,7 @@
let repeaterId let repeaterId
let schema let schema
$: fetchSchema(dataSource)
$: enrichedSearchColumns = enrichSearchColumns(searchColumns, schema) $: enrichedSearchColumns = enrichSearchColumns(searchColumns, schema)
$: enrichedFilter = enrichFilter(filter, enrichedSearchColumns, formId) $: enrichedFilter = enrichFilter(filter, enrichedSearchColumns, formId)
$: cardWidth = cardHorizontal ? 420 : 300 $: cardWidth = cardHorizontal ? 420 : 300
@ -107,12 +108,12 @@
return `${split[0]}/{{ ${safe(repeaterId)}.${safe(col)} }}` return `${split[0]}/{{ ${safe(repeaterId)}.${safe(col)} }}`
} }
// Load the datasource schema on mount so we can determine column types // Load the datasource schema so we can determine column types
onMount(async () => { const fetchSchema = async dataSource => {
if (dataSource) { if (dataSource) {
schema = await API.fetchDatasourceSchema(dataSource) schema = await API.fetchDatasourceSchema(dataSource)
} }
}) }
</script> </script>
<Block> <Block>

View File

@ -1,5 +1,5 @@
<script> <script>
import { onMount, getContext } from "svelte" import { getContext } from "svelte"
import Block from "components/Block.svelte" import Block from "components/Block.svelte"
import BlockComponent from "components/BlockComponent.svelte" import BlockComponent from "components/BlockComponent.svelte"
import { Heading } from "@budibase/bbui" import { Heading } from "@budibase/bbui"
@ -41,6 +41,7 @@
let dataProviderId let dataProviderId
let schema let schema
$: fetchSchema(dataSource)
$: enrichedSearchColumns = enrichSearchColumns(searchColumns, schema) $: enrichedSearchColumns = enrichSearchColumns(searchColumns, schema)
$: enrichedFilter = enrichFilter(filter, enrichedSearchColumns, formId) $: enrichedFilter = enrichFilter(filter, enrichedSearchColumns, formId)
$: titleButtonAction = [ $: titleButtonAction = [
@ -85,12 +86,12 @@
return enrichedColumns.slice(0, 3) return enrichedColumns.slice(0, 3)
} }
// Load the datasource schema on mount so we can determine column types // Load the datasource schema so we can determine column types
onMount(async () => { const fetchSchema = async dataSource => {
if (dataSource) { if (dataSource) {
schema = await API.fetchDatasourceSchema(dataSource) schema = await API.fetchDatasourceSchema(dataSource)
} }
}) }
</script> </script>
<Block> <Block>

View File

@ -1,5 +1,5 @@
<script> <script>
import { getContext, onMount } from "svelte" import { getContext } from "svelte"
import InnerForm from "./InnerForm.svelte" import InnerForm from "./InnerForm.svelte"
import { hashString } from "utils/helpers" import { hashString } from "utils/helpers"