Globale Live-Suche, Kontaktkarten-Personensuche, neue Beitragsansicht, Termine mit Seitenleiste, Demo-Inhalte, Plugin-Upload-Fix
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m24s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m26s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m46s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m31s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m18s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 19:07:13 +00:00
parent 9b06e65802
commit b276e1c6d0
211 changed files with 3580 additions and 1072 deletions

View file

@ -3,7 +3,7 @@
namespace Inhaus\Plugins\Qm;
use App\Models\User;
use App\Support\ProfileFields;
use App\Support\ContactCards;
use App\Support\Settings;
use Inhaus\Plugins\Qm\Models\QmEntry;
@ -15,14 +15,7 @@ class Presenter
public const CONTACT_FIELDS = 'qm.contact_fields';
/** Kernfelder des Profils, die bei Ansprechpartnern erscheinen können. */
public const CORE_FIELDS = [
'job_title' => 'Funktion',
'department' => 'Abteilung',
'location' => 'Standort',
'phone' => 'Telefon',
'mobile' => 'Mobil',
'email' => 'E-Mail-Adresse',
];
public const CORE_FIELDS = ContactCards::CORE_FIELDS;
public const DEFAULT_CONTACT_FIELDS = ['job_title', 'phone', 'email'];
@ -33,7 +26,7 @@ class Presenter
public const OFFICERS = 'qm.home.officers';
public function __construct(private readonly QmTree $tree, private readonly Settings $settings, private readonly ProfileFields $profileFields) {}
public function __construct(private readonly QmTree $tree, private readonly Settings $settings, private readonly ContactCards $cards) {}
/**
* @param array<int, int> $counts Ordner => Anzahl Einträge
@ -115,38 +108,8 @@ class Presenter
public function contacts(iterable $people, ?User $viewer): array
{
$fields = (array) $this->settings->get(self::CONTACT_FIELDS, self::DEFAULT_CONTACT_FIELDS);
$result = [];
foreach ($people as $person) {
if (! $person->is_active) {
continue;
}
$values = [];
$custom = collect($this->profileFields->visibleValues($person, $viewer))->keyBy('key');
foreach ($fields as $field) {
if (isset(self::CORE_FIELDS[$field])) {
$value = $person->{$field};
if (filled($value)) {
$values[] = ['key' => $field, 'label' => self::CORE_FIELDS[$field], 'value' => $value, 'type' => in_array($field, ['phone', 'mobile'], true) ? 'phone' : ($field === 'email' ? 'email' : 'text')];
}
} elseif (str_starts_with($field, 'custom.') && ($item = $custom->get(substr($field, 7)))) {
$values[] = ['key' => $field, 'label' => $item['label'], 'value' => $item['value'], 'type' => $item['type'] ?? 'text'];
}
}
$result[] = [
'id' => $person->id,
'name' => $person->name,
'initials' => $person->initials,
'avatar_url' => $person->avatarUrl(160),
'fields' => $values,
];
}
return $result;
return array_map(fn (array $card) => array_diff_key($card, ['subtitle' => true]), $this->cards->cards($people, $viewer, $fields));
}
/**
@ -197,7 +160,7 @@ class Presenter
*/
public function contactFieldOptions(): array
{
return self::CORE_FIELDS + collect($this->profileFields->options())->mapWithKeys(fn ($label, $key) => ['custom.'.$key => $label.' (Profilfeld)'])->all();
return $this->cards->options();
}
private function formUrl(int $id): ?string

View file

@ -4,6 +4,7 @@ namespace Inhaus\Plugins\Qm;
use App\Models\User;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use App\Support\Navigation;
use Illuminate\Support\Facades\Schedule;
@ -15,6 +16,8 @@ class QmPlugin extends Plugin
{
public function register(): void
{
$this->app->make(GlobalSearch::class)->add('qm', 'Qualitätsmanagement', 'shield-check', fn (...$args) => app(QmSearch::class)(...$args), sort: 50);
foreach ([QmTree::class, QmAccess::class, Presenter::class, Search::class, Library::class, Indexer::class, TextExtractor::class, Ocr::class] as $class) {
$this->app->singleton($class);
}

View file

@ -0,0 +1,35 @@
<?php
namespace Inhaus\Plugins\Qm;
use App\Models\User;
use App\Search\GlobalSearch;
/** Suchquelle für die globale Suche: QM-Dokumente inkl. Volltext */
class QmSearch
{
public function __construct(private readonly Search $search, private readonly Presenter $presenter, private readonly QmAccess $access) {}
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
if (! $this->access->allows($user)) {
return [];
}
return $this->search->run($search, $user)->take($limit)->map(function (array $hit) use ($search) {
$entry = $this->presenter->entry($hit['entry']);
return [
'title' => $hit['entry']->title,
'url' => $entry['open_url'] ?? $this->presenter->folderLabel($hit['entry']->folder_id)['url'],
'external' => ($entry['open_kind'] ?? null) === 'download' || ($entry['open_kind'] ?? null) === 'link',
'excerpt' => $hit['snippet'] ?? GlobalSearch::excerpt($hit['entry']->description, $search),
'meta' => collect([$this->presenter->folderLabel($hit['entry']->folder_id)['path'], $hit['entry']->version ? 'Version '.$hit['entry']->version : null])->filter()->implode(' · '),
'file' => $entry['extension'] ?? null,
];
})->values()->all();
}
}