feat: add multiple presets
This commit is contained in:
1 parent
78022bee5e
commit
d6edfaca36
6 files changed
+120
-27
No files matched your search
@@ -3,20 +3,25 @@
|
||||
import Setting from './Setting.svelte'
|
||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||
import Sort from '$lib/components/lemmy/Sort.svelte'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { Disclosure, Material, TextInput, toast } from 'mono-svelte'
|
||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import {
|
||||
ArrowPath,
|
||||
ChatBubbleOvalLeftEllipsis,
|
||||
ChevronDown,
|
||||
ChevronRight,
|
||||
GlobeAmericas,
|
||||
Icon,
|
||||
Plus,
|
||||
Trash,
|
||||
} from 'svelte-hero-icons'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import { Button, Checkbox, Select } from 'mono-svelte'
|
||||
import ViewSelect from '$lib/components/lemmy/ViewSelect.svelte'
|
||||
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
|
||||
import { removeItem } from '$lib/util.js'
|
||||
|
||||
let data = {
|
||||
loading: false,
|
||||
@@ -243,9 +248,9 @@
|
||||
|
||||
<SectionTitle class="mt-4" id="moderation">Moderation</SectionTitle>
|
||||
<Setting>
|
||||
<span slot="title">Removal reply preset</span>
|
||||
<span slot="title">Removal reply presets</span>
|
||||
<span slot="description">
|
||||
<p>The preset to use for "Reply reason" in a submission removal.</p>
|
||||
<p>Presets to use for "Reply reason" in a submission removal.</p>
|
||||
<ul class="leading-6">
|
||||
<li>Syntax:</li>
|
||||
<li>
|
||||
@@ -266,18 +271,64 @@
|
||||
</li>
|
||||
</ul>
|
||||
</span>
|
||||
<MarkdownEditor
|
||||
bind:value={$userSettings.moderation.removalReasonPreset}
|
||||
images={false}
|
||||
previewButton
|
||||
beforePreview={(input) =>
|
||||
removalTemplate(input, {
|
||||
postTitle: '<Example post>',
|
||||
communityLink: '[!community@example.com]()',
|
||||
reason: '<Being a meanie>',
|
||||
username: '@Bob',
|
||||
})}
|
||||
/>
|
||||
{#each $userSettings.moderation.presets as preset, index}
|
||||
<Material color="distinct" padding="md" class="py-3">
|
||||
<details>
|
||||
<summary
|
||||
class="cursor-pointer inline-flex flex-row items-center w-full gap-1"
|
||||
>
|
||||
<Icon src={ChevronDown} mini size="16" slot="prefix" />
|
||||
{preset.title}
|
||||
<Button
|
||||
size="square-md"
|
||||
class="ml-auto"
|
||||
on:click={() => {
|
||||
$userSettings.moderation.presets.splice(index, 1)
|
||||
$userSettings.moderation.presets =
|
||||
$userSettings.moderation.presets
|
||||
}}
|
||||
>
|
||||
<Icon src={Trash} size="16" mini slot="prefix" />
|
||||
</Button>
|
||||
</summary>
|
||||
<div class="flex flex-col gap-3 mt-2">
|
||||
<TextInput
|
||||
label="Title"
|
||||
bind:value={preset.title}
|
||||
placeholder="Reason 1"
|
||||
/>
|
||||
<MarkdownEditor
|
||||
bind:value={preset.content}
|
||||
label="Content"
|
||||
images={false}
|
||||
previewButton
|
||||
beforePreview={(input) =>
|
||||
removalTemplate(input, {
|
||||
postTitle: '<Example post>',
|
||||
communityLink: '[!community@example.com]()',
|
||||
reason: '<Being a meanie>',
|
||||
username: '@Bob',
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</details>
|
||||
</Material>
|
||||
{/each}
|
||||
<Button
|
||||
on:click={() => {
|
||||
$userSettings.moderation.presets = [
|
||||
...$userSettings.moderation.presets,
|
||||
{
|
||||
title: `Preset ${$userSettings.moderation.presets.length + 1}`,
|
||||
content:
|
||||
'Your submission in *{{post}}* was removed for *{{reason}}*.',
|
||||
},
|
||||
]
|
||||
}}
|
||||
>
|
||||
<Icon src={Plus} mini size="16" slot="prefix" />
|
||||
Add Preset
|
||||
</Button>
|
||||
</Setting>
|
||||
|
||||
<SectionTitle class="mt-4" id="other">Other</SectionTitle>
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
</div>
|
||||
{#if $$slots.default}
|
||||
<div
|
||||
class="w-full px-5 py-3 bg-slate-50 dark:bg-zinc-950 border-t dark:border-zinc-800 mt-4"
|
||||
class="w-full px-5 py-3 bg-slate-50 dark:bg-zinc-950 border-t dark:border-zinc-800 mt-4
|
||||
flex flex-col gap-2"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user