1
0
Fork 0
mirror of synced 2024-10-01 09:38:55 +13:00

Hide repeater placeholders when not running inside the builder or when the component hasn't been initialised fully

This commit is contained in:
Andrew Kingston 2021-01-26 09:48:41 +00:00
parent bfd24571b2
commit 77189c6d73
2 changed files with 14 additions and 10 deletions

View file

@ -5,6 +5,7 @@ import {
routeStore, routeStore,
screenStore, screenStore,
bindingStore, bindingStore,
builderStore,
} from "./store" } from "./store"
import { styleable } from "./utils/styleable" import { styleable } from "./utils/styleable"
import { linkable } from "./utils/linkable" import { linkable } from "./utils/linkable"
@ -16,6 +17,7 @@ export default {
notifications: notificationStore, notifications: notificationStore,
routeStore, routeStore,
screenStore, screenStore,
builderStore,
styleable, styleable,
linkable, linkable,
DataProvider, DataProvider,

View file

@ -2,12 +2,13 @@
import { getContext } from "svelte" import { getContext } from "svelte"
import { isEmpty } from "lodash/fp" import { isEmpty } from "lodash/fp"
const { API, styleable, DataProvider } = getContext("sdk") const { API, styleable, DataProvider, builderStore } = getContext("sdk")
const component = getContext("component") const component = getContext("component")
export let datasource = [] export let datasource = []
let rows = [] let rows = []
let loaded = false
$: fetchData(datasource) $: fetchData(datasource)
@ -15,21 +16,22 @@
if (!isEmpty(datasource)) { if (!isEmpty(datasource)) {
rows = await API.fetchDatasource(datasource) rows = await API.fetchDatasource(datasource)
} }
loaded = true
} }
</script> </script>
<div use:styleable={$component.styles}> <div use:styleable={$component.styles}>
{#if rows.length > 0} {#if rows.length > 0}
{#each rows as row} {#if $component.children === 0 && $builderStore.inBuilder}
<DataProvider {row}> <p>Add some components too</p>
{#if $component.children === 0} {:else}
<p>Add some components too.</p> {#each rows as row}
{:else} <DataProvider {row}>
<slot /> <slot />
{/if} </DataProvider>
</DataProvider> {/each}
{/each} {/if}
{:else} {:else if loaded && $builderStore.inBuilder}
<p>Feed me some data</p> <p>Feed me some data</p>
{/if} {/if}
</div> </div>