QM-Startseite: Einführungstext, Hauptansprechpartner, QM-Beauftragte
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m47s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m7s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 4m3s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m56s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 3m26s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 3m34s
CI / Build-Artefakte aktuell (pull_request) Successful in 54s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m47s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m7s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 4m3s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m56s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 3m26s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 3m34s
CI / Build-Artefakte aktuell (pull_request) Successful in 54s
- Pflege unter QM-Einstellungen → „Startseite des Qualitätsmanagements“ - QM-Beauftragte mit Zuständigkeit und optionalem Ordner-Link, Kontaktangaben wie bei den Ansprechpartnern Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b3a057e27c
commit
5a360d3cc7
95 changed files with 550 additions and 373 deletions
|
|
@ -1,14 +1,19 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { FolderCog, ShieldCheck } from '@lucide/vue';
|
||||
import { FolderCog, ShieldCheck, Users } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import PageHeader from '@/components/PageHeader.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import { qmColor } from '../colors';
|
||||
import ContactCard from '../components/ContactCard.vue';
|
||||
import FolderTile from '../components/FolderTile.vue';
|
||||
import QmSearchBox from '../components/QmSearchBox.vue';
|
||||
|
||||
defineProps({
|
||||
intro: { type: String, default: '' },
|
||||
contacts: { type: Array, default: () => [] },
|
||||
officers: { type: Array, default: () => [] },
|
||||
categories: { type: Array, required: true },
|
||||
canManage: { type: Boolean, default: false },
|
||||
adminUrl: { type: String, default: null },
|
||||
|
|
@ -24,6 +29,19 @@ defineProps({
|
|||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<div v-if="intro || contacts.length" class="mb-8 grid items-start gap-6" :class="{ 'lg:grid-cols-[minmax(0,1fr)_20rem]': intro && contacts.length }">
|
||||
<section v-if="intro" class="relative overflow-hidden rounded-lg border bg-card p-5 pl-6">
|
||||
<span class="absolute inset-y-0 left-0 w-1.5 bg-brand" aria-hidden="true" />
|
||||
<div class="prose prose-sm max-w-none dark:prose-invert" v-html="intro" />
|
||||
</section>
|
||||
<aside v-if="contacts.length" class="rounded-lg border bg-card">
|
||||
<h2 class="flex items-center gap-2 border-b px-4 py-2.5 text-sm font-semibold"><Users class="size-4 text-brand-text" /> {{ contacts.length === 1 ? 'Ansprechpartner*in QM' : 'Ansprechpartner*innen QM' }}</h2>
|
||||
<div class="grid gap-4 p-4" :class="{ 'sm:grid-cols-2 lg:grid-cols-1': !intro }">
|
||||
<ContactCard v-for="contact in contacts" :key="contact.id" :contact="contact" />
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div v-if="categories.length" class="grid gap-8">
|
||||
<section v-for="category in categories" :key="category.id ?? 'rest'">
|
||||
<div class="mb-3 flex items-center gap-3">
|
||||
|
|
@ -35,7 +53,25 @@ defineProps({
|
|||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div v-else class="rounded-lg border bg-card">
|
||||
<section v-if="officers.length" class="mt-10">
|
||||
<div class="mb-3 flex items-center gap-3">
|
||||
<h2 class="text-sm font-semibold tracking-wide whitespace-nowrap text-muted-foreground uppercase">QM-Beauftragte</h2>
|
||||
<span class="h-px flex-1 bg-border" aria-hidden="true" />
|
||||
</div>
|
||||
<ul class="grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
|
||||
<li v-for="(officer, index) in officers" :key="`${officer.id}-${index}`" class="rounded-lg border bg-card p-4">
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<span v-if="officer.area" class="rounded bg-brand-soft px-2 py-0.5 text-xs font-medium text-brand-soft-foreground">{{ officer.area }}</span>
|
||||
<Link v-if="officer.folder" :href="officer.folder.url" class="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground hover:underline">
|
||||
<span class="size-2 rounded-sm" :class="qmColor(officer.folder.color).dot" />{{ officer.folder.path }}
|
||||
</Link>
|
||||
</div>
|
||||
<ContactCard :contact="officer" />
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<div v-if="!categories.length" class="rounded-lg border bg-card">
|
||||
<EmptyState :icon="ShieldCheck" title="Noch keine Ordner" :text="canManage ? 'Legen Sie Kategorien und Ordner im Admin-Bereich unter „Qualitätsmanagement“ an.' : 'Hier erscheinen bald die QM-Dokumente.'">
|
||||
<Button v-if="adminUrl" class="mt-4" as-child><a :href="adminUrl">Ordner anlegen</a></Button>
|
||||
</EmptyState>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,13 @@
|
|||
namespace Inhaus\Plugins\Qm\Filament\Pages;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use App\Support\Audit;
|
||||
use App\Support\Settings;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
|
|
@ -20,6 +23,7 @@ use Illuminate\Support\Facades\DB;
|
|||
use Illuminate\Support\HtmlString;
|
||||
use Inhaus\Plugins\Qm\Presenter;
|
||||
use Inhaus\Plugins\Qm\QmAccess;
|
||||
use Inhaus\Plugins\Qm\QmTree;
|
||||
use Inhaus\Plugins\Qm\Text\Ocr;
|
||||
use UnitEnum;
|
||||
|
||||
|
|
@ -50,6 +54,9 @@ class QmSettings extends Page
|
|||
public function mount(Settings $settings): void
|
||||
{
|
||||
$this->form->fill([
|
||||
'home_intro' => (string) $settings->get(Presenter::HOME_INTRO, ''),
|
||||
'home_contacts' => array_map('strval', (array) $settings->get(Presenter::HOME_CONTACTS, [])),
|
||||
'officers' => array_values(array_map(fn ($row) => ['user_id' => (string) ($row['user_id'] ?? ''), 'area' => $row['area'] ?? null, 'folder_id' => isset($row['folder_id']) ? (string) $row['folder_id'] : null], (array) $settings->get(Presenter::OFFICERS, []))),
|
||||
'contact_fields' => (array) $settings->get(Presenter::CONTACT_FIELDS, Presenter::DEFAULT_CONTACT_FIELDS),
|
||||
'excluded_roles' => array_map('strval', (array) $settings->get(QmAccess::EXCLUDED_ROLES, [])),
|
||||
'ocr_enabled' => (bool) $settings->get(Ocr::SETTING_ENABLED, false),
|
||||
|
|
@ -59,9 +66,33 @@ class QmSettings extends Page
|
|||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
$people = fn () => User::query()->where('is_active', true)->orderBy('last_name')->orderBy('first_name')->get()
|
||||
->mapWithKeys(fn (User $u) => [(string) $u->id => $u->name.($u->job_title ? ' – '.$u->job_title : '')])->all();
|
||||
|
||||
return $schema->statePath('data')->components([
|
||||
Section::make('Startseite des Qualitätsmanagements')
|
||||
->description('Einführungstext, Hauptansprechpartner und die Liste der QM-Beauftragten auf /qm.')
|
||||
->schema([
|
||||
RichEditor::make('home_intro')->label('Einführungstext')
|
||||
->toolbarButtons(['bold', 'italic', 'link', 'bulletList', 'orderedList', 'h3', 'blockquote', 'undo', 'redo']),
|
||||
Select::make('home_contacts')->label('Hauptansprechpartner')->multiple()->searchable()->native(false)
|
||||
->options($people)
|
||||
->helperText('Erscheinen neben dem Einführungstext – z. B. die QM-Leitung.'),
|
||||
Repeater::make('officers')->label('QM-Beauftragte')
|
||||
->addActionLabel('QM-Beauftragte*n hinzufügen')
|
||||
->reorderableWithDragAndDrop()
|
||||
->defaultItems(0)
|
||||
->columns(3)
|
||||
->schema([
|
||||
Select::make('user_id')->label('Person')->required()->searchable()->native(false)->options($people),
|
||||
TextInput::make('area')->label('Zuständigkeit')->maxLength(120)->placeholder('z. B. Pflege, Standort Nord'),
|
||||
Select::make('folder_id')->label('Ordner (optional)')->searchable()->native(false)
|
||||
->options(fn () => collect(app(QmTree::class)->options())->mapWithKeys(fn ($name, $id) => [(string) $id => $name])->all()),
|
||||
]),
|
||||
]),
|
||||
|
||||
Section::make('Ansprechpartner')
|
||||
->description('Welche Angaben aus dem Profil bei Ansprechpartnern in den QM-Ordnern erscheinen. Name und Foto werden immer gezeigt.')
|
||||
->description('Welche Angaben aus dem Profil bei Ansprechpartnern und QM-Beauftragten erscheinen. Name und Foto werden immer gezeigt.')
|
||||
->schema([
|
||||
CheckboxList::make('contact_fields')->hiddenLabel()->columns(3)
|
||||
->options(fn () => app(Presenter::class)->contactFieldOptions()),
|
||||
|
|
@ -95,6 +126,13 @@ class QmSettings extends Page
|
|||
$options = app(Presenter::class)->contactFieldOptions();
|
||||
|
||||
$settings->setMany([
|
||||
Presenter::HOME_INTRO => (string) ($data['home_intro'] ?? ''),
|
||||
Presenter::HOME_CONTACTS => array_values(array_map('intval', (array) ($data['home_contacts'] ?? []))),
|
||||
Presenter::OFFICERS => array_values(array_map(fn ($row) => [
|
||||
'user_id' => (int) $row['user_id'],
|
||||
'area' => filled($row['area'] ?? null) ? trim($row['area']) : null,
|
||||
'folder_id' => filled($row['folder_id'] ?? null) ? (int) $row['folder_id'] : null,
|
||||
], array_filter((array) ($data['officers'] ?? []), fn ($row) => filled($row['user_id'] ?? null)))),
|
||||
Presenter::CONTACT_FIELDS => array_values(array_intersect((array) $data['contact_fields'], array_keys($options))),
|
||||
QmAccess::EXCLUDED_ROLES => array_values(array_map('intval', (array) $data['excluded_roles'])),
|
||||
Ocr::SETTING_ENABLED => (bool) $data['ocr_enabled'],
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Inhaus\Plugins\Qm\Http\Controllers;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Support\Audit;
|
||||
use App\Support\RichText;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -35,7 +36,12 @@ class QmController extends Controller
|
|||
{
|
||||
$counts = $this->entryCounts();
|
||||
|
||||
$settings = app(Settings::class);
|
||||
|
||||
return Inertia::render('qm::Index', [
|
||||
'intro' => app(RichText::class)->sanitize((string) $settings->get(Presenter::HOME_INTRO, '')),
|
||||
'contacts' => $this->presenter->homeContacts($request->user()),
|
||||
'officers' => $this->presenter->officers($request->user()),
|
||||
'categories' => collect($this->tree->categories($request->user()))->map(fn (array $category) => [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@ class Presenter
|
|||
|
||||
public const DEFAULT_CONTACT_FIELDS = ['job_title', 'phone', 'email'];
|
||||
|
||||
/** QM-Startseite: Einführungstext, Hauptansprechpartner, Liste der QM-Beauftragten */
|
||||
public const HOME_INTRO = 'qm.home.intro';
|
||||
|
||||
public const HOME_CONTACTS = 'qm.home.contacts';
|
||||
|
||||
public const OFFICERS = 'qm.home.officers';
|
||||
|
||||
public function __construct(private readonly QmTree $tree, private readonly Settings $settings, private readonly ProfileFields $profileFields) {}
|
||||
|
||||
/**
|
||||
|
|
@ -142,6 +149,49 @@ class Presenter
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hauptansprechpartner der QM-Startseite (in der gespeicherten Reihenfolge).
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function homeContacts(?User $viewer): array
|
||||
{
|
||||
$ids = array_map('intval', (array) $this->settings->get(self::HOME_CONTACTS, []));
|
||||
$users = User::query()->whereIn('id', $ids ?: [0])->get()->keyBy('id');
|
||||
|
||||
return $this->contacts(array_filter(array_map(fn (int $id) => $users[$id] ?? null, $ids)), $viewer);
|
||||
}
|
||||
|
||||
/**
|
||||
* QM-Beauftragte mit Zuständigkeit und optional Ordner.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function officers(?User $viewer): array
|
||||
{
|
||||
$rows = array_values(array_filter((array) $this->settings->get(self::OFFICERS, []), fn ($row) => is_array($row) && ! empty($row['user_id'])));
|
||||
$users = User::query()->whereIn('id', array_map(fn ($row) => (int) $row['user_id'], $rows) ?: [0])->get()->keyBy('id');
|
||||
$result = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$user = $users[(int) $row['user_id']] ?? null;
|
||||
$contact = $user ? ($this->contacts([$user], $viewer)[0] ?? null) : null;
|
||||
|
||||
if (! $contact) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$folderId = (int) ($row['folder_id'] ?? 0);
|
||||
$result[] = [
|
||||
...$contact,
|
||||
'area' => filled($row['area'] ?? null) ? (string) $row['area'] : null,
|
||||
'folder' => $folderId && $this->tree->isVisible($folderId, $viewer) ? $this->folderLabel($folderId) : null,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> auswählbare Felder für die Einstellungen
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue