Add Mitgliederverwaltungs-UI (Phase 1 MVP)
- List view with live search and member count - Create form (/mitglieder/neu) with group checkboxes - Detail/Edit view with inline edit toggle - Delete with confirmation dialog - Makefile: skip migration files already on DS (avoid root permission error)
This commit is contained in:
parent
375a3305bb
commit
c2c4dfd518
4 changed files with 709 additions and 14 deletions
8
Makefile
8
Makefile
|
|
@ -73,11 +73,15 @@ deploy: check-ssh
|
|||
cat "$$f" | ssh $(DS_HOST) "cat > $(HOOKS_DST)/$$(basename $$f)"; \
|
||||
done; \
|
||||
fi
|
||||
@echo "→ PocketBase Migrations synchronisieren..."
|
||||
@echo "→ PocketBase Migrations synchronisieren (nur neue)..."
|
||||
@ssh $(DS_HOST) "mkdir -p $(MIGRATIONS_DST)"
|
||||
@if ls $(MIGRATIONS_SRC)/*.js 2>/dev/null | grep -q .; then \
|
||||
for f in $(MIGRATIONS_SRC)/*.js; do \
|
||||
cat "$$f" | ssh $(DS_HOST) "cat > $(MIGRATIONS_DST)/$$(basename $$f)"; \
|
||||
fname=$$(basename "$$f"); \
|
||||
if ! ssh $(DS_HOST) "test -f $(MIGRATIONS_DST)/$$fname" 2>/dev/null; then \
|
||||
cat "$$f" | ssh $(DS_HOST) "cat > $(MIGRATIONS_DST)/$$fname"; \
|
||||
echo " ✓ $$fname"; \
|
||||
fi; \
|
||||
done; \
|
||||
fi
|
||||
@echo "→ Docker rebuild + restart..."
|
||||
|
|
|
|||
|
|
@ -1,27 +1,174 @@
|
|||
<script lang="ts">
|
||||
import { pb } from '$lib/pb';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let mitglieder = $state<any[]>([]);
|
||||
let gruppen = $state<any[]>([]);
|
||||
let search = $state('');
|
||||
let loading = $state(true);
|
||||
|
||||
onMount(async () => {
|
||||
[mitglieder, gruppen] = await Promise.all([
|
||||
pb.collection('mitglieder').getFullList({ sort: 'nachname,vorname' }),
|
||||
pb.collection('gruppen').getFullList({ sort: 'name' })
|
||||
]);
|
||||
loading = false;
|
||||
});
|
||||
|
||||
let filtered = $derived(
|
||||
search.trim()
|
||||
? mitglieder.filter(m =>
|
||||
`${m.vorname} ${m.nachname} ${m.email}`.toLowerCase().includes(search.toLowerCase())
|
||||
)
|
||||
: mitglieder
|
||||
);
|
||||
|
||||
function gruppenLabel(ids: string[]) {
|
||||
return (ids ?? [])
|
||||
.map(id => gruppen.find(g => g.id === id)?.name)
|
||||
.filter(Boolean)
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
const statusFarbe: Record<string, string> = {
|
||||
aktiv: '#16a34a',
|
||||
passiv: '#f59e0b',
|
||||
ausgetreten: '#94a3b8'
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Mitglieder — vereins.haus</title></svelte:head>
|
||||
|
||||
<div class="page-header">
|
||||
<div class="top">
|
||||
<h1>Mitglieder</h1>
|
||||
<button class="btn-primary">+ Mitglied</button>
|
||||
<span class="count">{mitglieder.length}</span>
|
||||
</div>
|
||||
|
||||
<p class="placeholder">Mitgliederverwaltung — in Entwicklung</p>
|
||||
<input
|
||||
class="search"
|
||||
type="search"
|
||||
bind:value={search}
|
||||
placeholder="Name oder E-Mail suchen…"
|
||||
/>
|
||||
|
||||
{#if loading}
|
||||
<p class="hint">Laden…</p>
|
||||
{:else if filtered.length === 0}
|
||||
<p class="hint">
|
||||
{search ? 'Keine Treffer.' : 'Noch keine Mitglieder — lege das erste an!'}
|
||||
</p>
|
||||
{:else}
|
||||
<ul>
|
||||
{#each filtered as m (m.id)}
|
||||
<li>
|
||||
<a href="/mitglieder/{m.id}">
|
||||
<div class="avatar">{m.vorname[0]}{m.nachname[0]}</div>
|
||||
<div class="info">
|
||||
<span class="name">{m.vorname} {m.nachname}</span>
|
||||
<span class="meta">
|
||||
{[m.email, gruppenLabel(m.gruppe_ids)].filter(Boolean).join(' · ')}
|
||||
</span>
|
||||
</div>
|
||||
<span class="badge" style="color:{statusFarbe[m.status] ?? '#94a3b8'}">
|
||||
{m.status}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
<a class="fab" href="/mitglieder/neu" aria-label="Neues Mitglied">+</a>
|
||||
|
||||
<style>
|
||||
.page-header {
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1.25rem;
|
||||
align-items: baseline;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
h1 { font-size: 1.4rem; font-weight: 700; color: #1e293b; }
|
||||
.btn-primary {
|
||||
background: #1e40af; color: #fff; border: none;
|
||||
border-radius: 8px; padding: 0.5rem 1rem;
|
||||
font-size: 0.9rem; font-weight: 600;
|
||||
.count { font-size: 1rem; color: #94a3b8; }
|
||||
.search {
|
||||
width: 100%;
|
||||
padding: 0.6rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
background: #f8fafc;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.placeholder { color: #94a3b8; font-size: 0.95rem; }
|
||||
.search:focus { outline: none; border-color: #1e40af; background: #fff; }
|
||||
ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 5rem;
|
||||
}
|
||||
a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.85rem;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
a:hover { border-color: #1e40af; }
|
||||
.avatar {
|
||||
width: 2.4rem;
|
||||
height: 2.4rem;
|
||||
border-radius: 50%;
|
||||
background: #e0e7ff;
|
||||
color: #1e40af;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 700;
|
||||
font-size: 0.85rem;
|
||||
flex-shrink: 0;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
}
|
||||
.name { font-weight: 600; font-size: 0.95rem; color: #1e293b; }
|
||||
.meta {
|
||||
font-size: 0.78rem;
|
||||
color: #94a3b8;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.badge { font-size: 0.72rem; font-weight: 600; text-transform: capitalize; flex-shrink: 0; }
|
||||
.hint { color: #94a3b8; text-align: center; margin-top: 3rem; font-size: 0.95rem; }
|
||||
.fab {
|
||||
position: fixed;
|
||||
bottom: calc(60px + env(safe-area-inset-bottom) + 1.25rem);
|
||||
right: 1.25rem;
|
||||
width: 3.5rem;
|
||||
height: 3.5rem;
|
||||
background: #1e40af;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 2rem;
|
||||
line-height: 1;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 4px 14px rgba(30, 64, 175, 0.4);
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.fab:hover { background: #1d3a9e; }
|
||||
</style>
|
||||
|
|
|
|||
370
app/src/routes/(app)/mitglieder/[id]/+page.svelte
Normal file
370
app/src/routes/(app)/mitglieder/[id]/+page.svelte
Normal file
|
|
@ -0,0 +1,370 @@
|
|||
<script lang="ts">
|
||||
import { pb } from '$lib/pb';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
const id = $derived($page.params.id);
|
||||
|
||||
let gruppen = $state<any[]>([]);
|
||||
let vorname = $state('');
|
||||
let nachname = $state('');
|
||||
let email = $state('');
|
||||
let iban = $state('');
|
||||
let status = $state('aktiv');
|
||||
let gruppe_ids = $state<string[]>([]);
|
||||
let loading = $state(true);
|
||||
let saving = $state(false);
|
||||
let error = $state('');
|
||||
let editMode = $state(false);
|
||||
let showDelete = $state(false);
|
||||
|
||||
onMount(async () => {
|
||||
const [m, g] = await Promise.all([
|
||||
pb.collection('mitglieder').getOne(id),
|
||||
pb.collection('gruppen').getFullList({ sort: 'name' })
|
||||
]);
|
||||
vorname = m.vorname;
|
||||
nachname = m.nachname;
|
||||
email = m.email ?? '';
|
||||
iban = m.iban ?? '';
|
||||
status = m.status;
|
||||
gruppe_ids = m.gruppe_ids ?? [];
|
||||
gruppen = g;
|
||||
loading = false;
|
||||
});
|
||||
|
||||
function toggleGruppe(gid: string) {
|
||||
gruppe_ids = gruppe_ids.includes(gid)
|
||||
? gruppe_ids.filter(g => g !== gid)
|
||||
: [...gruppe_ids, gid];
|
||||
}
|
||||
|
||||
async function speichern() {
|
||||
error = '';
|
||||
saving = true;
|
||||
try {
|
||||
await pb.collection('mitglieder').update(id, {
|
||||
vorname: vorname.trim(),
|
||||
nachname: nachname.trim(),
|
||||
email: email.trim(),
|
||||
iban: iban.trim(),
|
||||
status,
|
||||
gruppe_ids
|
||||
});
|
||||
editMode = false;
|
||||
} catch (e: unknown) {
|
||||
error = e instanceof Error ? e.message : 'Fehler beim Speichern.';
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loeschen() {
|
||||
try {
|
||||
await pb.collection('mitglieder').delete(id);
|
||||
goto('/mitglieder');
|
||||
} catch (e: unknown) {
|
||||
error = e instanceof Error ? e.message : 'Fehler beim Löschen.';
|
||||
showDelete = false;
|
||||
}
|
||||
}
|
||||
|
||||
function gruppenName(ids: string[]) {
|
||||
return (ids ?? [])
|
||||
.map(gid => gruppen.find(g => g.id === gid)?.name)
|
||||
.filter(Boolean)
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
const statusFarbe: Record<string, string> = {
|
||||
aktiv: '#16a34a', passiv: '#f59e0b', ausgetreten: '#94a3b8'
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:head><title>{vorname} {nachname} — vereins.haus</title></svelte:head>
|
||||
|
||||
<div class="top">
|
||||
<a class="back" href="/mitglieder">← Mitglieder</a>
|
||||
{#if !loading}
|
||||
<button class="edit-btn" onclick={() => editMode = !editMode}>
|
||||
{editMode ? 'Abbrechen' : 'Bearbeiten'}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if loading}
|
||||
<p class="hint">Laden…</p>
|
||||
|
||||
{:else if !editMode}
|
||||
<!-- Detailansicht -->
|
||||
<div class="card">
|
||||
<div class="avatar-lg">{vorname[0]}{nachname[0]}</div>
|
||||
<h1>{vorname} {nachname}</h1>
|
||||
<span class="status-badge" style="color:{statusFarbe[status] ?? '#94a3b8'}">
|
||||
{status}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="detail-list">
|
||||
{#if email}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">E-Mail</span>
|
||||
<a href="mailto:{email}" class="detail-value link">{email}</a>
|
||||
</div>
|
||||
{/if}
|
||||
{#if iban}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">IBAN</span>
|
||||
<span class="detail-value mono">{iban}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if gruppe_ids?.length > 0}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Gruppen</span>
|
||||
<span class="detail-value">{gruppenName(gruppe_ids)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<button class="btn-delete" onclick={() => showDelete = true}>Mitglied löschen</button>
|
||||
|
||||
{:else}
|
||||
<!-- Bearbeitungsformular -->
|
||||
<form onsubmit={(e) => { e.preventDefault(); speichern(); }}>
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="vorname">Vorname *</label>
|
||||
<input id="vorname" type="text" bind:value={vorname} required />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="nachname">Nachname *</label>
|
||||
<input id="nachname" type="text" bind:value={nachname} required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" type="email" bind:value={email} />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="iban">IBAN</label>
|
||||
<input id="iban" type="text" bind:value={iban} />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="status">Status</label>
|
||||
<select id="status" bind:value={status}>
|
||||
<option value="aktiv">Aktiv</option>
|
||||
<option value="passiv">Passiv</option>
|
||||
<option value="ausgetreten">Ausgetreten</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{#if gruppen.length > 0}
|
||||
<div class="field">
|
||||
<label>Gruppen</label>
|
||||
<div class="checkboxes">
|
||||
{#each gruppen as g (g.id)}
|
||||
<label class="check-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={gruppe_ids.includes(g.id)}
|
||||
onchange={() => toggleGruppe(g.id)}
|
||||
/>
|
||||
{g.name}
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if error}
|
||||
<p class="error">{error}</p>
|
||||
{/if}
|
||||
|
||||
<button type="submit" class="btn-primary" disabled={saving || !vorname || !nachname}>
|
||||
{saving ? 'Speichern…' : 'Änderungen speichern'}
|
||||
</button>
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
<!-- Lösch-Bestätigung -->
|
||||
{#if showDelete}
|
||||
<div class="overlay" role="dialog" aria-modal="true">
|
||||
<div class="dialog">
|
||||
<p><strong>{vorname} {nachname}</strong> wirklich löschen?</p>
|
||||
<p class="dialog-sub">Diese Aktion kann nicht rückgängig gemacht werden.</p>
|
||||
<div class="dialog-actions">
|
||||
<button class="btn-ghost" onclick={() => showDelete = false}>Abbrechen</button>
|
||||
<button class="btn-danger" onclick={loeschen}>Löschen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.back { font-size: 0.9rem; color: #1e40af; text-decoration: none; }
|
||||
.edit-btn {
|
||||
background: none;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
padding: 0.4rem 0.85rem;
|
||||
font-size: 0.875rem;
|
||||
color: #475569;
|
||||
cursor: pointer;
|
||||
}
|
||||
.card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 1.5rem 1rem;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.avatar-lg {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
border-radius: 50%;
|
||||
background: #e0e7ff;
|
||||
color: #1e40af;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 700;
|
||||
font-size: 1.3rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
h1 { font-size: 1.3rem; font-weight: 700; color: #1e293b; }
|
||||
.status-badge { font-size: 0.8rem; font-weight: 600; text-transform: capitalize; }
|
||||
.detail-list {
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.detail-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.85rem 1rem;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
gap: 1rem;
|
||||
}
|
||||
.detail-row:last-child { border-bottom: none; }
|
||||
.detail-label { font-size: 0.85rem; color: #94a3b8; flex-shrink: 0; }
|
||||
.detail-value { font-size: 0.9rem; color: #1e293b; text-align: right; }
|
||||
.detail-value.link { color: #1e40af; text-decoration: none; }
|
||||
.detail-value.mono { font-family: monospace; font-size: 0.85rem; }
|
||||
.btn-delete {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
background: none;
|
||||
border: 1.5px solid #fca5a5;
|
||||
border-radius: 8px;
|
||||
color: #dc2626;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.btn-delete:hover { background: #fef2f2; }
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
||||
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
|
||||
label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
input, select {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
background: #fff;
|
||||
transition: border-color 0.15s;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
input:focus, select:focus { outline: none; border-color: #1e40af; }
|
||||
.checkboxes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
||||
.check-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
padding: 0.4rem 0.75rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 20px;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.check-label:has(input:checked) { border-color: #1e40af; background: #e0e7ff; color: #1e40af; }
|
||||
.check-label input { display: none; }
|
||||
.error { color: #dc2626; font-size: 0.875rem; margin-bottom: 0.75rem; }
|
||||
.btn-primary {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
background: #1e40af;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
margin-top: 0.5rem;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) { background: #1d3a9e; }
|
||||
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
||||
.hint { color: #94a3b8; text-align: center; margin-top: 3rem; }
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.4);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
padding: 1rem;
|
||||
padding-bottom: calc(1rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
.dialog {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
padding: 1.5rem;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
.dialog p { font-size: 1rem; color: #1e293b; margin-bottom: 0.5rem; }
|
||||
.dialog-sub { font-size: 0.875rem; color: #94a3b8; }
|
||||
.dialog-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
|
||||
.btn-ghost {
|
||||
flex: 1;
|
||||
padding: 0.75rem;
|
||||
background: none;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 0.95rem;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn-danger {
|
||||
flex: 1;
|
||||
padding: 0.75rem;
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.btn-danger:hover { background: #b91c1c; }
|
||||
</style>
|
||||
174
app/src/routes/(app)/mitglieder/neu/+page.svelte
Normal file
174
app/src/routes/(app)/mitglieder/neu/+page.svelte
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<script lang="ts">
|
||||
import { pb } from '$lib/pb';
|
||||
import { goto } from '$app/navigation';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let gruppen = $state<any[]>([]);
|
||||
let vorname = $state('');
|
||||
let nachname = $state('');
|
||||
let email = $state('');
|
||||
let iban = $state('');
|
||||
let status = $state('aktiv');
|
||||
let gruppe_ids = $state<string[]>([]);
|
||||
let error = $state('');
|
||||
let loading = $state(false);
|
||||
|
||||
onMount(async () => {
|
||||
gruppen = await pb.collection('gruppen').getFullList({ sort: 'name' });
|
||||
});
|
||||
|
||||
function toggleGruppe(id: string) {
|
||||
gruppe_ids = gruppe_ids.includes(id)
|
||||
? gruppe_ids.filter(g => g !== id)
|
||||
: [...gruppe_ids, id];
|
||||
}
|
||||
|
||||
async function speichern() {
|
||||
error = '';
|
||||
loading = true;
|
||||
try {
|
||||
const verein_id = (pb.authStore.record ?? pb.authStore.model)?.verein_id;
|
||||
await pb.collection('mitglieder').create({
|
||||
verein_id,
|
||||
vorname: vorname.trim(),
|
||||
nachname: nachname.trim(),
|
||||
email: email.trim(),
|
||||
iban: iban.trim(),
|
||||
status,
|
||||
gruppe_ids
|
||||
});
|
||||
goto('/mitglieder');
|
||||
} catch (e: unknown) {
|
||||
error = e instanceof Error ? e.message : 'Fehler beim Speichern.';
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Neues Mitglied — vereins.haus</title></svelte:head>
|
||||
|
||||
<div class="top">
|
||||
<a class="back" href="/mitglieder">← Zurück</a>
|
||||
<h1>Neues Mitglied</h1>
|
||||
</div>
|
||||
|
||||
<form onsubmit={(e) => { e.preventDefault(); speichern(); }}>
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="vorname">Vorname *</label>
|
||||
<input id="vorname" type="text" bind:value={vorname} required autocomplete="given-name" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="nachname">Nachname *</label>
|
||||
<input id="nachname" type="text" bind:value={nachname} required autocomplete="family-name" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" type="email" bind:value={email} autocomplete="email" />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="iban">IBAN</label>
|
||||
<input id="iban" type="text" bind:value={iban} placeholder="DE12 3456 7890 …" />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="status">Status</label>
|
||||
<select id="status" bind:value={status}>
|
||||
<option value="aktiv">Aktiv</option>
|
||||
<option value="passiv">Passiv</option>
|
||||
<option value="ausgetreten">Ausgetreten</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{#if gruppen.length > 0}
|
||||
<div class="field">
|
||||
<label>Gruppen</label>
|
||||
<div class="checkboxes">
|
||||
{#each gruppen as g (g.id)}
|
||||
<label class="check-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={gruppe_ids.includes(g.id)}
|
||||
onchange={() => toggleGruppe(g.id)}
|
||||
/>
|
||||
{g.name}
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if error}
|
||||
<p class="error">{error}</p>
|
||||
{/if}
|
||||
|
||||
<div class="actions">
|
||||
<a class="btn-ghost" href="/mitglieder">Abbrechen</a>
|
||||
<button type="submit" class="btn-primary" disabled={loading || !vorname || !nachname}>
|
||||
{loading ? 'Speichern…' : 'Mitglied anlegen'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.top { margin-bottom: 1.25rem; }
|
||||
.back { font-size: 0.9rem; color: #1e40af; text-decoration: none; display: block; margin-bottom: 0.5rem; }
|
||||
h1 { font-size: 1.4rem; font-weight: 700; color: #1e293b; }
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
||||
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
|
||||
label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
input, select {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
background: #fff;
|
||||
transition: border-color 0.15s;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
input:focus, select:focus { outline: none; border-color: #1e40af; }
|
||||
.checkboxes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
||||
.check-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
padding: 0.4rem 0.75rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 20px;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.check-label:has(input:checked) { border-color: #1e40af; background: #e0e7ff; color: #1e40af; }
|
||||
.check-label input { display: none; }
|
||||
.error { color: #dc2626; font-size: 0.875rem; margin-bottom: 0.75rem; }
|
||||
.actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
|
||||
.btn-primary {
|
||||
flex: 1;
|
||||
padding: 0.75rem;
|
||||
background: #1e40af;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) { background: #1d3a9e; }
|
||||
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
||||
.btn-ghost {
|
||||
padding: 0.75rem 1rem;
|
||||
background: none;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
color: #64748b;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue