- Planungen mit Art, Status (Idee → In Arbeit → Zur Freigabe → Geplant → Erledigt), Zuständigkeit, Erscheinungstag, Frist, Notizen und Kommentaren - Monatsansicht mit Planungen, Meldungen (online/geplant/Entwurf) und Terminen; Verschieben per Ziehen & Ablegen oder im Dialog (Tastatur) - Ideenspeicher für Planungen ohne Datum - Board nach Status mit Ziehen & Ablegen, Listenansicht mit Tabelle - Filter nach Person („Nur meine“), Art und erledigten Einträgen - „Meldung daraus erstellen“ legt einen verknüpften Entwurf an - „Meine Aufgaben“ auf der Übersicht, überfällige Fristen hervorgehoben - Demo-Planungen im Seed Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
169 lines
6.4 KiB
Svelte
169 lines
6.4 KiB
Svelte
<script lang="ts">
|
|
import Plus from '@lucide/svelte/icons/plus';
|
|
import Lightbulb from '@lucide/svelte/icons/lightbulb';
|
|
import EntryChip from './EntryChip.svelte';
|
|
import { callAction } from '../actions';
|
|
import { formatLong, formatMonthYear, dayOfMonth } from '$lib/dates';
|
|
import type { CalendarEntry, TeamMember } from '$lib/editorial';
|
|
|
|
let {
|
|
days,
|
|
month,
|
|
entries,
|
|
ideas,
|
|
team,
|
|
today,
|
|
onopen,
|
|
oncreate
|
|
}: {
|
|
days: string[];
|
|
month: string;
|
|
entries: CalendarEntry[];
|
|
ideas: CalendarEntry[];
|
|
team: TeamMember[];
|
|
today: string;
|
|
onopen: (e: CalendarEntry) => void;
|
|
oncreate: (date: string) => void;
|
|
} = $props();
|
|
|
|
const WEEKDAYS = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'];
|
|
|
|
/** Einträge je Tag */
|
|
const byDay = $derived.by(() => {
|
|
const map = new Map<string, CalendarEntry[]>(days.map((d) => [d, []]));
|
|
const order = { event: 0, post: 1, plan: 2 } as const;
|
|
for (const e of entries) {
|
|
if (e.type === 'event' && e.endDate && e.endDate > e.date) {
|
|
// Schließzeiten an jedem Tag, andere mehrtägige Termine am ersten Tag und jeden Montag
|
|
days.forEach((d, i) => {
|
|
if (d < e.date || d > e.endDate) return;
|
|
if (e.closure || d === e.date || i % 7 === 0) map.get(d)!.push(e);
|
|
});
|
|
} else map.get(e.date)?.push(e);
|
|
}
|
|
for (const list of map.values()) list.sort((a, b) => order[a.type] - order[b.type]);
|
|
return map;
|
|
});
|
|
|
|
const weeks = $derived(Array.from({ length: days.length / 7 }, (_, i) => days.slice(i * 7, i * 7 + 7)));
|
|
|
|
let dropTarget = $state<string | null>(null);
|
|
|
|
function allowDrop(e: DragEvent, key: string) {
|
|
if (!e.dataTransfer?.types.includes('application/x-redaktion')) return;
|
|
e.preventDefault();
|
|
dropTarget = key;
|
|
}
|
|
|
|
async function drop(e: DragEvent, date: string) {
|
|
e.preventDefault();
|
|
dropTarget = null;
|
|
const raw = e.dataTransfer?.getData('application/x-redaktion');
|
|
if (!raw) return;
|
|
const { type, id } = JSON.parse(raw);
|
|
if (type === 'post' && !date) return;
|
|
await callAction('move', { type, id, date }, date ? `Auf ${formatLong(date)} verschoben` : 'In den Ideenspeicher gelegt');
|
|
}
|
|
</script>
|
|
|
|
<div class="grid 2xl:grid-cols-[1fr_17rem] gap-6 items-start">
|
|
<!-- Monatsraster (ab Tablet) -->
|
|
<div class="hidden md:block card overflow-hidden">
|
|
<table class="w-full table-fixed border-collapse">
|
|
<caption class="sr-only">Redaktionskalender {formatMonthYear(`${month}-01`)}</caption>
|
|
<thead>
|
|
<tr class="bg-surface-2">
|
|
{#each WEEKDAYS as w (w)}
|
|
<th scope="col" class="py-2 text-xs font-bold uppercase tracking-[0.12em] text-ink-2">
|
|
<abbr title={w} class="no-underline">{w.slice(0, 2)}</abbr>
|
|
</th>
|
|
{/each}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{#each weeks as week, wi (wi)}
|
|
<tr>
|
|
{#each week as day, di (day)}
|
|
{@const inMonth = day.startsWith(month)}
|
|
{@const isToday = day === today}
|
|
{@const list = byDay.get(day) ?? []}
|
|
<td
|
|
class="group align-top border-t border-l first:border-l-0 border-line h-36 p-1.5 transition-colors {inMonth ? '' : 'bg-surface-2/50'} {dropTarget === day ? '!bg-brand-soft outline-2 outline-dashed outline-brand -outline-offset-4' : ''} {di >= 5 && inMonth ? 'bg-surface-2/30' : ''}"
|
|
ondragover={(e) => allowDrop(e, day)}
|
|
ondragleave={() => dropTarget === day && (dropTarget = null)}
|
|
ondrop={(e) => drop(e, day)}
|
|
>
|
|
<div class="flex items-center justify-between mb-1">
|
|
<span
|
|
class="grid place-items-center size-7 rounded-full text-sm font-bold {isToday ? 'bg-accent text-white' : inMonth ? 'text-ink' : 'text-ink-3'}"
|
|
aria-current={isToday ? 'date' : undefined}
|
|
>
|
|
{dayOfMonth(day)}
|
|
</span>
|
|
<button
|
|
type="button"
|
|
class="grid place-items-center size-7 rounded-full text-ink-3 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:bg-brand hover:text-on-brand transition"
|
|
aria-label="Neue Planung am {formatLong(day)}"
|
|
onclick={() => oncreate(day)}
|
|
>
|
|
<Plus class="size-4" />
|
|
</button>
|
|
</div>
|
|
{#if list.length}
|
|
<ul class="space-y-1" aria-label="Einträge am {formatLong(day)}">
|
|
{#each list as entry (`${entry.type}-${entry.id}`)}
|
|
<li><EntryChip {entry} {team} {today} {onopen} compact /></li>
|
|
{/each}
|
|
</ul>
|
|
{/if}
|
|
</td>
|
|
{/each}
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Handy: Tagesliste des Monats -->
|
|
<ol class="md:hidden space-y-4" aria-label="Einträge {formatMonthYear(`${month}-01`)}">
|
|
{#each days.filter((d) => d.startsWith(month) && ((byDay.get(d)?.length ?? 0) > 0 || d === today)) as day (day)}
|
|
<li>
|
|
<div class="flex items-center justify-between mb-2">
|
|
<h3 class="text-sm font-bold {day === today ? 'text-accent-ink' : 'text-ink-2'}">{formatLong(day)}{day === today ? ' · heute' : ''}</h3>
|
|
<button type="button" class="btn btn-ghost btn-sm btn-icon" aria-label="Neue Planung am {formatLong(day)}" onclick={() => oncreate(day)}><Plus class="size-4" /></button>
|
|
</div>
|
|
<ul class="space-y-1.5">
|
|
{#each byDay.get(day) ?? [] as entry (`${entry.type}-${entry.id}`)}
|
|
<li><EntryChip {entry} {team} {today} {onopen} /></li>
|
|
{/each}
|
|
</ul>
|
|
</li>
|
|
{:else}
|
|
<li class="text-ink-3">In diesem Monat ist noch nichts geplant.</li>
|
|
{/each}
|
|
</ol>
|
|
|
|
<!-- Ideenspeicher: Planungen ohne Datum -->
|
|
<section
|
|
aria-labelledby="ideen"
|
|
class="card p-4 2xl:sticky 2xl:top-6 transition-colors {dropTarget === 'ideen' ? '!bg-brand-soft outline-2 outline-dashed outline-brand' : ''}"
|
|
ondragover={(e) => allowDrop(e, 'ideen')}
|
|
ondragleave={() => dropTarget === 'ideen' && (dropTarget = null)}
|
|
ondrop={(e) => drop(e, '')}
|
|
>
|
|
<div class="flex items-center justify-between mb-1">
|
|
<h2 id="ideen" class="font-bold flex items-center gap-2"><Lightbulb class="size-4 text-accent" />Ideenspeicher</h2>
|
|
<button type="button" class="btn btn-ghost btn-sm btn-icon" aria-label="Neue Idee ohne Datum" onclick={() => oncreate('')}><Plus class="size-4" /></button>
|
|
</div>
|
|
<p class="text-xs text-ink-3 mb-3">Noch ohne Datum. Zum Planen auf einen Tag ziehen oder öffnen und ein Datum wählen.</p>
|
|
{#if ideas.length}
|
|
<ul class="space-y-1.5">
|
|
{#each ideas as entry (entry.id)}
|
|
<li><EntryChip {entry} {team} {today} {onopen} /></li>
|
|
{/each}
|
|
</ul>
|
|
{:else}
|
|
<p class="text-sm text-ink-3">Keine offenen Ideen.</p>
|
|
{/if}
|
|
</section>
|
|
</div>
|