fix not being able to navigate directly to email template
This commit is contained in:
parent
e8969f395a
commit
aaa2433af6
|
@ -16,21 +16,16 @@
|
||||||
import Editor from "components/integration/QueryEditor.svelte"
|
import Editor from "components/integration/QueryEditor.svelte"
|
||||||
import TemplateBindings from "./_components/TemplateBindings.svelte"
|
import TemplateBindings from "./_components/TemplateBindings.svelte"
|
||||||
|
|
||||||
const ConfigTypes = {
|
|
||||||
SMTP: "smtp",
|
|
||||||
}
|
|
||||||
|
|
||||||
export let template
|
export let template
|
||||||
|
|
||||||
let selected = "Edit"
|
let selected = "Edit"
|
||||||
let selectedBindingTab = "Template"
|
|
||||||
let htmlEditor
|
let htmlEditor
|
||||||
|
|
||||||
$: selectedTemplate = $email.templates.find(
|
$: selectedTemplate = $email?.templates?.find(
|
||||||
({ purpose }) => purpose === template
|
({ purpose }) => purpose === template
|
||||||
)
|
)
|
||||||
$: templateBindings =
|
$: templateBindings =
|
||||||
$email.definitions?.bindings[selectedTemplate.purpose] || []
|
$email.definitions?.bindings?.[selectedTemplate.purpose] || []
|
||||||
|
|
||||||
async function saveTemplate() {
|
async function saveTemplate() {
|
||||||
try {
|
try {
|
||||||
|
@ -80,7 +75,7 @@
|
||||||
on:change={e => {
|
on:change={e => {
|
||||||
selectedTemplate.contents = e.detail.value
|
selectedTemplate.contents = e.detail.value
|
||||||
}}
|
}}
|
||||||
value={selectedTemplate.contents}
|
value={selectedTemplate?.contents}
|
||||||
/>
|
/>
|
||||||
<div class="bindings-editor">
|
<div class="bindings-editor">
|
||||||
<Detail size="L">Bindings</Detail>
|
<Detail size="L">Bindings</Detail>
|
||||||
|
@ -95,7 +90,7 @@
|
||||||
<Tab title="Common">
|
<Tab title="Common">
|
||||||
<TemplateBindings
|
<TemplateBindings
|
||||||
title="Common Bindings"
|
title="Common Bindings"
|
||||||
bindings={$email.definitions.bindings.common}
|
bindings={$email?.definitions?.bindings?.common}
|
||||||
onBindingClick={setTemplateBinding}
|
onBindingClick={setTemplateBinding}
|
||||||
/>
|
/>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
@ -105,7 +100,7 @@
|
||||||
>
|
>
|
||||||
<Tab title="Preview">
|
<Tab title="Preview">
|
||||||
<div class="preview">
|
<div class="preview">
|
||||||
{@html selectedTemplate.contents}
|
{@html selectedTemplate?.contents}
|
||||||
</div>
|
</div>
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<script>
|
||||||
|
import { email } from "stores/portal"
|
||||||
|
email.templates.fetch()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<slot />
|
|
@ -12,7 +12,6 @@
|
||||||
Body,
|
Body,
|
||||||
Table,
|
Table,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { onMount } from "svelte"
|
|
||||||
import { email } from "stores/portal"
|
import { email } from "stores/portal"
|
||||||
import TemplateLink from "./_components/TemplateLink.svelte"
|
import TemplateLink from "./_components/TemplateLink.svelte"
|
||||||
import api from "builderStore/api"
|
import api from "builderStore/api"
|
||||||
|
@ -36,9 +35,6 @@
|
||||||
]
|
]
|
||||||
|
|
||||||
let smtpConfig
|
let smtpConfig
|
||||||
let bindingsOpen = false
|
|
||||||
let htmlModal
|
|
||||||
let htmlEditor
|
|
||||||
let loading
|
let loading
|
||||||
|
|
||||||
async function saveSmtp() {
|
async function saveSmtp() {
|
||||||
|
@ -56,16 +52,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveTemplate() {
|
|
||||||
try {
|
|
||||||
await email.templates.save(selectedTemplate)
|
|
||||||
notifications.success(`Template saved.`)
|
|
||||||
} catch (err) {
|
|
||||||
notifications.error(`Failed to update template settings. ${err}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchSmtp() {
|
async function fetchSmtp() {
|
||||||
|
loading = true
|
||||||
// fetch the configs for smtp
|
// fetch the configs for smtp
|
||||||
const smtpResponse = await api.get(`/api/admin/configs/${ConfigTypes.SMTP}`)
|
const smtpResponse = await api.get(`/api/admin/configs/${ConfigTypes.SMTP}`)
|
||||||
const smtpDoc = await smtpResponse.json()
|
const smtpDoc = await smtpResponse.json()
|
||||||
|
@ -82,14 +70,10 @@
|
||||||
} else {
|
} else {
|
||||||
smtpConfig = smtpDoc
|
smtpConfig = smtpDoc
|
||||||
}
|
}
|
||||||
|
loading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
fetchSmtp()
|
||||||
loading = true
|
|
||||||
await fetchSmtp()
|
|
||||||
await email.templates.fetch()
|
|
||||||
loading = false
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Page>
|
<Page>
|
||||||
|
|
Loading…
Reference in New Issue