feat(settings): SettingsController passes assignments, macros, labels, collections to Settings page
This commit is contained in:
parent
f494a8a0d7
commit
b88ae3e918
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Label;
|
||||||
|
use App\Models\Macro;
|
||||||
|
use App\Models\MacroAssignment;
|
||||||
|
use App\Models\MacroCollection;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -10,11 +14,7 @@
|
||||||
|
|
||||||
class SettingsController extends Controller
|
class SettingsController extends Controller
|
||||||
{
|
{
|
||||||
private const MACRO_KEYS = [
|
private const AGENDA_KEYS = [
|
||||||
'macro_name',
|
|
||||||
'macro_uuid',
|
|
||||||
'macro_collection_name',
|
|
||||||
'macro_collection_uuid',
|
|
||||||
'agenda_start_title',
|
'agenda_start_title',
|
||||||
'agenda_end_title',
|
'agenda_end_title',
|
||||||
'agenda_announcement_position',
|
'agenda_announcement_position',
|
||||||
|
|
@ -24,19 +24,31 @@ class SettingsController extends Controller
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
$settings = [];
|
$settings = [];
|
||||||
foreach (self::MACRO_KEYS as $key) {
|
foreach (self::AGENDA_KEYS as $key) {
|
||||||
$settings[$key] = Setting::get($key);
|
$settings[$key] = Setting::get($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Inertia::render('Settings', [
|
return Inertia::render('Settings', [
|
||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
|
'assignments' => MacroAssignment::with(['macro', 'label'])->orderBy('part_type')->orderBy('order')->get(),
|
||||||
|
'macros' => Macro::with('collections')->orderBy('name')->get(),
|
||||||
|
'labels' => Label::orderBy('name')->get(),
|
||||||
|
'collections' => MacroCollection::with('macros')->orderBy('name')->get(),
|
||||||
|
'last_macros_import' => [
|
||||||
|
'at' => Setting::get('macros_last_imported_at'),
|
||||||
|
'filename' => Setting::get('macros_last_imported_filename'),
|
||||||
|
],
|
||||||
|
'last_labels_import' => [
|
||||||
|
'at' => Setting::get('labels_last_imported_at'),
|
||||||
|
'filename' => Setting::get('labels_last_imported_filename'),
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request): JsonResponse
|
public function update(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'key' => ['required', 'string', 'in:'.implode(',', self::MACRO_KEYS)],
|
'key' => ['required', 'string', 'in:'.implode(',', self::AGENDA_KEYS)],
|
||||||
'value' => ['nullable', 'string', 'max:500'],
|
'value' => ['nullable', 'string', 'max:500'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue