Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f6fd1cc0fb
|
|||
|
2482b392b5
|
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (open && mode === 'edit' && item) {
|
if (open && mode === 'edit' && item) {
|
||||||
$form.name = item.name ?? '';
|
$form.title = item.name ?? '';
|
||||||
$form.description = item.description ?? '';
|
$form.description = item.description ?? '';
|
||||||
} else if (!open) {
|
} else if (!open) {
|
||||||
reset();
|
reset();
|
||||||
@@ -75,18 +75,18 @@
|
|||||||
|
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<label for="agenda-name" class="text-sm font-medium">名称</label>
|
<label for="agenda-name" class="text-sm font-medium">名称</label>
|
||||||
<label class="input w-full {$errors.name ? 'input-error' : ''}">
|
<label class="input w-full {$errors.title ? 'input-error' : ''}">
|
||||||
<input
|
<input
|
||||||
id="agenda-name"
|
id="agenda-name"
|
||||||
name="name"
|
name="title"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="议程标题"
|
placeholder="议程标题"
|
||||||
maxlength="255"
|
maxlength="255"
|
||||||
bind:value={$form.name}
|
bind:value={$form.title}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
{#if $errors.name}
|
{#if $errors.title}
|
||||||
<p class="text-xs text-error">{$errors.name}</p>
|
<p class="text-xs text-error">{$errors.title}</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,28 +7,28 @@ import {
|
|||||||
} from './agenda';
|
} from './agenda';
|
||||||
|
|
||||||
describe('agendaItemSchema', () => {
|
describe('agendaItemSchema', () => {
|
||||||
it('accepts name and description', () => {
|
it('accepts title and description', () => {
|
||||||
expect(agendaItemSchema.safeParse({ name: '开幕式', description: '活动开场' }).success).toBe(
|
expect(agendaItemSchema.safeParse({ title: '开幕式', description: '活动开场' }).success).toBe(
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects empty name', () => {
|
it('rejects empty title', () => {
|
||||||
expect(agendaItemSchema.safeParse({ name: '', description: '描述' }).success).toBe(false);
|
expect(agendaItemSchema.safeParse({ title: '', description: '描述' }).success).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects name over 255 chars', () => {
|
it('rejects title over 255 chars', () => {
|
||||||
expect(agendaItemSchema.safeParse({ name: 'a'.repeat(256), description: '描述' }).success).toBe(
|
expect(agendaItemSchema.safeParse({ title: 'a'.repeat(256), description: '描述' }).success).toBe(
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects missing description', () => {
|
it('rejects missing description', () => {
|
||||||
expect(agendaItemSchema.safeParse({ name: '开幕式' }).success).toBe(false);
|
expect(agendaItemSchema.safeParse({ title: '开幕式' }).success).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects empty description', () => {
|
it('rejects empty description', () => {
|
||||||
expect(agendaItemSchema.safeParse({ name: '开幕式', description: '' }).success).toBe(false);
|
expect(agendaItemSchema.safeParse({ title: '开幕式', description: '' }).success).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
// Submit/Update form: name + description
|
// Submit/Update form: title + description
|
||||||
// description is required — backend stores it as base64 markdown for both
|
// description is required — backend stores it as base64 markdown for both
|
||||||
// postAgendaSubmit and patchAgendaUpdate.
|
// postAgendaSubmit and patchAgendaUpdate.
|
||||||
export const agendaItemSchema = z.object({
|
export const agendaItemSchema = z.object({
|
||||||
name: z.string().min(1, '请填写名称').max(255, '名称最多 255 字'),
|
title: z.string().min(1, '请填写名称').max(255, '名称最多 255 字'),
|
||||||
description: z.string().min(1, '请填写描述')
|
description: z.string().min(1, '请填写描述')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export const actions: Actions = {
|
|||||||
client: api,
|
client: api,
|
||||||
body: {
|
body: {
|
||||||
agenda_id,
|
agenda_id,
|
||||||
name: fd.name,
|
name: fd.title,
|
||||||
// Backend stores description as base64; encode before sending.
|
// Backend stores description as base64; encode before sending.
|
||||||
description: fd.description ? Buffer.from(fd.description).toString('base64') : undefined
|
description: fd.description ? Buffer.from(fd.description).toString('base64') : undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { resolve } from '$app/paths';
|
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import dayjs from '$lib/dayjs';
|
import dayjs from '$lib/dayjs';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
@@ -97,14 +96,14 @@
|
|||||||
<div class="join">
|
<div class="join">
|
||||||
{#if data.page > 1}
|
{#if data.page > 1}
|
||||||
<a
|
<a
|
||||||
href={resolve(`${page.url.pathname}?page=${data.page - 1}` as '/')}
|
href={`${page.url.pathname}?page=${data.page - 1}`}
|
||||||
class="btn join-item btn-sm"
|
class="btn join-item btn-sm"
|
||||||
aria-label="上一页">«</a
|
aria-label="上一页">«</a
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
{#if hasNextPage}
|
{#if hasNextPage}
|
||||||
<a
|
<a
|
||||||
href={resolve(`${page.url.pathname}?page=${data.page + 1}` as '/')}
|
href={`${page.url.pathname}?page=${data.page + 1}`}
|
||||||
class="btn join-item btn-sm"
|
class="btn join-item btn-sm"
|
||||||
aria-label="下一页">»</a
|
aria-label="下一页">»</a
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ export const actions: Actions = {
|
|||||||
client: api,
|
client: api,
|
||||||
body: {
|
body: {
|
||||||
event_id: eventId,
|
event_id: eventId,
|
||||||
name: fd.name,
|
name: fd.title,
|
||||||
description: Buffer.from(fullDescription).toString('base64')
|
description: Buffer.from(fullDescription).toString('base64')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -209,7 +209,7 @@ export const actions: Actions = {
|
|||||||
client: api,
|
client: api,
|
||||||
body: {
|
body: {
|
||||||
agenda_id,
|
agenda_id,
|
||||||
name: fd.name,
|
name: fd.title,
|
||||||
description: Buffer.from(fd.description).toString('base64')
|
description: Buffer.from(fd.description).toString('base64')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user