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

- 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:
Friederich Loheide 2026-09-26 16:17:17 +00:00
parent b3a057e27c
commit 5a360d3cc7
95 changed files with 550 additions and 373 deletions

View file

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