Profil zeigt geschriebene Beiträge, Als Person anmelden (0.27.1)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 4m47s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m40s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m51s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m1s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m45s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m36s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m21s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 4m47s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m40s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m51s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m1s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m45s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m36s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m21s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1469f50401
commit
546c94db1c
127 changed files with 643 additions and 337 deletions
37
plugins-core/news/resources/js/profile-panels/Posts.vue
Normal file
37
plugins-core/news/resources/js/profile-panels/Posts.vue
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ArrowRight } from '@lucide/vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import CategoryLabel from '../components/CategoryLabel.vue';
|
||||
import NewsImage from '../components/NewsImage.vue';
|
||||
import { formatShortDate } from '@/lib/format';
|
||||
|
||||
/**
|
||||
* Profilseite: Neuigkeiten, die die Person geschrieben hat.
|
||||
*/
|
||||
defineProps({
|
||||
total: { type: Number, required: true },
|
||||
posts: { type: Array, required: true },
|
||||
all_url: { type: String, required: true },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel :title="`Beiträge (${total})`">
|
||||
<ul class="grid gap-4 sm:grid-cols-2">
|
||||
<li v-for="post in posts" :key="post.id">
|
||||
<Link :href="`/neuigkeiten/${post.slug}`" class="group grid gap-2">
|
||||
<NewsImage :src="post.thumb_url" :alt="post.title" class="rounded-md" />
|
||||
<div class="min-w-0">
|
||||
<CategoryLabel :category="post.category" />
|
||||
<p class="mt-0.5 line-clamp-2 text-sm leading-snug font-semibold group-hover:underline">{{ post.title }}</p>
|
||||
<p class="mt-0.5 text-xs text-muted-foreground">{{ formatShortDate(post.published_at) }}</p>
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
<Link v-if="total > posts.length" :href="all_url" class="mt-4 inline-flex items-center gap-1.5 text-[13px] font-medium text-brand-text hover:underline">
|
||||
Alle {{ total }} Beiträge <ArrowRight class="size-3.5" />
|
||||
</Link>
|
||||
</Panel>
|
||||
</template>
|
||||
|
|
@ -24,6 +24,7 @@ class NewsController extends Controller
|
|||
// Mehrere Kategorien bzw. alle außer bestimmten (Link „Alle Beiträge“ der Startseite)
|
||||
$list = fn (string $param) => $categories->whereIn('slug', array_filter(explode(',', (string) $request->query($param, ''))))->values();
|
||||
$only = $category ? collect() : $list('kategorien');
|
||||
$author = $request->integer('autor') ? User::query()->find($request->integer('autor')) : null;
|
||||
$without = $category ? collect() : $list('ohne');
|
||||
|
||||
$posts = NewsPost::query()
|
||||
|
|
@ -31,6 +32,7 @@ class NewsController extends Controller
|
|||
->visibleTo($request->user())
|
||||
->with('category')
|
||||
->when($category, fn ($query) => $query->where('category_id', $category->id))
|
||||
->when($author, fn ($query) => $query->where('author_id', $author->id))
|
||||
->when($only->isNotEmpty(), fn ($query) => $query->whereIn('category_id', $only->pluck('id')))
|
||||
->when($without->isNotEmpty(), fn ($query) => $query->where(fn ($q) => $q->whereNull('category_id')->orWhereNotIn('category_id', $without->pluck('id'))))
|
||||
->latest('published_at')
|
||||
|
|
@ -42,6 +44,7 @@ class NewsController extends Controller
|
|||
'categories' => $categories->map(fn (NewsCategory $c) => ['name' => $c->name, 'slug' => $c->slug]),
|
||||
'activeCategory' => $category?->slug,
|
||||
'filter' => match (true) {
|
||||
$author !== null => 'Von: '.$author->name,
|
||||
$only->isNotEmpty() => 'Nur: '.$only->pluck('name')->implode(', '),
|
||||
$without->isNotEmpty() => 'Ohne: '.$without->pluck('name')->implode(', '),
|
||||
default => null,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,18 @@ class NewsPlugin extends Plugin
|
|||
$this->registerWidgets($this->app->make(Widgets::class));
|
||||
|
||||
// Profilseite: Kommentare der Person – nur zu Beiträgen, die die betrachtende Person sehen darf
|
||||
// Profil: Beiträge, die die Person geschrieben hat
|
||||
$this->app->make(ProfilePanels::class)->add('news.posts', 'news::Posts', 10, function (User $person, User $viewer) {
|
||||
$query = NewsPost::query()->where('author_id', $person->id)->published()->visibleTo($viewer);
|
||||
$total = (clone $query)->count();
|
||||
|
||||
return $total === 0 ? null : [
|
||||
'total' => $total,
|
||||
'posts' => NewsPostResource::collection($query->with('category')->latest('published_at')->limit(4)->get())->resolve(),
|
||||
'all_url' => '/neuigkeiten?autor='.$person->id,
|
||||
];
|
||||
});
|
||||
|
||||
$this->app->make(ProfilePanels::class)->add('news.comments', 'news::Comments', 20, function (User $person, User $viewer) {
|
||||
$query = NewsComment::query()->where('user_id', $person->id)
|
||||
->whereHas('post', fn ($post) => $post->published()->visibleTo($viewer));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue