Organigramm und Dokumente neu gestaltet
All checks were successful
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m30s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m34s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m45s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m35s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m42s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m7s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m15s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m8s
All checks were successful
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m30s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m34s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m45s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m35s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m42s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m7s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m15s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m8s
- Organigramm: grafischer Baum (Linien, Zoom, Verschieben) und Fokus-Ansicht mit Vorgesetzten, Team und direkt Unterstellten - Dokumente: Übersicht mit Bereichen und „Zuletzt aktualisiert“, sortierbare Dateiliste oder Kacheln (Wahl wird gemerkt) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4fcc41ed30
commit
ab0384ceb1
99 changed files with 1292 additions and 443 deletions
58
resources/js/components/org/OrgCard.vue
Normal file
58
resources/js/components/org/OrgCard.vue
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ChevronDown, ChevronUp, LoaderCircle, ScanSearch } from '@lucide/vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
|
||||
/**
|
||||
* Person im Organigramm. „compact“ für Mitarbeitende ohne eigenes Team.
|
||||
*/
|
||||
defineProps({
|
||||
person: { type: Object, required: true },
|
||||
compact: { type: Boolean, default: false },
|
||||
highlighted: { type: Boolean, default: false },
|
||||
open: { type: Boolean, default: false },
|
||||
loading: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
defineEmits(['toggle', 'focus']);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
:id="`person-${person.id}`"
|
||||
class="group/card relative w-60 rounded-lg border bg-card text-left shadow-xs transition-shadow hover:shadow-sm"
|
||||
:class="highlighted ? 'border-brand-400 ring-3 ring-brand-300/50' : ''"
|
||||
>
|
||||
<div class="flex items-center gap-3" :class="compact ? 'px-3 py-2' : 'px-3.5 pt-3.5 pb-3'">
|
||||
<PersonAvatar :person="person" :class="compact ? 'size-8 text-[11px]' : 'size-11'" />
|
||||
<div class="min-w-0 flex-1">
|
||||
<p v-if="person.department && !compact" class="truncate text-[10.5px] font-semibold tracking-wide text-brand-text uppercase">{{ person.department }}</p>
|
||||
<Link :href="`/personen/${person.id}`" class="block truncate text-sm leading-tight font-semibold hover:underline">{{ person.name }}</Link>
|
||||
<p class="truncate text-xs text-muted-foreground" :title="person.job_title">{{ person.job_title || '–' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="absolute top-1.5 right-1.5 grid size-7 place-items-center rounded-md text-muted-foreground opacity-0 transition-opacity group-hover/card:opacity-100 hover:bg-accent hover:text-foreground focus-visible:opacity-100"
|
||||
:title="`${person.name} in den Fokus`"
|
||||
:aria-label="`${person.name} in den Fokus`"
|
||||
@click="$emit('focus', person)"
|
||||
>
|
||||
<ScanSearch class="size-4" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="!compact && person.reports"
|
||||
type="button"
|
||||
class="flex w-full items-center justify-center gap-1.5 rounded-b-lg border-t py-1.5 text-xs font-medium hover:bg-accent"
|
||||
:class="open ? 'bg-brand-soft/60 text-brand-soft-foreground' : 'text-muted-foreground'"
|
||||
:aria-expanded="open"
|
||||
@click="$emit('toggle')"
|
||||
>
|
||||
<LoaderCircle v-if="loading" class="size-3.5 animate-spin" />
|
||||
<component :is="open ? ChevronUp : ChevronDown" v-else class="size-3.5" />
|
||||
{{ person.reports }} {{ person.reports === 1 ? 'Person' : 'Personen' }} im Team
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
219
resources/js/components/org/OrgChart.vue
Normal file
219
resources/js/components/org/OrgChart.vue
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
<script setup>
|
||||
import { nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { Maximize, Minus, Plus } from '@lucide/vue';
|
||||
import OrgChartNode from './OrgChartNode.vue';
|
||||
|
||||
/**
|
||||
* Grafisches Organigramm von oben nach unten. Die Fläche lässt sich mit der Maus
|
||||
* verschieben (oder scrollen) und zoomen.
|
||||
*/
|
||||
const props = defineProps({
|
||||
roots: { type: Array, required: true },
|
||||
teams: { type: Object, default: () => ({}) },
|
||||
path: { type: Array, default: () => [] },
|
||||
focus: { type: Number, default: null },
|
||||
});
|
||||
|
||||
defineEmits(['focus']);
|
||||
|
||||
const canvas = ref(null);
|
||||
const scale = ref(1);
|
||||
const steps = [0.5, 0.67, 0.8, 1, 1.15];
|
||||
|
||||
function zoom(direction) {
|
||||
const index = steps.findIndex((s) => s >= scale.value - 0.001);
|
||||
scale.value = steps[Math.min(steps.length - 1, Math.max(0, index + direction))];
|
||||
}
|
||||
|
||||
/** Ganzes (aufgeklapptes) Organigramm in die Breite einpassen. */
|
||||
function fit() {
|
||||
const el = canvas.value;
|
||||
if (!el) return;
|
||||
|
||||
const width = el.scrollWidth / scale.value;
|
||||
scale.value = Math.max(0.4, Math.min(1, (el.clientWidth - 32) / width));
|
||||
nextTick(() => (el.scrollLeft = (el.scrollWidth - el.clientWidth) / 2));
|
||||
}
|
||||
|
||||
// Verschieben mit gedrückter Maustaste auf freier Fläche.
|
||||
let drag = null;
|
||||
|
||||
function onPointerDown(event) {
|
||||
if (event.pointerType !== 'mouse' || event.button !== 0 || event.target.closest('a, button')) return;
|
||||
|
||||
drag = { x: event.clientX, y: event.clientY, left: canvas.value.scrollLeft, top: canvas.value.scrollTop };
|
||||
canvas.value.setPointerCapture(event.pointerId);
|
||||
}
|
||||
|
||||
function onPointerMove(event) {
|
||||
if (!drag) return;
|
||||
|
||||
canvas.value.scrollLeft = drag.left - (event.clientX - drag.x);
|
||||
canvas.value.scrollTop = drag.top - (event.clientY - drag.y);
|
||||
}
|
||||
|
||||
function onPointerUp() {
|
||||
drag = null;
|
||||
}
|
||||
|
||||
function center() {
|
||||
nextTick(() => {
|
||||
const el = canvas.value;
|
||||
// Gesuchte Person – sonst die Spitze in die Mitte.
|
||||
const target = (props.focus && document.getElementById(`person-${props.focus}`)) || (props.roots.length && document.getElementById(`person-${props.roots[0].id}`));
|
||||
|
||||
if (!el) return;
|
||||
|
||||
if (target) {
|
||||
const box = target.getBoundingClientRect();
|
||||
const frame = el.getBoundingClientRect();
|
||||
el.scrollLeft += box.left - frame.left - (frame.width - box.width) / 2;
|
||||
if (props.focus) el.scrollTop += box.top - frame.top - Math.min(120, (frame.height - box.height) / 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(center);
|
||||
watch(() => props.focus, center);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative overflow-hidden rounded-lg border bg-card">
|
||||
<div class="absolute top-3 right-3 z-10 flex items-center rounded-md border bg-card shadow-xs">
|
||||
<button type="button" class="grid size-8 place-items-center text-muted-foreground hover:text-foreground" aria-label="Verkleinern" @click="zoom(-1)"><Minus class="size-4" /></button>
|
||||
<span class="w-11 text-center text-xs text-muted-foreground tabular-nums">{{ Math.round(scale * 100) }} %</span>
|
||||
<button type="button" class="grid size-8 place-items-center text-muted-foreground hover:text-foreground" aria-label="Vergrößern" @click="zoom(1)"><Plus class="size-4" /></button>
|
||||
<span class="h-5 w-px bg-border" />
|
||||
<button type="button" class="grid size-8 place-items-center text-muted-foreground hover:text-foreground" title="Einpassen" aria-label="Einpassen" @click="fit"><Maximize class="size-4" /></button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
ref="canvas"
|
||||
class="org-canvas h-[calc(100vh-17rem)] min-h-[28rem] cursor-grab overflow-auto active:cursor-grabbing"
|
||||
@pointerdown="onPointerDown"
|
||||
@pointermove="onPointerMove"
|
||||
@pointerup="onPointerUp"
|
||||
@pointercancel="onPointerUp"
|
||||
>
|
||||
<div class="inline-block min-w-full p-10" :style="{ zoom: scale }">
|
||||
<ul class="org-tree">
|
||||
<OrgChartNode v-for="person in roots" :key="person.id" :person="person" :teams="teams" :path="path" :focus="focus" @focus="$emit('focus', $event)" />
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.org-canvas {
|
||||
background-color: color-mix(in srgb, var(--muted) 45%, var(--card));
|
||||
background-image: radial-gradient(color-mix(in srgb, var(--muted-foreground) 22%, transparent) 1px, transparent 1px);
|
||||
background-size: 18px 18px;
|
||||
}
|
||||
|
||||
/* Verbindungslinien: klassischer CSS-Baum mit Flexbox */
|
||||
.org-tree,
|
||||
.org-tree ul {
|
||||
--org-line: color-mix(in srgb, var(--muted-foreground) 45%, transparent);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.org-tree ul {
|
||||
position: relative;
|
||||
padding-top: 22px;
|
||||
}
|
||||
|
||||
.org-tree li {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 22px 10px 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.org-tree li::before,
|
||||
.org-tree li::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 50%;
|
||||
width: 50%;
|
||||
height: 22px;
|
||||
border-top: 1.5px solid var(--org-line);
|
||||
}
|
||||
|
||||
.org-tree li::after {
|
||||
right: auto;
|
||||
left: 50%;
|
||||
border-left: 1.5px solid var(--org-line);
|
||||
}
|
||||
|
||||
.org-tree li:only-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.org-tree li:only-child::before,
|
||||
.org-tree li:only-child::after,
|
||||
.org-tree > li::before,
|
||||
.org-tree > li::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.org-tree > li {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.org-tree li:first-child::before,
|
||||
.org-tree li:last-child::after {
|
||||
border: 0 none;
|
||||
}
|
||||
|
||||
.org-tree li:last-child::before {
|
||||
border-right: 1.5px solid var(--org-line);
|
||||
border-top-right-radius: 8px;
|
||||
}
|
||||
|
||||
.org-tree li:first-child::after {
|
||||
border-top-left-radius: 8px;
|
||||
}
|
||||
|
||||
.org-tree ul ul::before,
|
||||
.org-tree > li > ul::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
height: 22px;
|
||||
border-left: 1.5px solid var(--org-line);
|
||||
}
|
||||
|
||||
/* Mitarbeitende ohne eigenes Team: untereinander, mit durchgehender Linie */
|
||||
.org-members {
|
||||
position: relative;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.org-members::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 12px;
|
||||
left: 50%;
|
||||
border-left: 1.5px solid var(--org-line);
|
||||
}
|
||||
|
||||
.org-members > * {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.org-members-wide {
|
||||
grid-template-columns: repeat(2, 15rem);
|
||||
column-gap: 24px;
|
||||
}
|
||||
</style>
|
||||
61
resources/js/components/org/OrgChartNode.vue
Normal file
61
resources/js/components/org/OrgChartNode.vue
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { http } from '@/lib/http';
|
||||
import OrgCard from './OrgCard.vue';
|
||||
|
||||
/**
|
||||
* Ein Knoten im Baum. Teams laden beim Aufklappen nach; Mitarbeitende ohne
|
||||
* eigenes Team stehen platzsparend untereinander statt nebeneinander.
|
||||
*/
|
||||
const props = defineProps({
|
||||
person: { type: Object, required: true },
|
||||
teams: { type: Object, default: () => ({}) },
|
||||
path: { type: Array, default: () => [] },
|
||||
focus: { type: Number, default: null },
|
||||
});
|
||||
|
||||
defineEmits(['focus']);
|
||||
|
||||
const isOnPath = () => props.path.includes(props.person.id) && props.person.id !== props.focus;
|
||||
const team = ref(props.teams[props.person.id] ?? null);
|
||||
const open = ref(isOnPath() && team.value !== null);
|
||||
const loading = ref(false);
|
||||
|
||||
watch(() => props.teams, (teams) => {
|
||||
team.value = teams[props.person.id] ?? team.value;
|
||||
open.value = isOnPath() && team.value !== null;
|
||||
});
|
||||
|
||||
const managers = computed(() => (team.value ?? []).filter((p) => p.reports));
|
||||
const members = computed(() => (team.value ?? []).filter((p) => !p.reports));
|
||||
|
||||
async function toggle() {
|
||||
open.value = !open.value;
|
||||
|
||||
if (open.value && team.value === null) {
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
team.value = (await http.get(`/personen/organigramm/${props.person.id}/team`)).team;
|
||||
} catch {
|
||||
open.value = false;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<li>
|
||||
<OrgCard :person="person" :highlighted="person.id === focus" :open="open" :loading="loading" @toggle="toggle" @focus="$emit('focus', $event)" />
|
||||
<ul v-if="open && team?.length">
|
||||
<OrgChartNode v-for="child in managers" :key="child.id" :person="child" :teams="teams" :path="path" :focus="focus" @focus="$emit('focus', $event)" />
|
||||
<li v-if="members.length">
|
||||
<div class="org-members" :class="{ 'org-members-wide': members.length > 8 }">
|
||||
<OrgCard v-for="member in members" :key="member.id" :person="member" compact :highlighted="member.id === focus" @focus="$emit('focus', $event)" />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</template>
|
||||
121
resources/js/components/org/OrgFocus.vue
Normal file
121
resources/js/components/org/OrgFocus.vue
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { Mail, MapPin, Network, Phone, UserRound, Users } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
|
||||
/**
|
||||
* Fokus-Ansicht: eine Person groß, darüber die Kette der Vorgesetzten, daneben
|
||||
* das eigene Team, darunter die direkt unterstellten Personen.
|
||||
*/
|
||||
const props = defineProps({
|
||||
roots: { type: Array, required: true },
|
||||
teams: { type: Object, default: () => ({}) },
|
||||
path: { type: Array, default: () => [] },
|
||||
details: { type: Object, required: true },
|
||||
});
|
||||
|
||||
defineEmits(['focus', 'show-in-tree']);
|
||||
|
||||
const known = computed(() => {
|
||||
const map = new Map();
|
||||
[...props.roots, ...Object.values(props.teams).flat()].forEach((p) => map.set(p.id, p));
|
||||
|
||||
return map;
|
||||
});
|
||||
|
||||
const chain = computed(() => props.path.slice(0, -1).map((id) => known.value.get(id)).filter(Boolean));
|
||||
const manager = computed(() => chain.value.at(-1) ?? null);
|
||||
const peers = computed(() => (manager.value ? (props.teams[manager.value.id] ?? []).filter((p) => p.id !== props.details.id) : []));
|
||||
const reports = computed(() => props.teams[props.details.id] ?? []);
|
||||
const meta = computed(() => [props.details.department, props.details.location].filter(Boolean));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mx-auto grid max-w-5xl gap-6">
|
||||
<!-- Vorgesetzte -->
|
||||
<ol v-if="chain.length" class="flex flex-col items-center" aria-label="Vorgesetzte">
|
||||
<li v-for="person in chain" :key="person.id" class="flex flex-col items-center">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-72 items-center gap-3 rounded-lg border bg-card px-3 py-2 text-left shadow-xs hover:border-brand-300 hover:shadow-sm"
|
||||
@click="$emit('focus', person)"
|
||||
>
|
||||
<PersonAvatar :person="person" class="size-8 text-[11px]" />
|
||||
<span class="min-w-0">
|
||||
<span class="block truncate text-sm font-medium">{{ person.name }}</span>
|
||||
<span class="block truncate text-xs text-muted-foreground">{{ person.job_title || person.department || '–' }}</span>
|
||||
</span>
|
||||
</button>
|
||||
<span class="h-5 w-px bg-border" aria-hidden="true" />
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<!-- Person im Fokus -->
|
||||
<section class="overflow-hidden rounded-lg border bg-card shadow-sm" :class="{ '-mt-6': chain.length }">
|
||||
<div class="h-20 bg-brand" style="background-image: linear-gradient(120deg, transparent 40%, rgb(255 255 255 / 0.08))" />
|
||||
<div class="flex flex-col gap-4 px-6 pb-6 md:flex-row md:items-end md:justify-between">
|
||||
<div class="flex flex-col gap-4 sm:flex-row sm:items-end">
|
||||
<PersonAvatar :person="details" class="-mt-12 size-24 text-2xl ring-4 ring-card" />
|
||||
<div class="min-w-0 sm:pb-1">
|
||||
<h2 class="text-xl font-semibold tracking-tight">{{ details.name }}</h2>
|
||||
<p v-if="details.job_title" class="text-[15px] text-muted-foreground">{{ details.job_title }}</p>
|
||||
<p v-if="meta.length" class="mt-1 flex items-center gap-1.5 text-[13px] text-muted-foreground">
|
||||
<MapPin class="size-3.5" /> {{ meta.join(' · ') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2 md:pb-1">
|
||||
<Button variant="outline" size="sm" as-child><a :href="`mailto:${details.email}`"><Mail /> E-Mail</a></Button>
|
||||
<Button v-if="details.phone || details.mobile" variant="outline" size="sm" as-child><a :href="`tel:${details.phone || details.mobile}`"><Phone /> Anrufen</a></Button>
|
||||
<Button variant="outline" size="sm" @click="$emit('show-in-tree', details)"><Network /> Im Baum</Button>
|
||||
<Button size="sm" as-child><Link :href="`/personen/${details.id}`"><UserRound /> Profil</Link></Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="manager" class="flex flex-wrap items-center gap-x-3 gap-y-2 border-t bg-muted/30 px-6 py-3 text-[13px]">
|
||||
<span class="text-muted-foreground">Im Team von <button type="button" class="font-medium text-foreground hover:underline" @click="$emit('focus', manager)">{{ manager.name }}</button><template v-if="peers.length"> mit</template></span>
|
||||
<div v-if="peers.length" class="flex flex-wrap gap-1.5">
|
||||
<button
|
||||
v-for="peer in peers.slice(0, 12)"
|
||||
:key="peer.id"
|
||||
type="button"
|
||||
class="rounded-full ring-2 ring-transparent hover:ring-brand-300"
|
||||
:title="`${peer.name}${peer.job_title ? ' – ' + peer.job_title : ''}`"
|
||||
@click="$emit('focus', peer)"
|
||||
>
|
||||
<PersonAvatar :person="peer" class="size-7 text-[10px]" />
|
||||
</button>
|
||||
<span v-if="peers.length > 12" class="grid h-7 place-items-center rounded-full bg-muted px-2 text-xs text-muted-foreground">+{{ peers.length - 12 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Direkt unterstellt -->
|
||||
<section v-if="reports.length">
|
||||
<h3 class="mb-3 flex items-center gap-2 text-base font-semibold">
|
||||
<Users class="size-4 text-brand-text" /> Direkt unterstellt <span class="font-normal text-muted-foreground">({{ reports.length }})</span>
|
||||
</h3>
|
||||
<ul class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<li v-for="person in reports" :key="person.id">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full items-center gap-3 rounded-lg border bg-card p-3 text-left shadow-xs hover:border-brand-300 hover:shadow-sm"
|
||||
@click="$emit('focus', person)"
|
||||
>
|
||||
<PersonAvatar :person="person" class="size-11" />
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate text-sm font-semibold">{{ person.name }}</span>
|
||||
<span class="block truncate text-xs text-muted-foreground">{{ person.job_title || '–' }}</span>
|
||||
<span v-if="person.reports" class="mt-1 inline-flex items-center gap-1 text-xs font-medium text-brand-text">
|
||||
<Users class="size-3.5" /> {{ person.reports }} im Team
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<p v-else class="text-center text-sm text-muted-foreground">{{ details.name }} hat keine direkt unterstellten Personen.</p>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ChevronDown, ChevronRight, LoaderCircle, Users } from '@lucide/vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
/**
|
||||
* Eine Person im Organigramm; ihr Team lädt beim Aufklappen nach.
|
||||
*/
|
||||
const props = defineProps({
|
||||
person: { type: Object, required: true },
|
||||
teams: { type: Object, default: () => ({}) },
|
||||
path: { type: Array, default: () => [] },
|
||||
focus: { type: Number, default: null },
|
||||
});
|
||||
|
||||
const team = ref(props.teams[props.person.id] ?? null);
|
||||
const open = ref(props.path.includes(props.person.id) && props.person.id !== props.focus);
|
||||
const loading = ref(false);
|
||||
|
||||
watch(() => props.teams, (teams) => {
|
||||
team.value = teams[props.person.id] ?? team.value;
|
||||
open.value = props.path.includes(props.person.id) && props.person.id !== props.focus;
|
||||
});
|
||||
|
||||
async function toggle() {
|
||||
if (!props.person.reports) return;
|
||||
|
||||
open.value = !open.value;
|
||||
|
||||
if (open.value && team.value === null) {
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
team.value = (await http.get(`/personen/organigramm/${props.person.id}/team`)).team;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<li class="relative">
|
||||
<div
|
||||
class="flex items-center gap-3 rounded-lg border bg-card px-3 py-2.5"
|
||||
:class="person.id === focus ? 'border-brand-400 ring-2 ring-brand-300/50' : ''"
|
||||
:id="`person-${person.id}`"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-accent disabled:opacity-0"
|
||||
:disabled="!person.reports"
|
||||
:aria-expanded="open"
|
||||
:aria-label="open ? `Team von ${person.name} zuklappen` : `Team von ${person.name} aufklappen`"
|
||||
@click="toggle"
|
||||
>
|
||||
<LoaderCircle v-if="loading" class="size-4 animate-spin" />
|
||||
<ChevronDown v-else-if="open" class="size-4" />
|
||||
<ChevronRight v-else class="size-4" />
|
||||
</button>
|
||||
<PersonAvatar :person="person" class="size-10" />
|
||||
<div class="min-w-0 flex-1">
|
||||
<Link :href="`/personen/${person.id}`" class="block truncate text-sm font-semibold hover:underline">{{ person.name }}</Link>
|
||||
<p class="truncate text-[13px] text-muted-foreground">{{ [person.job_title, person.department].filter(Boolean).join(' · ') }}</p>
|
||||
</div>
|
||||
<span v-if="person.reports" class="inline-flex shrink-0 items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground" :title="`${person.reports} direkt unterstellt`">
|
||||
<Users class="size-3.5" /> {{ person.reports }}
|
||||
</span>
|
||||
</div>
|
||||
<ul v-if="open && team?.length" class="mt-2 ml-6 grid gap-2 border-l pl-4 sm:ml-8 sm:pl-6">
|
||||
<OrgNode v-for="member in team" :key="member.id" :person="member" :teams="teams" :path="path" :focus="focus" />
|
||||
</ul>
|
||||
</li>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue