Neues Modul Interne Stellenausschreibungen (0.28.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m1s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m42s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m37s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m43s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 10:16:48 +00:00
parent b322b97f32
commit 993d49c99c
146 changed files with 1981 additions and 305 deletions

View file

@ -0,0 +1,16 @@
<script setup>
import { Building2, CalendarClock, Clock, MapPin } from '@lucide/vue';
import { formatShortDate } from '@/lib/format';
/** Eckdaten einer Stelle als kleine Zeile mit Symbolen */
defineProps({ posting: { type: Object, required: true } });
</script>
<template>
<p class="flex flex-wrap items-center gap-x-4 gap-y-1 text-[13px] text-muted-foreground">
<span v-if="posting.department" class="inline-flex items-center gap-1.5"><Building2 class="size-3.5" /> {{ posting.department }}</span>
<span v-if="posting.location" class="inline-flex items-center gap-1.5"><MapPin class="size-3.5" /> {{ posting.location }}</span>
<span v-if="posting.summary" class="inline-flex items-center gap-1.5"><Clock class="size-3.5" /> {{ posting.summary }}</span>
<span v-if="posting.deadline" class="inline-flex items-center gap-1.5"><CalendarClock class="size-3.5" /> Bewerbung bis {{ formatShortDate(posting.deadline) }}</span>
</p>
</template>

View file

@ -0,0 +1,38 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import { Plus, Users } from '@lucide/vue';
import { Button } from '@/components/ui/button';
import Panel from '@/components/Panel.vue';
import { formatShortDate } from '@/lib/format';
defineProps({
postings: { type: Array, required: true },
canCreate: { type: Boolean, default: false },
});
const statuses = {
open: ['Offen', 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200'],
draft: ['Entwurf', 'bg-muted text-muted-foreground'],
scheduled: ['Geplant', 'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200'],
expired: ['Frist abgelaufen', 'bg-muted text-muted-foreground'],
};
</script>
<template>
<Panel title="Stellen">
<template #actions>
<Button v-if="canCreate" size="sm" variant="outline" as-child><Link href="/redaktion/stellen/neu"><Plus /> Stelle ausschreiben</Link></Button>
</template>
<ul v-if="postings.length" class="-mx-5 divide-y border-t">
<li v-for="posting in postings" :key="posting.id" class="flex items-center gap-3 px-5 py-2.5">
<div class="min-w-0 flex-1">
<Link :href="canCreate ? posting.edit_url : posting.url" class="block truncate text-sm font-medium hover:underline">{{ posting.title }}</Link>
<p class="truncate text-xs text-muted-foreground">{{ [posting.department, posting.location, posting.deadline ? `Frist ${formatShortDate(posting.deadline)}` : null].filter(Boolean).join(' · ') }}</p>
</div>
<Link :href="posting.applications_url" class="inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground hover:text-foreground" :title="`${posting.applications} Bewerbungen`"><Users class="size-3.5" /> {{ posting.applications }}</Link>
<span class="shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium" :class="statuses[posting.status][1]">{{ statuses[posting.status][0] }}</span>
</li>
</ul>
<p v-else class="text-sm text-muted-foreground">Noch keine Stellen ausgeschrieben.</p>
</Panel>
</template>

View file

@ -0,0 +1,61 @@
<script setup>
import { reactive, watch } from 'vue';
import { Link, router, usePage } from '@inertiajs/vue3';
import { Download, Mail, Users } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import EmptyState from '@/components/EmptyState.vue';
import NativeSelect from '@/components/NativeSelect.vue';
import PageHeader from '@/components/PageHeader.vue';
import PersonAvatar from '@/components/PersonAvatar.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import { formatShortDate } from '@/lib/format';
/**
* Bewerbungen auf eine Stelle – vertraulich (Ansprechperson und „Bewerbungen einsehen“).
*/
const props = defineProps({
posting: { type: Object, required: true },
applications: { type: Array, required: true },
statuses: { type: Array, required: true },
});
const page = usePage();
watch(() => page.props.flash.status, (status) => status && toast.success(status));
const edits = reactive(Object.fromEntries(props.applications.map((a) => [a.id, { status: a.status, note: a.note ?? '' }])));
function save(application) {
router.put(`/redaktion/stellen/bewerbungen/${application.id}`, edits[application.id], { preserveScroll: true });
}
</script>
<template>
<AppLayout :title="`Bewerbungen: ${posting.title}`">
<PageHeader :title="`Bewerbungen (${applications.length})`" :description="posting.title" :breadcrumbs="[{ label: 'Stellen', href: '/stellen' }, { label: posting.title, href: posting.url }]" />
<ul v-if="applications.length" class="grid gap-4">
<li v-for="application in applications" :key="application.id" class="rounded-lg border bg-card p-5">
<div class="flex flex-wrap items-start gap-4">
<PersonAvatar :person="application.person" class="size-11" />
<div class="min-w-0 flex-1">
<Link :href="`/personen/${application.person.id}`" class="font-semibold hover:underline">{{ application.person.name }}</Link>
<p class="text-[13px] text-muted-foreground">{{ [application.person.job_title, application.person.department].filter(Boolean).join(' · ') || '–' }}</p>
<p class="text-xs text-muted-foreground">Eingegangen am {{ formatShortDate(application.created_at) }}</p>
</div>
<div class="flex flex-wrap gap-2">
<Button v-if="application.file" variant="outline" size="sm" as-child><a :href="application.file.url"><Download /> {{ application.file.name }}</a></Button>
<Button variant="outline" size="sm" as-child><a :href="`mailto:${application.person.email}`"><Mail /> E-Mail</a></Button>
</div>
</div>
<p v-if="application.message" class="mt-4 rounded-md bg-muted/60 px-4 py-3 text-sm leading-relaxed break-words whitespace-pre-line">{{ application.message }}</p>
<form class="mt-4 grid gap-3 border-t pt-4 sm:grid-cols-[12rem_minmax(0,1fr)_auto] sm:items-end" @submit.prevent="save(application)">
<label class="grid gap-1 text-[13px] font-medium">Stand <NativeSelect v-model="edits[application.id].status" :options="statuses" /></label>
<label class="grid gap-1 text-[13px] font-medium">Interne Notiz <input v-model="edits[application.id].note" maxlength="5000" placeholder="nur für die Bearbeitung sichtbar" class="h-9 rounded-md border border-input bg-card px-3 text-sm font-normal focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/30" /></label>
<Button type="submit" size="sm" class="h-9">Speichern</Button>
</form>
</li>
</ul>
<div v-else class="rounded-lg border border-dashed bg-card"><EmptyState :icon="Users" title="Noch keine Bewerbungen" /></div>
</AppLayout>
</template>

View file

@ -0,0 +1,163 @@
<script setup>
import { computed, ref } from 'vue';
import { router, useForm } from '@inertiajs/vue3';
import { FileText, LoaderCircle, Save, Trash2, X } from '@lucide/vue';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import FormField from '@/components/FormField.vue';
import NativeSelect from '@/components/NativeSelect.vue';
import PageHeader from '@/components/PageHeader.vue';
import Panel from '@/components/Panel.vue';
import PersonPicker from '@/components/PersonPicker.vue';
import RichTextEditor from '@/components/RichTextEditor.vue';
import AppLayout from '@/layouts/AppLayout.vue';
/**
* Stelle ausschreiben oder bearbeiten.
*/
const props = defineProps({
posting: { type: Object, default: null },
options: { type: Object, required: true },
});
const p = props.posting;
const form = useForm({
title: p?.title ?? '',
department: p?.department ?? '',
location: p?.location ?? '',
employment: p?.employment ?? 'full',
hours: p?.hours ?? '',
contract: p?.contract ?? 'permanent',
contract_note: p?.contract_note ?? '',
pay_grade: p?.pay_grade ?? '',
start: p?.start ?? '',
deadline: p?.deadline ?? '',
description: p?.description ?? '',
apply_mode: p?.apply_mode ?? 'online',
apply_url: p?.apply_url ?? '',
contact_id: p?.contact?.id ?? null,
notify_email: p?.notify_email ?? '',
publish: !p ? 'now' : p.status === 'draft' ? 'draft' : p.status === 'scheduled' ? 'at' : 'now',
published_at: p?.published_at ?? '',
pdf: null,
remove_pdf: false,
});
const pdfInput = ref(null);
const pdfName = computed(() => form.pdf?.name ?? (form.remove_pdf ? null : p?.pdf_name));
const publishOptions = [
{ value: 'now', label: p?.status === 'open' || p?.status === 'expired' ? 'Veröffentlicht' : 'Sofort veröffentlichen' },
{ value: 'at', label: 'Zu einem Zeitpunkt' },
{ value: 'draft', label: 'Entwurf (nicht sichtbar)' },
];
function submit() {
const options = { forceFormData: true, preserveScroll: true };
p ? form.post(`/redaktion/stellen/${p.id}`, options) : form.post('/redaktion/stellen', options);
}
function remove() {
const warning = p.applications ? ` Auch die ${p.applications} Bewerbung(en) werden gelöscht.` : '';
if (window.confirm(`Stelle „${p.title}“ löschen?${warning}`)) {
router.delete(`/redaktion/stellen/${p.id}`);
}
}
</script>
<template>
<AppLayout :title="p ? `Bearbeiten: ${p.title}` : 'Stelle ausschreiben'">
<PageHeader :title="p ? 'Stelle bearbeiten' : 'Stelle ausschreiben'" :breadcrumbs="[{ label: 'Stellen', href: '/stellen' }]">
<template #actions>
<Button v-if="p" variant="ghost" class="text-destructive hover:text-destructive" @click="remove"><Trash2 /> Löschen</Button>
<Button :disabled="form.processing" @click="submit"><LoaderCircle v-if="form.processing" class="animate-spin" /><Save v-else /> Speichern</Button>
</template>
</PageHeader>
<form class="grid grid-cols-1 items-start gap-6 lg:grid-cols-[minmax(0,1fr)_22rem]" @submit.prevent="submit">
<div class="grid min-w-0 gap-6">
<Panel>
<div class="grid gap-5">
<FormField id="job-title" label="Titel der Stelle" :error="form.errors.title">
<Input id="job-title" v-model="form.title" maxlength="200" placeholder="z. B. Pflegefachkraft (m/w/d) im Nachtdienst" class="text-base" />
</FormField>
<div class="grid gap-4 sm:grid-cols-2">
<FormField id="job-dept" label="Bereich" :error="form.errors.department">
<Input id="job-dept" v-model="form.department" maxlength="150" list="job-departments" placeholder="z. B. Pflege" />
<datalist id="job-departments"><option v-for="d in options.departments" :key="d" :value="d" /></datalist>
</FormField>
<FormField id="job-location" label="Standort" :error="form.errors.location">
<Input id="job-location" v-model="form.location" maxlength="150" list="job-locations" placeholder="z. B. Haus am See" />
<datalist id="job-locations"><option v-for="l in options.locations" :key="l" :value="l" /></datalist>
</FormField>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<FormField id="job-employment" label="Umfang" :error="form.errors.employment">
<NativeSelect id="job-employment" v-model="form.employment" :options="options.employment" />
</FormField>
<FormField id="job-hours" label="Stunden (optional)" :error="form.errors.hours">
<Input id="job-hours" v-model="form.hours" maxlength="60" placeholder="z. B. 30 Std./Woche" />
</FormField>
<FormField id="job-contract" label="Vertrag" :error="form.errors.contract">
<NativeSelect id="job-contract" v-model="form.contract" :options="options.contract" />
</FormField>
<FormField v-if="form.contract === 'fixed'" id="job-contract-note" label="Befristung" :error="form.errors.contract_note">
<Input id="job-contract-note" v-model="form.contract_note" maxlength="120" placeholder="z. B. bis 31.12.2027 (Elternzeitvertretung)" />
</FormField>
<FormField id="job-pay" label="Eingruppierung (optional)" :error="form.errors.pay_grade">
<Input id="job-pay" v-model="form.pay_grade" maxlength="60" placeholder="z. B. AVR P8" />
</FormField>
<FormField id="job-start" label="Beginn (optional)" :error="form.errors.start">
<Input id="job-start" v-model="form.start" maxlength="60" placeholder="z. B. ab sofort" />
</FormField>
</div>
<FormField id="job-description" label="Beschreibung" :error="form.errors.description" hint="Zum Beispiel: Ihre Aufgaben, Ihr Profil, Wir bieten.">
<RichTextEditor v-model="form.description" bordered min-height="16rem" />
</FormField>
<FormField id="job-pdf" label="Ausschreibung als PDF (optional)" :error="form.errors.pdf">
<div class="flex flex-wrap items-center gap-2">
<input ref="pdfInput" type="file" accept=".pdf" class="hidden" @change="(form.pdf = $event.target.files?.[0] ?? null), (form.remove_pdf = false)" />
<Button type="button" variant="outline" size="sm" @click="pdfInput?.click()"><FileText /> {{ pdfName ? 'Andere Datei' : 'PDF auswählen' }}</Button>
<span v-if="pdfName" class="inline-flex min-w-0 items-center gap-1 text-[13px] text-muted-foreground">
<span class="truncate">{{ pdfName }}</span>
<button type="button" class="rounded p-0.5 hover:text-destructive" aria-label="PDF entfernen" @click="(form.pdf = null), (form.remove_pdf = true)"><X class="size-3.5" /></button>
</span>
</div>
</FormField>
</div>
</Panel>
</div>
<div class="grid gap-6">
<Panel title="Veröffentlichung">
<div class="grid gap-4">
<NativeSelect v-model="form.publish" :options="publishOptions" aria-label="Veröffentlichung" />
<FormField v-if="form.publish === 'at'" id="job-publish-at" label="Erscheint am" :error="form.errors.published_at">
<Input id="job-publish-at" v-model="form.published_at" type="datetime-local" />
</FormField>
<FormField id="job-deadline" label="Bewerbungsfrist" :error="form.errors.deadline" hint="Danach verschwindet die Stelle aus der Liste. Leer = ohne Frist.">
<Input id="job-deadline" v-model="form.deadline" type="date" />
</FormField>
<p v-if="!p || p.status !== 'open'" class="text-xs text-muted-foreground">Beim Erscheinen werden alle Mitarbeitenden einmalig benachrichtigt.</p>
</div>
</Panel>
<Panel title="Bewerbung">
<div class="grid gap-4">
<NativeSelect v-model="form.apply_mode" :options="options.apply_modes" aria-label="Art der Bewerbung" />
<FormField v-if="form.apply_mode === 'link'" id="job-apply-url" label="Link zur Bewerbung" :error="form.errors.apply_url">
<Input id="job-apply-url" v-model="form.apply_url" maxlength="1000" placeholder="https://…" />
</FormField>
<FormField id="job-contact" label="Ansprechperson" :error="form.errors.contact_id" :hint="form.apply_mode === 'online' ? 'Erhält die Bewerbungen im Portal. Ohne Ansprechperson: alle mit „Bewerbungen einsehen“.' : 'Wird bei der Stelle mit E-Mail und Telefon gezeigt.'">
<PersonPicker id="job-contact" v-model="form.contact_id" :person="p?.contact" />
</FormField>
<FormField v-if="form.apply_mode === 'online'" id="job-notify" label="Zusätzlich per E-Mail an (optional)" :error="form.errors.notify_email" hint="Nur ein Hinweis mit Link – Unterlagen bleiben im Portal.">
<Input id="job-notify" v-model="form.notify_email" type="email" maxlength="190" placeholder="z. B. personal@firma.de" />
</FormField>
</div>
</Panel>
</div>
</form>
</AppLayout>
</template>

View file

@ -0,0 +1,88 @@
<script setup>
import { computed, ref, watch } from 'vue';
import { Link, usePage } from '@inertiajs/vue3';
import { Briefcase, CircleCheck, FileUser, Plus, Search } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import EmptyState from '@/components/EmptyState.vue';
import NativeSelect from '@/components/NativeSelect.vue';
import PageHeader from '@/components/PageHeader.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import JobFacts from '../components/JobFacts.vue';
/**
* Interne Stellenausschreibungen: offene Stellen mit Filter nach Bereich, Standort und Umfang.
*/
const props = defineProps({
postings: { type: Array, required: true },
filters: { type: Object, required: true },
canManage: { type: Boolean, default: false },
myApplications: { type: Number, default: 0 },
});
const page = usePage();
watch(() => page.props.flash.status, (status) => status && toast.success(status), { immediate: true });
const query = ref('');
const department = ref(null);
const location = ref(null);
const employment = ref(null);
const normalize = (text) => String(text ?? '').toLocaleLowerCase('de-DE').normalize('NFD').replace(/[̀-ͯ]/g, '');
const list = computed(() => props.postings.filter((p) =>
(!department.value || p.department === department.value)
&& (!location.value || p.location === location.value)
&& (!employment.value || p.employment === employment.value)
&& (!query.value.trim() || normalize(`${p.title} ${p.department ?? ''} ${p.location ?? ''}`).includes(normalize(query.value.trim())))));
const filtered = computed(() => query.value || department.value || location.value || employment.value);
const isNew = (posting) => Date.now() - new Date(posting.published_at) < 7 * 86400000;
function reset() {
query.value = '';
department.value = location.value = employment.value = null;
}
</script>
<template>
<AppLayout title="Stellen">
<PageHeader title="Interne Stellen" description="Offene Stellen im Unternehmen – für Ihren nächsten Schritt.">
<template #actions>
<Button v-if="myApplications" variant="outline" class="h-10" as-child><Link href="/stellen/meine-bewerbungen"><FileUser /> Meine Bewerbungen ({{ myApplications }})</Link></Button>
<Button v-if="canManage" class="h-10" as-child><Link href="/redaktion/stellen/neu"><Plus /> Stelle ausschreiben</Link></Button>
</template>
</PageHeader>
<div v-if="postings.length" class="mb-6 grid gap-3 rounded-lg border bg-card p-3 sm:grid-cols-2 lg:grid-cols-[minmax(0,1.5fr)_repeat(3,minmax(0,1fr))]">
<div class="relative">
<Search class="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
<input v-model="query" type="search" placeholder="Stelle suchen …" aria-label="Stellen durchsuchen" class="h-9 w-full rounded-md border border-input bg-card pr-3 pl-9 text-sm shadow-xs focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none" />
</div>
<NativeSelect v-model="department" :options="filters.departments.map((d) => ({ value: d, label: d }))" placeholder="Alle Bereiche" aria-label="Bereich" />
<NativeSelect v-model="location" :options="filters.locations.map((l) => ({ value: l, label: l }))" placeholder="Alle Standorte" aria-label="Standort" />
<NativeSelect v-model="employment" :options="filters.employments" placeholder="Jeder Umfang" aria-label="Umfang" />
</div>
<ul v-if="list.length" class="grid gap-3">
<li v-for="posting in list" :key="posting.id">
<Link :href="posting.url" class="group flex items-start gap-4 rounded-lg border bg-card p-4 transition-shadow hover:shadow-md sm:p-5">
<span class="hidden size-11 shrink-0 place-items-center rounded-lg bg-brand-soft text-brand-text sm:grid"><Briefcase class="size-5" /></span>
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-center gap-2">
<h2 class="text-base font-semibold break-words group-hover:underline">{{ posting.title }}</h2>
<span v-if="isNew(posting)" class="rounded-pill bg-brand px-2 py-0.5 text-[11px] font-semibold text-brand-foreground">Neu</span>
<span v-if="posting.applied" class="inline-flex items-center gap-1 rounded-pill bg-emerald-100 px-2 py-0.5 text-[11px] font-semibold text-emerald-800 dark:bg-emerald-950 dark:text-emerald-300"><CircleCheck class="size-3" /> Beworben</span>
</div>
<JobFacts :posting="posting" class="mt-1.5" />
</div>
</Link>
</li>
</ul>
<div v-else class="rounded-lg border border-dashed bg-card">
<EmptyState :icon="Briefcase" :title="filtered ? 'Keine passende Stelle' : 'Derzeit keine offenen Stellen'" :text="filtered ? 'Mit anderen Filtern gibt es vielleicht Treffer.' : 'Neue Stellen erscheinen hier – Sie werden benachrichtigt.'">
<Button v-if="filtered" variant="outline" class="mt-4" @click="reset">Filter zurücksetzen</Button>
</EmptyState>
</div>
</AppLayout>
</template>

View file

@ -0,0 +1,37 @@
<script setup>
import { Link, router } from '@inertiajs/vue3';
import { FileUser } from '@lucide/vue';
import { Button } from '@/components/ui/button';
import EmptyState from '@/components/EmptyState.vue';
import PageHeader from '@/components/PageHeader.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import { formatShortDate } from '@/lib/format';
defineProps({ applications: { type: Array, required: true } });
const tone = { received: 'bg-muted text-muted-foreground', review: 'bg-brand-soft text-brand-soft-foreground', interview: 'bg-amber-100 text-amber-800 dark:bg-amber-950 dark:text-amber-300', closed: 'bg-muted text-muted-foreground' };
function withdraw(application) {
if (window.confirm('Bewerbung zurückziehen? Nachricht und Unterlagen werden gelöscht.')) {
router.delete(`/stellen/bewerbungen/${application.id}`, { preserveScroll: true });
}
}
</script>
<template>
<AppLayout title="Meine Bewerbungen">
<PageHeader title="Meine Bewerbungen" description="Nur Sie und die zuständigen Personen sehen diese Bewerbungen." :breadcrumbs="[{ label: 'Stellen', href: '/stellen' }]" />
<ul v-if="applications.length" class="divide-y overflow-hidden rounded-lg border bg-card">
<li v-for="application in applications" :key="application.id" class="flex flex-wrap items-center gap-x-4 gap-y-2 px-5 py-4">
<div class="min-w-0 flex-1">
<Link :href="application.posting.url" class="font-medium hover:underline">{{ application.posting.title }}</Link>
<p class="text-xs text-muted-foreground">Beworben am {{ formatShortDate(application.created_at) }}<template v-if="application.file"> · {{ application.file.name }}</template></p>
</div>
<span class="rounded-pill px-2.5 py-0.5 text-xs font-medium" :class="tone[application.status]">{{ application.status_label }}</span>
<Button v-if="application.status === 'received'" size="sm" variant="ghost" class="text-destructive hover:text-destructive" @click="withdraw(application)">Zurückziehen</Button>
</li>
</ul>
<div v-else class="rounded-lg border border-dashed bg-card"><EmptyState :icon="FileUser" title="Noch keine Bewerbungen" text="Offene Stellen finden Sie unter „Stellen“." /></div>
</AppLayout>
</template>

View file

@ -0,0 +1,148 @@
<script setup>
import { computed, ref, watch } from 'vue';
import { Link, router, useForm, usePage } from '@inertiajs/vue3';
import { ArrowLeft, CircleCheck, ExternalLink, FileText, Mail, PencilLine, Phone, Send, Users } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import FormField from '@/components/FormField.vue';
import Panel from '@/components/Panel.vue';
import PersonAvatar from '@/components/PersonAvatar.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import { formatShortDate } from '@/lib/format';
import JobFacts from '../components/JobFacts.vue';
const props = defineProps({
posting: { type: Object, required: true },
application: { type: Object, default: null },
canApply: { type: Boolean, default: false },
editUrl: { type: String, default: null },
applicationsUrl: { type: String, default: null },
applicationsCount: { type: Number, default: null },
accept: { type: String, default: '.pdf' },
});
const page = usePage();
watch(() => page.props.flash.status, (status) => status && toast.success(status), { immediate: true });
const facts = computed(() => [
['Umfang', [props.posting.employment_label, props.posting.hours].filter(Boolean).join(', ')],
['Vertrag', props.posting.contract === 'fixed' ? `Befristet${props.posting.contract_note ? ` ${props.posting.contract_note}` : ''}` : 'Unbefristet'],
['Eingruppierung', props.posting.pay_grade],
['Beginn', props.posting.start],
['Bewerbungsfrist', props.posting.deadline ? formatShortDate(props.posting.deadline) : null],
].filter(([, value]) => value));
const statusLabel = { draft: 'Entwurf – nur für die Redaktion sichtbar', scheduled: 'Geplant – noch nicht sichtbar', expired: 'Frist abgelaufen – nicht mehr in der Liste' };
// Bewerben
const applying = ref(false);
const fileInput = ref(null);
const form = useForm({ message: '', file: null });
function apply() {
form.post(`/stellen/${props.posting.id}/bewerben`, { forceFormData: true, preserveScroll: true, onSuccess: () => (applying.value = false) });
}
function withdraw() {
if (window.confirm('Bewerbung zurückziehen? Nachricht und Unterlagen werden gelöscht.')) {
router.delete(`/stellen/bewerbungen/${props.application.id}`, { preserveScroll: true });
}
}
</script>
<template>
<AppLayout :title="posting.title">
<div class="mb-5 flex flex-wrap items-center justify-between gap-3">
<Link href="/stellen" class="inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground"><ArrowLeft class="size-4" /> Alle Stellen</Link>
<div class="flex flex-wrap gap-2">
<Button v-if="applicationsUrl" variant="outline" size="sm" as-child><Link :href="applicationsUrl"><Users /> Bewerbungen ({{ applicationsCount }})</Link></Button>
<Button v-if="editUrl" variant="outline" size="sm" as-child><Link :href="editUrl"><PencilLine /> Bearbeiten</Link></Button>
</div>
</div>
<p v-if="statusLabel[posting.status]" class="mb-4 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/50 dark:text-amber-100">{{ statusLabel[posting.status] }}</p>
<div class="grid grid-cols-1 items-start gap-6 lg:grid-cols-[minmax(0,1fr)_22rem]">
<article class="min-w-0 rounded-lg border bg-card p-6 sm:p-8">
<h1 class="text-2xl leading-tight font-semibold tracking-tight break-words sm:text-3xl">{{ posting.title }}</h1>
<JobFacts :posting="posting" class="mt-3" />
<div v-if="posting.description" class="prose prose-neutral mt-6 max-w-none break-words dark:prose-invert" v-html="posting.description" />
<a v-if="posting.pdf" :href="posting.pdf.url" target="_blank" rel="noopener" class="mt-6 inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-accent">
<FileText class="size-4 text-red-600" /> Ausschreibung als PDF <span class="text-xs font-normal text-muted-foreground">{{ posting.pdf.name }}</span>
</a>
</article>
<aside class="grid gap-6">
<!-- Bewerben -->
<Panel title="Bewerbung">
<template v-if="application">
<p class="flex items-center gap-2 text-sm font-medium text-emerald-700 dark:text-emerald-400"><CircleCheck class="size-4" /> Beworben am {{ formatShortDate(application.created_at) }}</p>
<p class="mt-1 text-sm">Stand: <strong>{{ application.status_label }}</strong></p>
<Button v-if="application.status === 'received'" variant="ghost" size="sm" class="mt-3 -ml-2 text-destructive hover:text-destructive" @click="withdraw">Bewerbung zurückziehen</Button>
</template>
<template v-else-if="posting.apply_mode === 'online'">
<p class="text-sm text-muted-foreground">Bewerben Sie sich direkt hier – vertraulich an {{ posting.contact ? posting.contact.name : 'die Personalabteilung' }}.</p>
<Button class="mt-4 w-full" :disabled="!canApply" @click="applying = true"><Send /> Jetzt bewerben</Button>
<p v-if="!canApply && posting.status !== 'open'" class="mt-2 text-xs text-muted-foreground">Bewerben ist gerade nicht möglich.</p>
</template>
<template v-else-if="posting.apply_mode === 'link' && posting.apply_url">
<Button class="w-full" as-child><a :href="posting.apply_url" target="_blank" rel="noopener"><ExternalLink /> Zur Bewerbung</a></Button>
</template>
<p v-else class="text-sm text-muted-foreground">Bitte wenden Sie sich an die Ansprechperson.</p>
<div v-if="posting.contact" class="mt-5 border-t pt-4">
<p class="mb-2 text-xs font-semibold tracking-wide text-muted-foreground uppercase">Ansprechperson</p>
<Link :href="`/personen/${posting.contact.id}`" class="flex items-center gap-3 hover:underline">
<PersonAvatar :person="posting.contact" class="size-10" />
<span class="min-w-0">
<span class="block text-sm font-medium">{{ posting.contact.name }}</span>
<span v-if="posting.contact.job_title" class="block truncate text-xs text-muted-foreground">{{ posting.contact.job_title }}</span>
</span>
</Link>
<p class="mt-2 grid gap-1 text-[13px]">
<a v-if="posting.contact.email" :href="`mailto:${posting.contact.email}`" class="inline-flex items-center gap-2 text-brand-text hover:underline"><Mail class="size-3.5" /> {{ posting.contact.email }}</a>
<a v-if="posting.contact.phone" :href="`tel:${posting.contact.phone}`" class="inline-flex items-center gap-2 text-brand-text hover:underline"><Phone class="size-3.5" /> {{ posting.contact.phone }}</a>
</p>
</div>
</Panel>
<Panel v-if="facts.length" title="Auf einen Blick">
<dl class="grid gap-3 text-sm">
<div v-for="[label, value] in facts" :key="label">
<dt class="text-xs text-muted-foreground">{{ label }}</dt>
<dd>{{ value }}</dd>
</div>
</dl>
</Panel>
</aside>
</div>
<Dialog v-model:open="applying">
<DialogContent class="sm:max-w-lg">
<DialogHeader>
<DialogTitle>Bewerbung: {{ posting.title }}</DialogTitle>
<DialogDescription>Ihre Angaben aus dem Profil (Name, Funktion, Abteilung) werden mitgeschickt. Vertraulich – nur für die Ansprechperson bzw. die Personalabteilung.</DialogDescription>
</DialogHeader>
<form class="grid gap-4" @submit.prevent="apply">
<FormField id="apply-message" label="Nachricht" :error="form.errors.message" hint="Warum interessiert Sie die Stelle? Was bringen Sie mit?">
<Textarea id="apply-message" v-model="form.message" rows="6" maxlength="5000" />
</FormField>
<FormField id="apply-file" label="Unterlagen (optional)" :error="form.errors.file" hint="z. B. Lebenslauf – PDF, Word oder OpenDocument, höchstens 10 MB.">
<div class="flex items-center gap-2">
<input id="apply-file" ref="fileInput" type="file" :accept="accept" class="hidden" @change="form.file = $event.target.files?.[0] ?? null" />
<Button type="button" variant="outline" size="sm" @click="fileInput?.click()">Datei auswählen</Button>
<span class="min-w-0 truncate text-[13px] text-muted-foreground">{{ form.file?.name ?? 'Keine Datei' }}</span>
</div>
</FormField>
<DialogFooter>
<Button type="button" variant="outline" @click="applying = false">Abbrechen</Button>
<Button type="submit" :disabled="form.processing || (!form.message.trim() && !form.file)"><Send /> Bewerbung senden</Button>
</DialogFooter>
<div v-if="form.progress" class="h-1 overflow-hidden rounded-full bg-muted"><div class="h-full bg-brand" :style="{ width: `${form.progress.percentage}%` }" /></div>
</form>
</DialogContent>
</Dialog>
</AppLayout>
</template>

View file

@ -0,0 +1,20 @@
<!doctype html>
<html lang="de">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width"></head>
<body style="margin:0;background:#f4f5f7;font-family:-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:#1a1d21">
<div style="max-width:640px;margin:0 auto;padding:24px">
@php($branding = app(\App\Support\Branding::class))
<p style="margin:0 0 16px;font-size:15px;font-weight:700;color:{{ $branding->primaryColor() }}">{{ $portalName }}</p>
<div style="background:#fff;border:1px solid #e3e5e8;border-radius:8px;padding:24px">
<h1 style="margin:0 0 4px;font-size:20px">Neue Bewerbung</h1>
<p style="margin:0 0 16px;font-size:14px;color:#5f6670">{{ $posting->title }}</p>
<p style="margin:0;font-size:14px">
<strong>{{ $applicant->name }}</strong>@if ($applicant->job_title), {{ $applicant->job_title }}@endif@if ($applicant->department) ({{ $applicant->department }})@endif
hat sich auf die interne Stelle beworben.
</p>
<p style="margin:12px 0 0;font-size:14px">Nachricht und Unterlagen liegen aus Datenschutzgründen nur im Portal.</p>
<p style="margin:24px 0 0"><a href="{{ $url }}" style="display:inline-block;background:{{ $branding->primaryColor() }};color:{{ \App\Support\ColorPalette::foregroundFor($branding->primaryColor()) }};text-decoration:none;padding:10px 16px;border-radius:6px;font-size:14px">Bewerbung im Portal öffnen</a></p>
</div>
</div>
</body>
</html>