Add hot reloading to search results

This commit is contained in:
Andrew Kingston 2021-02-11 09:30:05 +00:00
parent a166147826
commit 81e779c8b5
1 changed files with 78 additions and 68 deletions

View File

@ -1,6 +1,5 @@
<script> <script>
import { getContext } from "svelte" import { getContext } from "svelte"
import { isEmpty } from "lodash/fp"
import { import {
Button, Button,
DatePicker, DatePicker,
@ -10,10 +9,12 @@
Input, Input,
} from "@budibase/bbui" } from "@budibase/bbui"
const { API, styleable, Provider, builderStore } = getContext("sdk") const { API, styleable, Provider, builderStore, ActionTypes } = getContext(
"sdk"
)
const component = getContext("component") const component = getContext("component")
export let table = [] export let table
export let columns = [] export let columns = []
export let pageSize export let pageSize
export let noRowsMessage export let noRowsMessage
@ -34,9 +35,16 @@
search[next] === "" ? acc : { ...acc, [next]: search[next] }, search[next] === "" ? acc : { ...acc, [next]: search[next] },
{} {}
) )
$: actions = [
{
type: ActionTypes.RefreshDatasource,
callback: () => fetchData(table, page),
metadata: { datasource: { type: "table", tableId: table } },
},
]
async function fetchData(table, page) { async function fetchData(table, page) {
if (!isEmpty(table)) { if (table) {
const tableDef = await API.fetchTableDefinition(table) const tableDef = await API.fetchTableDefinition(table)
schema = tableDef.schema schema = tableDef.schema
rows = await API.searchTableData({ rows = await API.searchTableData({
@ -60,6 +68,7 @@
} }
</script> </script>
<Provider {actions}>
<div use:styleable={$component.styles}> <div use:styleable={$component.styles}>
<div class="query-builder"> <div class="query-builder">
{#if schema} {#if schema}
@ -128,6 +137,7 @@
{/if} {/if}
</div> </div>
</div> </div>
</Provider>
<style> <style>
p { p {