Meine Aufgaben (0.53.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 7m6s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 13s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 7m24s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 8m34s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 9m51s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 10m39s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m4s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m9s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m42s

Tasks-Registry mit Anbietern aus QM, Umfragen und Redaktion; Kachel auf der
Startseite und Seite /aufgaben.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-29 19:42:53 +00:00
parent 63f50f691a
commit c11cf4e0c4
146 changed files with 731 additions and 353 deletions

View file

@ -6,6 +6,7 @@ use App\Http\Resources\PersonResource;
use App\Models\User;
use App\Plugins\Hooks;
use App\Support\QuickLinks;
use App\Tasks\Tasks;
/**
* Kacheln des Kerns. Plugins ergänzen weitere über App\Dashboard\Widgets.
@ -25,6 +26,13 @@ class CoreWidgets
'actions' => array_values(array_filter((array) Hooks::apply('greeting.actions', [], $user), fn ($action) => is_array($action) && isset($action['label'], $action['href']))),
], label: 'Begrüßung mit Profil', mobileSort: 0);
// Meine Aufgaben: was jetzt wartet (Lesebestätigungen, Umfragen, Freigaben …)
$widgets->add('core.tasks', 'core::Tasks', 'aside', sort: 5, props: function (User $user) {
$tasks = app(Tasks::class)->forUser($user);
return $tasks === [] ? null : ['tasks' => array_slice($tasks, 0, 6), 'total' => count($tasks)];
}, label: 'Meine Aufgaben', mobileSort: 5, areas: ['aside', 'main']);
$widgets->add('core.quick-links', 'core::QuickLinks', 'main', sort: 10, props: function (User $user) {
$links = app(QuickLinks::class)->forUser($user);

View file

@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers;
use App\Tasks\Tasks;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class TasksController extends Controller
{
/** „Meine Aufgaben“: alles, was gerade auf die Person wartet */
public function __invoke(Request $request, Tasks $tasks): Response
{
return Inertia::render('Tasks/Index', [
'tasks' => $tasks->forUser($request->user()),
]);
}
}

View file

@ -41,6 +41,7 @@ use App\Support\Theme\ThemeCompiler;
use App\Support\Update\InstalledVersion;
use App\Support\Update\MaintenanceFlag;
use App\Support\Update\UpdateProgress;
use App\Tasks\Tasks;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
@ -74,6 +75,7 @@ class AppServiceProvider extends ServiceProvider
$this->app->singleton(ThemeCompiler::class);
$this->app->singleton(Avatars::class);
$this->app->singleton(QuickLinks::class);
$this->app->singleton(Tasks::class);
$this->app->singleton(PluginAccess::class);
$this->app->singleton(GlobalSearch::class);
$this->app->singleton(LicenseStore::class);

104
app/Tasks/Tasks.php Normal file
View file

@ -0,0 +1,104 @@
<?php
namespace App\Tasks;
use App\Editorial\Editorial;
use App\Models\User;
use App\Plugins\PluginAccess;
use App\Support\Icons;
use App\Support\Navigation;
use Carbon\CarbonImmutable;
use Closure;
use Illuminate\Support\Facades\Log;
use Throwable;
/**
* „Meine Aufgaben“: was jetzt auf eine Person wartet – an einer Stelle gesammelt.
* Kern und Plugins melden ihre offenen Punkte an:
*
* app(Tasks::class)->add('qm', fn (User $user) => [
* ['title' => '„Urlaubsregelung“ lesen und bestätigen', 'url' => '/qm/lesen/12',
* 'meta' => 'Qualitätsmanagement', 'icon' => 'shield-check', 'due' => '2026-10-02'],
* ]);
*
* Nur, was Handlung braucht (bestätigen, abstimmen, freigeben, annehmen) – keine Hinweise.
* Gesperrte Plugins (Administration → Plugins → „Zugang“) liefern nichts; Fehler eines
* Anbieters legen die Liste nicht lahm.
*/
class Tasks
{
/** @var array<string, array{sort: int, items: Closure}> */
private array $providers = [];
public function __construct()
{
// Redaktion: Freigaben und Anfragen, die in einem Bereich warten
$this->add('editorial', function (User $user) {
return collect(app(Editorial::class)->menu($user))
->filter(fn (array $section) => $section['todo'] !== null)
->map(fn (array $section) => [
// Die Texte sind für „3 warten auf Freigabe“ gedacht
'title' => $section['todo']['count'].' '.$section['todo']['label'],
'meta' => 'Redaktion · '.$section['label'],
'url' => '/redaktion?bereich='.$section['key'],
'icon' => $section['icon'],
])->values()->all();
}, sort: 90);
}
/**
* @param Closure(User): iterable<array{title: string, url: string, meta?: string, icon?: string, due?: string|null, count?: int}> $items
*/
public function add(string $key, Closure $items, int $sort = 50): void
{
$this->providers[$key] = ['sort' => $sort, 'items' => $items];
}
public function remove(string $key): void
{
unset($this->providers[$key]);
}
/**
* @return list<array{key: string, title: string, url: string, meta: string, icon: string, due: string|null, overdue: bool, count: int|null}>
*/
public function forUser(User $user): array
{
$access = app(PluginAccess::class);
$today = CarbonImmutable::today();
$tasks = [];
foreach (collect($this->providers)->sortBy('sort') as $key => $provider) {
if ($key !== 'editorial' && ! $access->allows($key, $user)) {
continue;
}
try {
foreach (($provider['items'])($user) as $item) {
if (! is_array($item) || blank($item['title'] ?? null) || blank($item['url'] ?? null)) {
continue;
}
$due = filled($item['due'] ?? null) ? CarbonImmutable::parse($item['due'])->startOfDay() : null;
$tasks[] = [
'key' => $key,
'title' => (string) $item['title'],
'url' => (string) $item['url'],
'meta' => (string) ($item['meta'] ?? ''),
'icon' => Icons::has($item['icon'] ?? null) ? $item['icon'] : (Navigation::DEFAULT_ICONS[explode('.', $key)[0]] ?? 'circle-check'),
'due' => $due?->toDateString(),
'overdue' => $due !== null && $due->lt($today),
'count' => isset($item['count']) ? (int) $item['count'] : null,
];
}
} catch (Throwable $e) {
Log::error("Aufgaben aus {$key}: ".$e->getMessage(), ['exception' => $e]);
}
}
// Fällige zuerst (nach Datum), dann der Rest in der Reihenfolge der Anbieter
return collect($tasks)
->sortBy(fn (array $task, int $index) => [$task['due'] === null ? 1 : 0, $task['due'] ?? '', $index])
->values()->all();
}
}

View file

@ -9,5 +9,5 @@ namespace App;
*/
final class Version
{
public const VERSION = '0.52.0';
public const VERSION = '0.53.0';
}