Ersetze die Symbolauswahl im CMS durch einen Wähler mit Raster, Gruppen und Suche
Das Feld steht in den Einstellungen aller Widgets und je Karte und Merkmal. Es trägt nur die Zeichnung des gewählten Symbols; der Katalog mit allen Zeichnungen kommt beim Öffnen in einer Anfrage (nur Redaktion und Katalogverwaltung). Mit Tastatur bedienbar. Dazu Katalog-Dokumentation, Tokens und Abnahme mit Screenshots (lokal geprüft, nicht auf luf-test). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
edca8e864c
commit
1270e2e948
21 files changed
+409
-16
No files matched your search
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Models\User;
|
||||
use App\Support\Brand\SymbolCatalog;
|
||||
use App\Support\Brand\Symbols;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* Daten für den Symbolwähler im CMS (nur Redaktion und Katalogverwaltung): der Katalog als JSON, je Symbol mit seiner
|
||||
* Zeichnung.
|
||||
*
|
||||
* Der Wähler lädt das erst beim Öffnen und einmal je Seitenaufruf. So stecken nicht 70 Zeichnungen in jeder Antwort
|
||||
* des Formulars, und es braucht keine 70 einzelnen Bildabrufe.
|
||||
*/
|
||||
class SymbolPickerController extends Controller
|
||||
{
|
||||
public function catalog(): JsonResponse
|
||||
{
|
||||
$this->authorizeStaff();
|
||||
|
||||
// Eine Antwort mit allen Zeichnungen statt eines Bildes je Symbol: ein Aufruf, keine siebzig.
|
||||
$groups = array_map(function (array $group): array {
|
||||
$group['items'] = array_map(fn (array $item): array => $item + ['svg' => (string) Symbols::symbol($item['key'])], $group['items']);
|
||||
|
||||
return $group;
|
||||
}, SymbolCatalog::groups());
|
||||
|
||||
return response()->json(['groups' => $groups])->header('Cache-Control', 'private, max-age=300');
|
||||
}
|
||||
|
||||
private function authorizeStaff(): void
|
||||
{
|
||||
$user = auth('staff')->user();
|
||||
|
||||
abort_unless(
|
||||
$user instanceof User && ($user->hasStaffRole(StaffRole::Redakteur) || $user->hasStaffRole(StaffRole::Katalogverwalter)),
|
||||
403,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user