Add new part type 'abspann' (credits/Abspann presentation) to the macro assignment enum, validation and UI. - Relax part_type from enum to plain string on macro_assignments, service_macro_overrides and service_macro_assignments so 'abspann' (and any controller-validated value) is accepted across MySQL and SQLite. - Add 'abspann' to Rule::in validation in MacroAssignmentController and ServiceMacroOverrideController. - Include 'abspann' in the per-service macros_per_part list in ServiceController so the override UI exposes it. - Add 'abspann' to the parts array in Settings/MacroAssignments.vue (by_label stays song-only; abspann offers all/first/last slide).
95 lines
3.3 KiB
PHP
95 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\MacroAssignment;
|
|
use App\Models\Service;
|
|
use App\Models\ServiceMacroAssignment;
|
|
use App\Models\ServiceMacroOverride;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ServiceMacroOverrideController extends Controller
|
|
{
|
|
public function store(Request $request, Service $service): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'part_type' => ['required', 'in:information,moderation,sermon,song,agenda_item,abspann'],
|
|
]);
|
|
|
|
ServiceMacroOverride::firstOrCreate([
|
|
'service_id' => $service->id,
|
|
'part_type' => $validated['part_type'],
|
|
]);
|
|
|
|
$globals = MacroAssignment::where('part_type', $validated['part_type'])->orderBy('order')->get();
|
|
foreach ($globals as $global) {
|
|
ServiceMacroAssignment::firstOrCreate([
|
|
'service_id' => $service->id,
|
|
'part_type' => $validated['part_type'],
|
|
'macro_id' => $global->macro_id,
|
|
'position' => $global->position,
|
|
'label_id' => $global->label_id,
|
|
'order' => $global->order,
|
|
]);
|
|
}
|
|
|
|
return response()->json(['success' => true]);
|
|
}
|
|
|
|
public function destroy(Service $service, Request $request): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'part_type' => ['required', 'in:information,moderation,sermon,song,agenda_item,abspann'],
|
|
]);
|
|
|
|
ServiceMacroOverride::where('service_id', $service->id)
|
|
->where('part_type', $validated['part_type'])
|
|
->delete();
|
|
|
|
ServiceMacroAssignment::where('service_id', $service->id)
|
|
->where('part_type', $validated['part_type'])
|
|
->delete();
|
|
|
|
return response()->json(['success' => true]);
|
|
}
|
|
|
|
public function storeAssignment(Request $request, Service $service): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'part_type' => ['required', 'in:information,moderation,sermon,song,agenda_item,abspann'],
|
|
'macro_id' => ['required', 'integer', 'exists:macros,id'],
|
|
'position' => ['required', 'in:all_slides,first_slide,last_slide,by_label'],
|
|
'label_id' => ['nullable', 'integer', 'exists:labels,id'],
|
|
'order' => ['integer', 'min:0'],
|
|
]);
|
|
|
|
$assignment = ServiceMacroAssignment::create([
|
|
'service_id' => $service->id,
|
|
...$validated,
|
|
]);
|
|
|
|
return response()->json(['id' => $assignment->id, 'success' => true]);
|
|
}
|
|
|
|
public function updateAssignment(Request $request, Service $service, ServiceMacroAssignment $serviceMacroAssignment): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'position' => ['sometimes', 'in:all_slides,first_slide,last_slide,by_label'],
|
|
'label_id' => ['nullable', 'integer', 'exists:labels,id'],
|
|
'order' => ['sometimes', 'integer', 'min:0'],
|
|
]);
|
|
|
|
$serviceMacroAssignment->update($validated);
|
|
|
|
return response()->json(['success' => true]);
|
|
}
|
|
|
|
public function destroyAssignment(Service $service, ServiceMacroAssignment $serviceMacroAssignment): JsonResponse
|
|
{
|
|
$serviceMacroAssignment->delete();
|
|
|
|
return response()->json(['success' => true]);
|
|
}
|
|
}
|