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