edit template HTML in modal

This commit is contained in:
Martin McKeaveney 2021-05-10 14:47:16 +01:00
parent 8174f44d40
commit 2be60b8c71
1 changed files with 14 additions and 11 deletions

View File

@ -4,6 +4,8 @@
Heading, Heading,
Divider, Divider,
Label, Label,
Modal,
ModalContent,
notifications, notifications,
Layout, Layout,
Input, Input,
@ -24,6 +26,7 @@
let templateIdx = 0 let templateIdx = 0
let templateDefinition let templateDefinition
let templates = [] let templates = []
let htmlModal
$: templateTypes = templates.map((template, idx) => ({ $: templateTypes = templates.map((template, idx) => ({
label: template.purpose, label: template.purpose,
@ -154,19 +157,19 @@
</Body> </Body>
<div class="template-controls"> <div class="template-controls">
<Select bind:value={templateIdx} options={templateTypes} /> <Select bind:value={templateIdx} options={templateTypes} />
<Button cta on:click={saveTemplate}>Save</Button> <Button primary on:click={htmlModal.show}>Edit HTML</Button>
</div> </div>
{#if selectedTemplate} </div>
{#key templateIdx} <Modal bind:this={htmlModal}>
<ModalContent title="Edit Template HTML" onConfirm={saveTemplate} size="XL">
<Editor <Editor
mode="handlebars" mode="handlebars"
on:change={e => { on:change={e => {
selectedTemplate.contents = e.detail.value selectedTemplate.contents = e.detail.value
}} }}
value={selectedTemplate.contents} /> value={selectedTemplate.contents} />
{/key} </ModalContent>
{/if} </Modal>
</div>
{/if} {/if}
</Page> </Page>