Compare commits

..

No commits in common. "main" and "v1.2.0" have entirely different histories.
main ... v1.2.0

8 changed files with 7 additions and 102 deletions

2
dist/assets/style-9URDqoQM.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/inhaus.json vendored
View file

@ -7,6 +7,6 @@
"widgets/Recent": "widgets/Recent.js"
},
"css": [
"assets/style-B47C9pxK.css"
"assets/style-9URDqoQM.css"
]
}

2
dist/pages/Post.js vendored
View file

@ -1 +1 @@
import{i as e,t}from"../chunks/PostCard-ClNPcHNo.js";import{Fragment as n,createBlock as r,createCommentVNode as i,createElementBlock as a,createElementVNode as o,createTextVNode as s,createVNode as c,onMounted as l,openBlock as u,renderList as d,toDisplayString as f,unref as p,withCtx as m}from"vue";import{router as h}from"@inertiajs/vue3";import{AppLayout as g,Button as _,PageHeader as v,http as y,toast as b}from"@inhaus/ui";var x={class:`ih:mx-auto ih:grid ih:max-w-4xl ih:gap-4`},S={key:0,class:`ih:rounded-md ih:border ih:border-destructive/30 ih:bg-destructive/5 ih:p-3 ih:text-sm`},C={class:`ih:flex ih:items-center ih:gap-2 ih:font-medium`},w={class:`ih:mt-1 ih:list-disc ih:pl-6 ih:text-muted-foreground`},T={__name:`Post`,props:{group:{type:Object,required:!0},post:{type:Object,required:!0},comments:{type:Array,required:!0},reactions:{type:Array,required:!0},reports:{type:Array,default:()=>[]}},setup(T){let E=T;l(()=>{(location.hash?document.querySelector(location.hash):null)?.scrollIntoView({block:`center`})});async function D(){await y.post(`/gruppen/beitraege/${E.post.id}/meldungen-erledigt`),b.success(`Meldungen erledigt`),h.reload()}return(l,y)=>(u(),r(p(g),{title:`Beitrag in ${T.group.name}`,width:`medium`},{default:m(()=>[c(p(v),{title:`Beitrag`,breadcrumbs:[{label:`Gruppen`,href:`/gruppen`},{label:T.group.name,href:T.group.url}]},null,8,[`breadcrumbs`]),o(`div`,x,[T.reports.length?(u(),a(`div`,S,[o(`p`,C,[c(p(e),{class:`ih:size-4 ih:text-destructive`}),s(` `+f(T.reports.length)+` `+f(T.reports.length===1?`Meldung`:`Meldungen`),1)]),o(`ul`,w,[(u(!0),a(n,null,d(T.reports,e=>(u(),a(`li`,{key:e.id},f(e.comment_id?`Kommentar: `:``)+f(e.reason),1))),128))]),c(p(_),{size:`sm`,variant:`outline`,class:`ih:mt-2`,onClick:D},{default:m(()=>[...y[1]||=[s(`In Ordnung – erledigt`,-1)]]),_:1})])):i(``,!0),c(t,{post:T.post,reactions:T.reactions,"full-comments":T.comments,onDeleted:y[0]||=e=>p(h).visit(T.group.url)},null,8,[`post`,`reactions`,`full-comments`])])]),_:1},8,[`title`]))}};export{T as default};
import{i as e,t}from"../chunks/PostCard-ClNPcHNo.js";import{Fragment as n,createBlock as r,createCommentVNode as i,createElementBlock as a,createElementVNode as o,createTextVNode as s,createVNode as c,onMounted as l,openBlock as u,renderList as d,toDisplayString as f,unref as p,withCtx as m}from"vue";import{router as h}from"@inertiajs/vue3";import{AppLayout as g,Button as _,PageHeader as v,http as y,toast as b}from"@inhaus/ui";var x={class:`ih:mx-auto ih:grid ih:max-w-4xl ih:gap-4`},S={key:0,class:`ih:rounded-md ih:border ih:border-destructive/30 ih:bg-destructive/5 ih:p-3 ih:text-sm`},C={class:`ih:flex ih:items-center ih:gap-2 ih:font-medium`},w={class:`ih:mt-1 ih:list-disc ih:pl-6 ih:text-muted-foreground`},T={__name:`Post`,props:{group:{type:Object,required:!0},post:{type:Object,required:!0},comments:{type:Array,required:!0},reactions:{type:Array,required:!0},reports:{type:Array,default:()=>[]}},setup(T){let E=T;l(()=>{(location.hash&&document.querySelector(location.hash))?.scrollIntoView({block:`center`})});async function D(){await y.post(`/gruppen/beitraege/${E.post.id}/meldungen-erledigt`),b.success(`Meldungen erledigt`),h.reload()}return(l,y)=>(u(),r(p(g),{title:`Beitrag in ${T.group.name}`},{default:m(()=>[c(p(v),{title:`Beitrag`,breadcrumbs:[{label:`Gruppen`,href:`/gruppen`},{label:T.group.name,href:T.group.url}]},null,8,[`breadcrumbs`]),o(`div`,x,[T.reports.length?(u(),a(`div`,S,[o(`p`,C,[c(p(e),{class:`ih:size-4 ih:text-destructive`}),s(` `+f(T.reports.length)+` `+f(T.reports.length===1?`Meldung`:`Meldungen`),1)]),o(`ul`,w,[(u(!0),a(n,null,d(T.reports,e=>(u(),a(`li`,{key:e.id},f(e.comment_id?`Kommentar: `:``)+f(e.reason),1))),128))]),c(p(_),{size:`sm`,variant:`outline`,class:`ih:mt-2`,onClick:D},{default:m(()=>[...y[1]||=[s(`In Ordnung – erledigt`,-1)]]),_:1})])):i(``,!0),c(t,{post:T.post,reactions:T.reactions,"full-comments":T.comments,onDeleted:y[0]||=e=>p(h).visit(T.group.url)},null,8,[`post`,`reactions`,`full-comments`])])]),_:1},8,[`title`]))}};export{T as default};

View file

@ -1,7 +1,7 @@
{
"slug": "gruppen",
"name": "Gruppen",
"version": "1.3.2",
"version": "1.2.0",
"description": "Diskussionsgruppen wie bei Facebook: offen, geschlossen (Beitritt auf Anfrage) oder privat (nur auf Einladung). Beiträge mit Fotos, Dateien und Umfragen, Reaktionen, Kommentare mit Antworten, Anpinnen, Melden und Moderation.",
"author": "Loheide",
"namespace": "Inhaus\\Plugins\\Gruppen\\",

View file

@ -14,7 +14,7 @@ const props = defineProps({
});
onMounted(() => {
const target = location.hash ? document.querySelector(location.hash) : null;
const target = location.hash && document.querySelector(location.hash);
target?.scrollIntoView({ block: 'center' });
});
@ -26,7 +26,7 @@ async function resolve() {
</script>
<template>
<AppLayout :title="`Beitrag in ${group.name}`" width="medium">
<AppLayout :title="`Beitrag in ${group.name}`">
<PageHeader title="Beitrag" :breadcrumbs="[{ label: 'Gruppen', href: '/gruppen' }, { label: group.name, href: group.url }]" />
<div class="ih:mx-auto ih:grid ih:max-w-4xl ih:gap-4">
<div v-if="reports.length" class="ih:rounded-md ih:border ih:border-destructive/30 ih:bg-destructive/5 ih:p-3 ih:text-sm">

View file

@ -4,15 +4,12 @@ namespace Inhaus\Plugins\Gruppen;
use App\Dashboard\Widgets;
use App\Digest\Digest;
use App\Feed\Feed;
use App\Models\User;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use App\Support\Navigation;
use App\Tasks\Tasks;
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Inhaus\Plugins\Gruppen\Models\Group;
@ -43,65 +40,6 @@ class GruppenPlugin extends Plugin
])->all();
}, sort: 45);
// Feed der Mitarbeiter-App (Inhaus ab 0.54): Beiträge aus den eigenen Gruppen
if (class_exists(Feed::class)) {
$this->app->make(Feed::class)->add('gruppen', function (User $user, ?CarbonImmutable $before, int $limit) {
// Die App lädt über die API (Token), der Browser über die Sitzung
$api = request()->is('api/*');
$ids = Member::query()->where('user_id', $user->id)->where('status', 'active')->pluck('group_id');
return Post::query()->with(['user', 'group', 'attachments'])->withCount('comments')
->addSelect([
'reactions_count' => DB::table('gruppen_reactions')->selectRaw('count(*)')->whereColumn('post_id', 'gruppen_posts.id'),
'my_reaction' => DB::table('gruppen_reactions')->select('emoji')->whereColumn('post_id', 'gruppen_posts.id')->where('user_id', $user->id)->limit(1),
])
->whereIn('group_id', $ids->all() ?: [0])
->when($before, fn ($query) => $query->where('created_at', '<', $before))
->latest('id')->limit($limit)->get()
->map(fn (Post $post) => [
'id' => 'gruppen-'.$post->id,
'kind' => 'group-post',
'time' => $post->created_at,
'actor' => Feed::person($post->user),
'context' => ['label' => $post->group->name, 'url' => route('gruppen.show', $post->group)],
'text' => (string) ($post->body ?: ($post->poll ? 'Umfrage in der Gruppe' : '')),
'images' => $post->attachments->filter->isImage()->take(4)->map(fn ($a) => route($api ? 'gruppen.app.file' : 'gruppen.file', [$a, 'thumb']))->values()->all(),
'url' => route('gruppen.post', [$post->group, $post]),
'stats' => ['likes' => (int) $post->reactions_count, 'comments' => (int) $post->comments_count],
// Herz im Feed = Reaktion ❤️ (jede eigene Reaktion zählt als „gefällt mir“)
'like' => ['liked' => $post->my_reaction !== null, 'url' => route($api ? 'gruppen.app.posts.react' : 'gruppen.posts.react', $post, absolute: false), 'mode' => 'reaction'],
]);
});
}
// Meine Aufgaben: Einladungen annehmen, Beitrittsanfragen beantworten
if (class_exists(Tasks::class)) {
$this->app->make(Tasks::class)->add('gruppen', function (User $user) {
$mine = Member::query()->with('group')->where('user_id', $user->id)->whereIn('status', ['invited', 'active'])->get();
$tasks = $mine->where('status', 'invited')->map(fn (Member $m) => [
'title' => 'Einladung in „'.$m->group->name.'“ annehmen',
'meta' => 'Gruppen',
'url' => route('gruppen.show', $m->group),
'icon' => 'users-round',
])->values()->all();
$moderated = $mine->filter(fn (Member $m) => $m->isActive() && in_array($m->role, ['admin', 'moderator'], true))->pluck('group', 'group_id');
$pending = Member::query()->whereIn('group_id', $moderated->keys()->all() ?: [0])->where('status', 'pending')
->selectRaw('group_id, count(*) as total')->groupBy('group_id')->pluck('total', 'group_id');
foreach ($pending as $groupId => $count) {
$tasks[] = [
'title' => $count === 1 ? '1 Beitrittsanfrage in „'.$moderated[$groupId]->name.'“' : $count.' Beitrittsanfragen in „'.$moderated[$groupId]->name.'“',
'meta' => 'Gruppen',
'url' => route('gruppen.show', $moderated[$groupId]).'?tab=mitglieder',
'icon' => 'user-plus',
];
}
return $tasks;
}, sort: 40);
}
// Startseite: Neues aus den eigenen Gruppen
$this->app->make(Widgets::class)->add('gruppen.feed', 'gruppen::Recent', 'aside', sort: 35, props: function (User $user) {
$ids = Member::query()->where('user_id', $user->id)->where('status', 'active')->pluck('group_id');

View file

@ -2,10 +2,8 @@
namespace Tests\Plugins\Gruppen;
use App\Feed\Feed;
use App\Models\User;
use App\Notifications\PortalNotification;
use App\Tasks\Tasks;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Notification;
@ -195,35 +193,4 @@ class GruppenTest extends TestCase
$closedPost = Post::query()->where('group_id', $closed->id)->firstOrFail();
$this->getJson("/api/v1/gruppen/beitraege/{$closedPost->id}")->assertNotFound();
}
public function test_posts_reach_the_feed_and_invitations_and_requests_become_tasks(): void
{
if (! class_exists(Feed::class)) {
$this->markTestSkipped('Inhaus ohne Feed');
}
[$ada, $bob, $eve] = User::factory()->count(3)->create()->all();
$group = $this->group($ada, 'closed');
$this->actingAs($ada)->postJson("/gruppen/{$group->slug}/beitraege", ['body' => 'Mittwoch 17 Uhr am Haupteingang?'])->assertCreated();
$feed = collect(app(Feed::class)->page($ada)['items'])->firstWhere('kind', 'group-post');
$this->assertSame('Mittwoch 17 Uhr am Haupteingang?', $feed['text']);
$this->assertSame('Laufgruppe', $feed['context']['label']);
// Herz direkt im Feed = Reaktion
$this->assertSame('reaction', $feed['like']['mode']);
$this->actingAs($ada)->postJson($feed['like']['url'], ['emoji' => '❤️'])->assertOk();
$liked = collect(app(Feed::class)->page($ada)['items'])->firstWhere('kind', 'group-post');
$this->assertTrue($liked['like']['liked']);
$this->assertSame(1, $liked['stats']['likes']);
// Nicht-Mitglieder sehen den Beitrag nicht
$this->assertNull(collect(app(Feed::class)->page($eve)['items'])->firstWhere('kind', 'group-post'));
// Einladung → Aufgabe für Bob; Beitrittsanfrage von Eve → Aufgabe für Ada
$this->actingAs($ada)->post("/gruppen/{$group->slug}/einladen", ['users' => [$bob->id]]);
$this->actingAs($eve)->post("/gruppen/{$group->slug}/beitreten");
$this->assertContains('Einladung in „Laufgruppe“ annehmen', array_column(app(Tasks::class)->forUser($bob), 'title'));
$this->assertContains('1 Beitrittsanfrage in „Laufgruppe“', array_column(app(Tasks::class)->forUser($ada), 'title'));
}
}