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
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