feat(settings): namenseinblender macro + default image settings

This commit is contained in:
Thorsten Bus 2026-05-31 00:04:49 +02:00
parent 7de25b7423
commit 38e79553eb
4 changed files with 96 additions and 0 deletions

View file

@ -43,3 +43,11 @@ ## [2026-05-30] Task: T3
- `Service` accessors use `Attribute::get(fn () => $this->... ? '/storage/'.$this->... : null)` for `keyVisualUrl` and `backgroundUrl`
- Added all 4 new fields to `Service::$fillable` so `fill()`/`save()` persists them
- Full suite green after fresh migrate: `ddev exec php artisan test` → 510 passed
## [2026-05-30] Task: T4
- Setting keys added to `SettingsController::AGENDA_KEYS` constant (single source for both index() props and update() Rule::in validation): `current_key_visual`, `current_background`, `namenseinblender_macro_name`, `namenseinblender_macro_uuid`, `namenseinblender_macro_collection_name`, `namenseinblender_macro_collection_uuid`.
- PATCH /settings (route `settings.update`) validates `key` via `Rule::in(self::AGENDA_KEYS)`, `value` nullable string max:500, persists via `Setting::set()`.
- `HandleInertiaRequests::share()` now globally exposes: `namenseinblenderMacro` => {name, uuid, collection_name (default '--MAIN--'), collection_uuid}, plus `currentKeyVisual`, `currentBackground`.
- NOTE: namenseinblenderMacro uses snake_case keys (name/uuid/collection_name/collection_uuid) — differs from existing `macroSettings` which uses camelCase (collectionName/collectionUuid). T10/T14 consumers must use snake_case for namenseinblender.
- Test file `tests/Feature/NamenseinblenderSettingTest.php` (Pest, 4 tests). Inertia prop assertions use `->where('namenseinblenderMacro.name', ...)` dot-path on shared props from any authed page (settings.index).
- 514 app tests green (510 baseline + 4 new). Pint clean.

View file

@ -21,6 +21,12 @@ class SettingsController extends Controller
'agenda_announcement_position',
'agenda_sermon_matching',
'default_translation_language',
'current_key_visual',
'current_background',
'namenseinblender_macro_name',
'namenseinblender_macro_uuid',
'namenseinblender_macro_collection_name',
'namenseinblender_macro_collection_uuid',
];
public function index(): Response

View file

@ -53,6 +53,14 @@ public function share(Request $request): array
'collectionName' => Setting::get('macro_collection_name', '--MAIN--'),
'collectionUuid' => Setting::get('macro_collection_uuid', '8D02FC57-83F8-4042-9B90-81C229728426'),
],
'namenseinblenderMacro' => [
'name' => Setting::get('namenseinblender_macro_name'),
'uuid' => Setting::get('namenseinblender_macro_uuid'),
'collection_name' => Setting::get('namenseinblender_macro_collection_name', '--MAIN--'),
'collection_uuid' => Setting::get('namenseinblender_macro_collection_uuid'),
],
'currentKeyVisual' => Setting::get('current_key_visual'),
'currentBackground' => Setting::get('current_background'),
];
}
}

View file

@ -0,0 +1,74 @@
<?php
use App\Models\Setting;
use App\Models\User;
beforeEach(function () {
$this->user = User::factory()->create();
});
test('patch namenseinblender macro name and uuid persists settings', function () {
$this->actingAs($this->user)
->patchJson(route('settings.update'), [
'key' => 'namenseinblender_macro_name',
'value' => 'Namenseinblender',
])->assertOk()->assertJson(['success' => true]);
$this->actingAs($this->user)
->patchJson(route('settings.update'), [
'key' => 'namenseinblender_macro_uuid',
'value' => 'ABC-123',
])->assertOk()->assertJson(['success' => true]);
expect(Setting::get('namenseinblender_macro_name'))->toBe('Namenseinblender');
expect(Setting::get('namenseinblender_macro_uuid'))->toBe('ABC-123');
});
test('namenseinblender macro shared prop reflects persisted values', function () {
Setting::set('namenseinblender_macro_name', 'Namenseinblender');
Setting::set('namenseinblender_macro_uuid', 'ABC-123');
$this->actingAs($this->user)
->withoutVite()
->get(route('settings.index'))
->assertInertia(
fn ($page) => $page
->where('namenseinblenderMacro.name', 'Namenseinblender')
->where('namenseinblenderMacro.uuid', 'ABC-123')
->where('namenseinblenderMacro.collection_name', '--MAIN--')
);
});
test('current_background setting persists and is shared as prop', function () {
$this->actingAs($this->user)
->patchJson(route('settings.update'), [
'key' => 'current_background',
'value' => 'slides/bg.jpg',
])->assertOk()->assertJson(['success' => true]);
expect(Setting::get('current_background'))->toBe('slides/bg.jpg');
$this->actingAs($this->user)
->withoutVite()
->get(route('settings.index'))
->assertInertia(
fn ($page) => $page->where('currentBackground', 'slides/bg.jpg')
);
});
test('current_key_visual setting persists and is shared as prop', function () {
$this->actingAs($this->user)
->patchJson(route('settings.update'), [
'key' => 'current_key_visual',
'value' => 'slides/key.jpg',
])->assertOk()->assertJson(['success' => true]);
expect(Setting::get('current_key_visual'))->toBe('slides/key.jpg');
$this->actingAs($this->user)
->withoutVite()
->get(route('settings.index'))
->assertInertia(
fn ($page) => $page->where('currentKeyVisual', 'slides/key.jpg')
);
});