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

View File

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