This commit is contained in:
Martin McKeaveney 2020-06-24 16:12:55 +01:00
parent 2c764a787c
commit 1f2c1a06aa
5 changed files with 23 additions and 17 deletions

View File

@ -4,11 +4,10 @@
import { Router, basepath } from "@sveltech/routify" import { Router, basepath } from "@sveltech/routify"
import { routes } from "../routify/routes" import { routes } from "../routify/routes"
import { store, initialise } from "builderStore" import { store, initialise } from "builderStore"
import NotificationDisplay from "components/common/Notification/NotificationDisplay.svelte"; import NotificationDisplay from "components/common/Notification/NotificationDisplay.svelte"
$basepath = "/_builder" $basepath = "/_builder"
</script> </script>
<NotificationDisplay /> <NotificationDisplay />
<Router {routes} /> <Router {routes} />

View File

@ -1,13 +1,16 @@
import { writable } from 'svelte/store' import { writable } from "svelte/store"
import { generate } from "shortid" import { generate } from "shortid"
export const notificationStore = writable({ export const notificationStore = writable({
notifications: [] notifications: [],
}) })
export function send(message, type = 'default') { export function send(message, type = "default") {
notificationStore.update(state => { notificationStore.update(state => {
state.notifications = [...state.notifications, { id: generate(), type, message }] state.notifications = [
...state.notifications,
{ id: generate(), type, message },
]
return state return state
}) })
} }
@ -16,5 +19,5 @@ export const notifier = {
danger: msg => send(msg, "danger"), danger: msg => send(msg, "danger"),
warning: msg => send(msg, "warning"), warning: msg => send(msg, "warning"),
info: msg => send(msg, "info"), info: msg => send(msg, "info"),
success: msg => send(msg, "success") success: msg => send(msg, "success"),
} }

View File

@ -16,17 +16,20 @@
$: if ($notificationStore.notifications.length) { $: if ($notificationStore.notifications.length) {
setTimeout(() => { setTimeout(() => {
notificationStore.update(state => { notificationStore.update(state => {
state.notifications.shift(); state.notifications.shift()
state.notifications = state.notifications state.notifications = state.notifications
return state; return state
}) })
}, timeout) }, timeout)
} }
</script> </script>
<ul class="notifications"> <ul class="notifications">
{#each $notificationStore.notifications as notification (notification.id)} {#each $notificationStore.notifications as notification (notification.id)}
<li class="toast" style="background: {themes[notification.type]};" transition:fade> <li
class="toast"
style="background: {themes[notification.type]};"
transition:fade>
<div class="content">{notification.message}</div> <div class="content">{notification.message}</div>
{#if notification.icon} {#if notification.icon}
<i class={notification.icon} /> <i class={notification.icon} />

View File

@ -132,11 +132,9 @@
</td> </td>
{#each headers as header} {#each headers as header}
<td> <td>
{#if schema[header].type === "link"} {#if schema[header].type === 'link'}
<LinkedRecord field={schema[header]} ids={row[header]} /> <LinkedRecord field={schema[header]} ids={row[header]} />
{:else} {:else}{row[header]}{/if}
{row[header]}
{/if}
</td> </td>
{/each} {/each}
</tr> </tr>

View File

@ -78,7 +78,10 @@
{:else if field.type === 'link'} {:else if field.type === 'link'}
<div class="field"> <div class="field">
<label>Link</label> <label>Link</label>
<select class="budibase__input" bind:value={field.modelId} on:change={attachModelIdToSchema}> <select
class="budibase__input"
bind:value={field.modelId}
on:change={attachModelIdToSchema}>
<option value={''} /> <option value={''} />
{#each $backendUiStore.models as model} {#each $backendUiStore.models as model}
{#if model._id !== $backendUiStore.draftModel._id} {#if model._id !== $backendUiStore.draftModel._id}