Feed in der Mitarbeiter-App (0.54.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 15m6s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 15m58s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 15m42s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 15m21s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 1h1m41s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 1h2m13s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 23m20s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 23m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 1m17s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m57s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 15m6s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 15m58s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 15m42s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 15m21s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 1h1m41s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 1h2m13s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 23m20s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 23m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 1m17s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m57s
Feed-Registry mit Anbietern (Neu im Team, Neuigkeiten, Termine, Umfragen), Schnellaktionen je nach Rechten, Nachladen über /feed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ab76b65aff
commit
8acc0cfd8b
152 changed files with 950 additions and 361 deletions
|
|
@ -12,7 +12,7 @@ defineProps({
|
|||
<template>
|
||||
<section class="rounded-lg border bg-card text-card-foreground">
|
||||
<header v-if="title || $slots.actions" class="flex items-center justify-between gap-4 px-5 pt-4 pb-3">
|
||||
<h2 class="text-base font-semibold">{{ title }}</h2>
|
||||
<h2 v-if="title" class="text-base font-semibold">{{ title }}</h2>
|
||||
<slot name="actions">
|
||||
<Link v-if="actionHref" :href="actionHref" class="inline-flex items-center gap-0.5 text-[13px] font-medium text-brand-text hover:underline">
|
||||
{{ actionLabel }}
|
||||
|
|
|
|||
68
resources/js/components/feed/FeedItem.vue
Normal file
68
resources/js/components/feed/FeedItem.vue
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { CalendarDays, Heart, MessageCircle, Vote } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
import { formatRelative } from '@/lib/format';
|
||||
|
||||
/** Ein Beitrag im Feed der Mitarbeiter-App (Neuigkeit, neue Kollegin, Termin, Umfrage, Gruppenbeitrag …) */
|
||||
const props = defineProps({
|
||||
item: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const kindIcon = computed(() => ({ event: CalendarDays, poll: Vote })[props.item.kind] ?? null);
|
||||
const internal = (url) => url?.startsWith('/');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Neu im Team: Person im Mittelpunkt -->
|
||||
<article v-if="item.kind === 'welcome'" class="flex items-center gap-5 rounded-lg border bg-card p-5">
|
||||
<Link :href="item.url" class="shrink-0"><PersonAvatar :person="item.actor" class="size-20 text-2xl" /></Link>
|
||||
<div class="grid min-w-0 flex-1 gap-1.5">
|
||||
<span class="text-xs font-bold tracking-wider text-accent2-text uppercase">{{ item.badge }}</span>
|
||||
<Link :href="item.url" class="text-lg leading-snug font-semibold hover:underline">{{ item.title }}</Link>
|
||||
<p v-if="item.text" class="text-sm text-muted-foreground">{{ item.text }}</p>
|
||||
<div v-if="item.cta" class="pt-1">
|
||||
<Button size="sm" class="rounded-pill" as-child><Link :href="item.cta.url">{{ item.cta.label }}</Link></Button>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article v-else class="overflow-hidden rounded-lg border bg-card">
|
||||
<header class="flex items-center gap-3 px-5 pt-4 pb-3">
|
||||
<PersonAvatar v-if="item.actor" :person="item.actor" class="size-10" />
|
||||
<span v-else-if="kindIcon" class="grid size-10 place-items-center rounded-full bg-brand-soft text-brand-text"><component :is="kindIcon" class="size-5" /></span>
|
||||
<div class="min-w-0 flex-1 text-sm leading-snug">
|
||||
<p>
|
||||
<Link v-if="item.actor" :href="`/personen/${item.actor.id}`" class="font-semibold hover:underline">{{ item.actor.name }}</Link>
|
||||
<span v-else class="font-semibold">{{ item.badge }}</span>
|
||||
<template v-if="item.context"> in <Link :href="item.context.url" class="font-semibold hover:underline">{{ item.context.label }}</Link></template>
|
||||
<span v-else-if="item.action" class="text-muted-foreground"> {{ item.action }}</span>
|
||||
</p>
|
||||
<p class="text-xs text-muted-foreground">{{ formatRelative(item.time) }}<template v-if="item.actor?.subtitle"> · {{ item.actor.subtitle }}</template></p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<component :is="internal(item.url) ? Link : 'a'" :href="item.url" class="block">
|
||||
<div v-if="item.title || item.text" class="grid gap-1.5 px-5 pb-4">
|
||||
<span v-if="item.badge && item.actor" class="text-xs font-bold tracking-wider text-accent2-text uppercase">{{ item.badge }}</span>
|
||||
<h3 v-if="item.title" class="text-lg leading-snug font-semibold text-balance">{{ item.title }}</h3>
|
||||
<p v-if="item.text" class="line-clamp-4 text-[15px] leading-relaxed whitespace-pre-line text-muted-foreground">{{ item.text }}</p>
|
||||
</div>
|
||||
<img v-if="item.image_url" :src="item.image_url" alt="" loading="lazy" class="max-h-[380px] w-full object-cover" />
|
||||
<div v-else-if="item.images.length" class="grid gap-0.5" :class="item.images.length > 1 ? 'grid-cols-2' : ''">
|
||||
<img v-for="(src, i) in item.images.slice(0, 4)" :key="i" :src="src" alt="" loading="lazy" class="w-full object-cover" :class="item.images.length > 1 ? 'aspect-[4/3]' : 'max-h-[380px]'" />
|
||||
</div>
|
||||
</component>
|
||||
|
||||
<footer v-if="item.stats || item.cta" class="flex items-center gap-4 border-t px-5 py-2.5 text-sm text-muted-foreground">
|
||||
<span v-if="item.stats?.likes != null" class="inline-flex items-center gap-1.5"><Heart class="size-4" /> {{ item.stats.likes }}</span>
|
||||
<span v-if="item.stats?.comments != null" class="inline-flex items-center gap-1.5"><MessageCircle class="size-4" /> {{ item.stats.comments }}</span>
|
||||
<span v-if="item.stats?.label">{{ item.stats.label }}</span>
|
||||
<Button v-if="item.cta" size="sm" variant="outline" class="ml-auto rounded-pill" as-child>
|
||||
<component :is="internal(item.cta.url) ? Link : 'a'" :href="item.cta.url">{{ item.cta.label }}</component>
|
||||
</Button>
|
||||
</footer>
|
||||
</article>
|
||||
</template>
|
||||
68
resources/js/components/feed/FeedList.vue
Normal file
68
resources/js/components/feed/FeedList.vue
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { LoaderCircle, Newspaper } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import AppIcon from '@/components/AppIcon.vue';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import FeedItem from '@/components/feed/FeedItem.vue';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
/** Feed der Mitarbeiter-App: Schnellaktionen, dann Beiträge – mit „Mehr laden“ */
|
||||
const props = defineProps({
|
||||
feed: { type: Object, default: null }, // { items, next }
|
||||
actions: { type: Array, default: () => [] },
|
||||
});
|
||||
|
||||
const items = ref(props.feed?.items ?? []);
|
||||
const next = ref(props.feed?.next ?? null);
|
||||
const loading = ref(false);
|
||||
|
||||
watch(() => props.feed, (feed) => {
|
||||
items.value = feed?.items ?? [];
|
||||
next.value = feed?.next ?? null;
|
||||
});
|
||||
|
||||
async function more() {
|
||||
if (!next.value || loading.value) return;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const page = await http.get(`/feed?vor=${encodeURIComponent(next.value)}`);
|
||||
const known = new Set(items.value.map((item) => item.id));
|
||||
items.value.push(...page.items.filter((item) => !known.has(item.id)));
|
||||
next.value = page.next;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const internal = (url) => url?.startsWith('/');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="grid gap-5" aria-label="Neues aus dem Haus">
|
||||
<div v-if="actions.length" class="grid gap-2 sm:gap-3" :class="actions.length >= 3 ? 'grid-cols-3' : 'grid-cols-2'">
|
||||
<component
|
||||
:is="internal(action.url) ? Link : 'a'"
|
||||
v-for="action in actions.slice(0, 3)"
|
||||
:key="action.url"
|
||||
:href="action.url"
|
||||
class="flex flex-col items-center gap-2 rounded-lg border bg-card px-2 py-3 text-center text-xs font-semibold hover:bg-accent sm:flex-row sm:gap-3 sm:px-4 sm:text-left sm:text-[15px]"
|
||||
>
|
||||
<span class="grid size-9 place-items-center rounded-md bg-brand-soft text-brand-text"><AppIcon :name="action.icon || 'link'" class="size-5" /></span>
|
||||
{{ action.label }}
|
||||
</component>
|
||||
</div>
|
||||
|
||||
<FeedItem v-for="item in items" :key="item.id" :item="item" />
|
||||
|
||||
<EmptyState v-if="!items.length" :icon="Newspaper" title="Noch nichts Neues" text="Sobald es Neuigkeiten, Termine oder Beiträge gibt, stehen sie hier." />
|
||||
|
||||
<div v-if="next" class="flex justify-center">
|
||||
<Button variant="outline" class="rounded-pill" :disabled="loading" @click="more">
|
||||
<LoaderCircle v-if="loading" class="animate-spin" /> Ältere Beiträge laden
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue