- „Geänderte Fassung aktivieren“ übernimmt Inhaberart, Laufzeitregel, Steuerklasse und „dynamisch“ aus der aktiven Fassung. Bisher wurden sie still auf Person/dauerhaft zurückgesetzt, obwohl die Maske „vorbelegt“ sagte. Ohne aktive Fassung gilt wie bisher die Vorgabe. - Nur Such- und Filteränderungen lassen die Liste wieder oben beginnen; Eingaben in einem geöffneten Anlegedialog klappen „Weitere anzeigen“ nicht mehr zu. - Test: Kombinationen öffnen Aufbau und Redaktion aus der Liste. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96 lines
2.7 KiB
PHP
96 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Support;
|
|
|
|
use Filament\Schemas\Components\View;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Enums\Width;
|
|
use Livewire\Attributes\Url;
|
|
|
|
/**
|
|
* Kataloglisten (Lizenzartikel, Pakete, Rechteprofile, Angebote) in der gemeinsamen Bestandsliste. Die Seite liefert
|
|
* Zeilen mit 'suchtext' und 'zustand' (Liste von Zustandsschlüsseln) sowie die Zustandsoptionen.
|
|
*/
|
|
trait ListsCatalog
|
|
{
|
|
use ShowsBestand;
|
|
|
|
#[Url(as: 'suche', except: '')]
|
|
public string $suche = '';
|
|
|
|
#[Url(as: 'zustand', except: 'alle')]
|
|
public string $zustand = 'alle';
|
|
|
|
/**
|
|
* @return list<array<string, mixed>>
|
|
*/
|
|
abstract protected function catalogRows(): array;
|
|
|
|
/**
|
|
* @return array<string, string> Zustandsschlüssel => Bezeichnung, beginnend mit 'alle'
|
|
*/
|
|
abstract protected function zustandOptionen(): array;
|
|
|
|
/**
|
|
* @return array{0: string, 1: string}
|
|
*/
|
|
abstract protected function einheit(): array;
|
|
|
|
/**
|
|
* @return array{titel: string, text: string}
|
|
*/
|
|
abstract protected function leer(): array;
|
|
|
|
protected function bestandFilterEigenschaften(): array
|
|
{
|
|
return ['suche', 'zustand'];
|
|
}
|
|
|
|
protected function suchPlatzhalter(): string
|
|
{
|
|
return 'Name oder Beschreibung';
|
|
}
|
|
|
|
public function getMaxContentWidth(): Width|string|null
|
|
{
|
|
return Width::Full;
|
|
}
|
|
|
|
public function content(Schema $schema): Schema
|
|
{
|
|
return $schema->components([View::make('filament.verwaltung.bestand')]);
|
|
}
|
|
|
|
public function resetFilters(): void
|
|
{
|
|
$this->suche = '';
|
|
$this->zustand = 'alle';
|
|
$this->bestandGrenze = Bestand::SCHRITT;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function bestand(): array
|
|
{
|
|
$needle = mb_strtolower(trim($this->suche));
|
|
$rows = array_values(array_filter($this->catalogRows(), function (array $row) use ($needle): bool {
|
|
if ($this->zustand !== 'alle' && ! in_array($this->zustand, $row['zustand'] ?? [], true)) {
|
|
return false;
|
|
}
|
|
|
|
return $needle === '' || str_contains(mb_strtolower(implode(' ', array_filter([
|
|
$row['titel'], $row['meta'] ?? '', $row['text'] ?? '', $row['suchtext'] ?? '',
|
|
]))), $needle);
|
|
}));
|
|
|
|
return [
|
|
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => $this->suchPlatzhalter()],
|
|
'filter' => [['eigenschaft' => 'zustand', 'label' => 'Zustand', 'vorgabe' => 'alle', 'optionen' => $this->zustandOptionen()]],
|
|
'zeilen' => $rows,
|
|
'einheit' => $this->einheit(),
|
|
'leer' => $this->leer(),
|
|
];
|
|
}
|
|
}
|