## Summary <!-- Kurz: Was ändert sich und warum? --> ## Spec-Driven Development (SDD) - [ ] Es gibt eine Spec unter `specs/<NNN>-<feature>/` - [ ] Enthaltene Dateien: `plan.md`, `tasks.md`, `spec.md` - [ ] Spec beschreibt Verhalten/Acceptance Criteria (nicht nur Implementation) - [ ] Wenn sich Anforderungen während der Umsetzung geändert haben: Spec/Plan/Tasks wurden aktualisiert ## Implementation - [ ] Implementierung entspricht der Spec - [ ] Edge cases / Fehlerfälle berücksichtigt - [ ] Keine unbeabsichtigten Änderungen außerhalb des Scopes ## Tests - [ ] Tests ergänzt/aktualisiert (Pest/PHPUnit) - [ ] Relevante Tests lokal ausgeführt (`./vendor/bin/sail artisan test` oder `php artisan test`) ## Migration / Config / Ops (falls relevant) - [ ] Migration(en) enthalten und getestet - [ ] Rollback bedacht (rückwärts kompatibel, sichere Migration) - [ ] Neue Env Vars dokumentiert (`.env.example` / Doku) - [ ] Queue/cron/storage Auswirkungen geprüft ## UI (Filament/Livewire) (falls relevant) - [ ] UI-Flows geprüft - [ ] Screenshots/Notizen hinzugefügt ## Notes <!-- Links, Screenshots, Follow-ups, offene Punkte --> Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #3
69 lines
2.8 KiB
PHP
69 lines
2.8 KiB
PHP
@php
|
|
// Obtain state from Filament infolist entry
|
|
$payload = $getState();
|
|
|
|
// Normalize payload to array for the JSON viewer
|
|
$payloadArray = is_string($payload) ? (json_decode($payload, true) ?? []) : ($payload ?? []);
|
|
$rawJson = json_encode($payloadArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
|
|
// Provide the small set of helpers the pepperfm json view expects
|
|
$getState = fn () => $payloadArray;
|
|
$getCharacterLimit = fn () => null;
|
|
$getAsModal = fn () => false;
|
|
$getAsDrawer = fn () => false;
|
|
$getKeyColumnLabel = fn () => 'Key';
|
|
$getValueColumnLabel = fn () => 'Value';
|
|
$getButtonConfig = fn () => (object) ['id' => 'fj-modal', 'icon' => null, 'iconColor' => null, 'alignment' => null, 'width' => null, 'closeByClickingAway' => true, 'closedByEscaping' => true, 'closedButton' => true, 'label' => null, 'tooltip' => null, 'size' => null, 'href' => null, 'tag' => null, 'color' => null];
|
|
$getModalConfig = fn () => (object) ['id' => 'fj-modal', 'icon' => null, 'iconColor' => null, 'alignment' => null, 'width' => null, 'closeByClickingAway' => true, 'closedByEscaping' => true, 'closedButton' => true];
|
|
$getRenderMode = fn () => \PepperFM\FilamentJson\Enums\RenderModeEnum::Tree;
|
|
$getInitiallyCollapsed = fn () => 1;
|
|
$getExpandAllToggle = fn () => false;
|
|
$getCopyJsonAction = fn () => false;
|
|
$getMaxDepth = fn () => 3;
|
|
$applyLimit = fn ($v) => $v;
|
|
@endphp
|
|
|
|
<div
|
|
class="space-y-2"
|
|
x-data="{
|
|
text: @js($rawJson),
|
|
async copyJson() {
|
|
try {
|
|
if (navigator.clipboard && (location.protocol === 'https:' || location.hostname === 'localhost')) {
|
|
await navigator.clipboard.writeText(this.text);
|
|
} else {
|
|
const ta = document.createElement('textarea');
|
|
ta.value = this.text;
|
|
ta.style.position = 'fixed';
|
|
ta.style.inset = '0';
|
|
document.body.appendChild(ta);
|
|
ta.focus();
|
|
ta.select();
|
|
document.execCommand('copy');
|
|
ta.remove();
|
|
}
|
|
|
|
new FilamentNotification()
|
|
.title('Copied!')
|
|
.icon('heroicon-o-clipboard-document-check')
|
|
.success()
|
|
.send();
|
|
} catch (e) {
|
|
new FilamentNotification()
|
|
.title('Copy failed!')
|
|
.danger()
|
|
.send();
|
|
}
|
|
}
|
|
}"
|
|
>
|
|
<div class="flex items-center justify-end">
|
|
<x-filament::button size="xs" color="gray" x-on:click="copyJson()">
|
|
Copy JSON
|
|
</x-filament::button>
|
|
</div>
|
|
|
|
{{-- Render pepperfm filament-json viewer --}}
|
|
@include('filament-json::json')
|
|
</div>
|