Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 1m3s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m7s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 1m16s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 1m20s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m29s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m33s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m28s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m33s
CI / Build-Artefakte aktuell (pull_request) Failing after 52s
- Nüchterne, professionelle Optik: neutrale Flächen, Markenfarbe nur als Akzent, Inter-Schrift (lokal) - Zweizeiliger Header mit Suche, Hauptnavigation und Avatar-Menü - Startseite mit Begrüßungskarte, Schnellzugriffen und „Neu im Team“ - Personenverzeichnis mit Suche, Abteilungsfilter und Seitenaufteilung - Markenfarbe exakt übernommen, Abstufungen serverseitig in OKLCH (ColorPalette) – gemeinsam für Portal und Admin, keine Farbberechnung im Browser - Schnellzugriffe im Admin pflegbar - Filament-Avatare lokal statt über ui-avatars.com (DSGVO) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
181 lines
8 KiB
Vue
181 lines
8 KiB
Vue
<script setup>
|
|
import { ref } from 'vue';
|
|
import { router, useForm } from '@inertiajs/vue3';
|
|
import { Camera, LoaderCircle, Trash2 } from '@lucide/vue';
|
|
import { toast } from 'vue-sonner';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Input } from '@/components/ui/input';
|
|
import { Textarea } from '@/components/ui/textarea';
|
|
import FormField from '@/components/FormField.vue';
|
|
import Panel from '@/components/Panel.vue';
|
|
import PersonAvatar from '@/components/PersonAvatar.vue';
|
|
import AppLayout from '@/layouts/AppLayout.vue';
|
|
|
|
const props = defineProps({
|
|
profile: { type: Object, required: true },
|
|
});
|
|
|
|
// Stammdaten
|
|
const form = useForm({
|
|
first_name: props.profile.first_name ?? '',
|
|
last_name: props.profile.last_name ?? '',
|
|
email: props.profile.email,
|
|
job_title: props.profile.job_title ?? '',
|
|
department: props.profile.department ?? '',
|
|
location: props.profile.location ?? '',
|
|
phone: props.profile.phone ?? '',
|
|
mobile: props.profile.mobile ?? '',
|
|
about: props.profile.about ?? '',
|
|
});
|
|
|
|
function saveProfile() {
|
|
form.put('/profil', {
|
|
preserveScroll: true,
|
|
onSuccess: () => {
|
|
form.defaults();
|
|
toast.success('Profil gespeichert');
|
|
},
|
|
});
|
|
}
|
|
|
|
const fields = [
|
|
{ key: 'first_name', label: 'Vorname', autocomplete: 'given-name' },
|
|
{ key: 'last_name', label: 'Nachname', autocomplete: 'family-name' },
|
|
{ key: 'email', label: 'E-Mail-Adresse', type: 'email', autocomplete: 'email', wide: true },
|
|
{ key: 'job_title', label: 'Funktion', autocomplete: 'organization-title' },
|
|
{ key: 'department', label: 'Abteilung' },
|
|
{ key: 'location', label: 'Standort' },
|
|
{ key: 'phone', label: 'Telefon', type: 'tel', autocomplete: 'tel' },
|
|
{ key: 'mobile', label: 'Mobil', type: 'tel' },
|
|
];
|
|
|
|
// Profilbild
|
|
const avatarInput = ref(null);
|
|
const avatarForm = useForm({ avatar: null });
|
|
|
|
function uploadAvatar(event) {
|
|
const file = event.target.files?.[0];
|
|
|
|
if (!file) return;
|
|
|
|
avatarForm.avatar = file;
|
|
avatarForm.post('/profil/bild', {
|
|
preserveScroll: true,
|
|
forceFormData: true,
|
|
onSuccess: () => toast.success('Profilbild aktualisiert'),
|
|
onFinish: () => {
|
|
event.target.value = '';
|
|
},
|
|
});
|
|
}
|
|
|
|
function removeAvatar() {
|
|
router.delete('/profil/bild', {
|
|
preserveScroll: true,
|
|
onSuccess: () => toast.success('Profilbild entfernt'),
|
|
});
|
|
}
|
|
|
|
// Passwort
|
|
const passwordForm = useForm({
|
|
current_password: '',
|
|
password: '',
|
|
password_confirmation: '',
|
|
});
|
|
|
|
function savePassword() {
|
|
passwordForm.put('/user/password', {
|
|
preserveScroll: true,
|
|
errorBag: 'updatePassword',
|
|
onSuccess: () => {
|
|
passwordForm.reset();
|
|
toast.success('Passwort geändert');
|
|
},
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<AppLayout title="Profil bearbeiten">
|
|
<h1 class="mb-6 text-2xl font-semibold tracking-tight">Profil bearbeiten</h1>
|
|
|
|
<div class="grid gap-6 lg:grid-cols-12">
|
|
<div class="lg:col-span-4">
|
|
<Panel title="Profilbild">
|
|
<div class="flex flex-col items-center text-center">
|
|
<PersonAvatar :person="profile" class="size-32 text-3xl" />
|
|
<input ref="avatarInput" type="file" accept="image/jpeg,image/png,image/webp" class="hidden" @change="uploadAvatar" />
|
|
<div class="mt-5 flex flex-wrap justify-center gap-2">
|
|
<Button variant="outline" :disabled="avatarForm.processing" @click="avatarInput?.click()">
|
|
<LoaderCircle v-if="avatarForm.processing" class="animate-spin" />
|
|
<Camera v-else />
|
|
{{ profile.avatar_url ? 'Bild ändern' : 'Bild hochladen' }}
|
|
</Button>
|
|
<Button v-if="profile.avatar_url" variant="ghost" class="text-destructive hover:text-destructive" @click="removeAvatar">
|
|
<Trash2 /> Entfernen
|
|
</Button>
|
|
</div>
|
|
<p v-if="avatarForm.errors.avatar" class="mt-3 text-[13px] text-destructive">{{ avatarForm.errors.avatar }}</p>
|
|
<p class="mt-3 text-[13px] text-muted-foreground">JPG, PNG oder WebP, höchstens 8 MB. Das Bild wird quadratisch zugeschnitten.</p>
|
|
</div>
|
|
</Panel>
|
|
</div>
|
|
|
|
<div class="grid content-start gap-6 lg:col-span-8">
|
|
<Panel title="Persönliche Angaben">
|
|
<form class="grid gap-5" @submit.prevent="saveProfile">
|
|
<div class="grid gap-5 sm:grid-cols-2">
|
|
<FormField
|
|
v-for="field in fields"
|
|
:id="field.key"
|
|
:key="field.key"
|
|
:label="field.label"
|
|
:error="form.errors[field.key]"
|
|
:class="{ 'sm:col-span-2': field.wide }"
|
|
>
|
|
<Input
|
|
:id="field.key"
|
|
v-model="form[field.key]"
|
|
:type="field.type ?? 'text'"
|
|
:autocomplete="field.autocomplete"
|
|
:aria-invalid="!!form.errors[field.key]"
|
|
/>
|
|
</FormField>
|
|
<FormField id="about" label="Über mich" :error="form.errors.about" hint="Aufgaben, Themen, bei denen man Sie ansprechen kann." class="sm:col-span-2">
|
|
<Textarea id="about" v-model="form.about" rows="4" maxlength="2000" />
|
|
</FormField>
|
|
</div>
|
|
<div class="flex justify-end border-t pt-5">
|
|
<Button type="submit" :disabled="form.processing || !form.isDirty">
|
|
<LoaderCircle v-if="form.processing" class="animate-spin" />
|
|
Speichern
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</Panel>
|
|
|
|
<Panel v-if="profile.has_password" title="Passwort ändern">
|
|
<form class="grid gap-5" @submit.prevent="savePassword">
|
|
<FormField id="current_password" label="Aktuelles Passwort" :error="passwordForm.errors.current_password" class="sm:max-w-sm">
|
|
<Input id="current_password" v-model="passwordForm.current_password" type="password" autocomplete="current-password" />
|
|
</FormField>
|
|
<div class="grid gap-5 sm:grid-cols-2">
|
|
<FormField id="password" label="Neues Passwort" :error="passwordForm.errors.password" hint="Mindestens 10 Zeichen, mit Buchstaben und Ziffern.">
|
|
<Input id="password" v-model="passwordForm.password" type="password" autocomplete="new-password" />
|
|
</FormField>
|
|
<FormField id="password_confirmation" label="Neues Passwort wiederholen">
|
|
<Input id="password_confirmation" v-model="passwordForm.password_confirmation" type="password" autocomplete="new-password" />
|
|
</FormField>
|
|
</div>
|
|
<div class="flex justify-end border-t pt-5">
|
|
<Button type="submit" :disabled="passwordForm.processing">
|
|
<LoaderCircle v-if="passwordForm.processing" class="animate-spin" />
|
|
Passwort ändern
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</Panel>
|
|
</div>
|
|
</div>
|
|
</AppLayout>
|
|
</template>
|