Skip to content

Commit 31df9cb

Browse files
feat: allow inserting templates into descriptions
1 parent 44f9b1a commit 31df9cb

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/components/dash/edit/EditDescription.svelte

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,34 @@
55
import { autoresize } from "svelte-textarea-autoresize"
66
import AwaitHtml from "../AwaitHtml.svelte"
77
import parseMarkdown from "$api/parseMarkdown"
8+
import { dash } from "$lib/dash/dash.svelte"
89
910
let {
1011
original,
1112
value = $bindable(),
1213
item,
1314
index,
1415
title,
16+
showTemplates = true,
1517
}: {
1618
original: string | undefined | null
1719
value: string | undefined
1820
item?: Member | Group | System
1921
index?: number
2022
title?: string
23+
showTemplates?: boolean
2124
} = $props()
2225
2326
let popupElement: HTMLDialogElement
27+
28+
let templatesVisible =
29+
showTemplates &&
30+
dash.config?.description_templates &&
31+
dash.config?.description_templates.length > 0
32+
33+
function insertTemplate(index: number) {
34+
value = dash.config?.description_templates[index]
35+
}
2436
</script>
2537

2638
<div class="flex flex-col w-full">
@@ -41,7 +53,18 @@
4153
{value?.length ?? 0}/1000
4254
</span>
4355
</div>
44-
<div class="p-4 rounded-xl bg-base-100">
56+
<div class={`p-4 rounded-xl bg-base-100 flex flex-col gap-2 ${templatesVisible ? "pt-2" : ""}`}>
57+
{#if templatesVisible}
58+
<ol class="flex flex-row gap-2 items-center">
59+
{#each dash.config?.description_templates ?? [] as template, i}
60+
<li>
61+
<button class="btn btn-xs btn-neutral" onclick={() => insertTemplate(i)}
62+
>Template {i + 1}</button
63+
>
64+
</li>
65+
{/each}
66+
</ol>
67+
{/if}
4568
<textarea
4669
id={`${item?.uuid ?? index ?? ""}-edit-description`}
4770
bind:value

src/routes/dash/[sid]/(dashboard)/config/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<div class="flex flex-col gap-3 -mx-4">
133133
{#each new Array(3) as _, i}
134134
<EditDescription
135+
showTemplates={false}
135136
title={`Template ${i + 1}`}
136137
index={i + 1}
137138
original={dash.config?.description_templates[i]}

0 commit comments

Comments
 (0)