Implement market occurrence drawer

This commit is contained in:
gitea_admin committed 2026-09-19 11:40:44 +02:00
1 parent 7178c4af53
commit 49fd392f79
3 files changed
+169 -3

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../modules/shared/db.php';
require_once __DIR__ . '/../../modules/shared/auth/service.php';
require_once __DIR__ . '/../../modules/market_management/service.php';
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store');
$env = expand_env_values(parse_env_file(__DIR__ . '/../../.env'));
$pdo = connect_database($env);
auth_bootstrap_session();
if (auth_current_user($pdo) === null) {
http_response_code(401);
echo json_encode(['ok' => false, 'error' => 'Unauthorized']);
exit;
}
$requestMethod = strtoupper((string) ($_SERVER['REQUEST_METHOD'] ?? 'GET'));
if ($requestMethod === 'POST') {
$csrf = (string) ($_SERVER['HTTP_X_CSRF_TOKEN'] ?? '');
if (!auth_validate_csrf_token($csrf)) {
http_response_code(419);
echo json_encode(['ok' => false, 'error' => 'Ungültiges Sicherheits-Token']);
exit;
}
$payload = json_decode((string) file_get_contents('php://input'), true);
if (!is_array($payload)) {
http_response_code(400);
echo json_encode(['ok' => false, 'error' => 'Ungültige Anfrage']);
exit;
}
$scope = (string) ($payload['scope'] ?? '');
$id = market_management_require_positive_id($payload['id'] ?? null, 'id');
$fields = is_array($payload['fields'] ?? null) ? $payload['fields'] : [];
if ($scope === 'occurrence') {
market_management_update_occurrence($pdo, $id, $fields);
} elseif ($scope === 'day') {
market_management_update_day($pdo, $id, $fields);
} else {
throw new InvalidArgumentException('Ungültiger Bearbeitungsbereich.');
}
echo json_encode(['ok' => true]);
exit;
}
$occurrenceId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if (!is_int($occurrenceId) || $occurrenceId <= 0) {
http_response_code(400);
echo json_encode(['ok' => false, 'error' => 'Invalid occurrence id']);
exit;
}
$occurrence = market_management_get_occurrence($pdo, $occurrenceId);
if ($occurrence === null) {
http_response_code(404);
echo json_encode(['ok' => false, 'error' => 'Occurrence not found']);
exit;
}
$market = market_management_get_market($pdo, (int) $occurrence['market_definition_id']);
if ($market === null) {
http_response_code(404);
echo json_encode(['ok' => false, 'error' => 'Market not found']);
exit;
}
echo json_encode(['ok' => true, 'market' => $market, 'occurrence' => $occurrence], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
+67
View File
@@ -39,6 +39,73 @@ body.sg-card-list-page-drawer-open {
overflow: hidden;
}
.sg-market-mobile-detail-host {
position: fixed;
inset: 0;
z-index: 1500;
display: flex;
flex-direction: column;
gap: var(--spacing-large);
padding: var(--spacing-small);
box-sizing: border-box;
overflow: auto;
background: var(--color-background-purple);
}
.sg-market-mobile-detail-host .sg-card-list-page-drawer {
position: static;
display: flex;
width: 100%;
max-width: none;
transform: none;
box-shadow: none;
overflow: visible;
}
body.sg-market-mobile-detail-open > :not([data-market-mobile-detail-host]) {
display: none !important;
}
.market-detail-grid {
display: grid;
grid-template-columns: minmax(10rem, 0.8fr) minmax(0, 1.2fr);
margin: 0;
}
.market-detail-row {
display: contents;
}
.market-detail-row dt,
.market-detail-row dd {
margin: 0;
padding: var(--spacing-small) 0;
border-bottom: 1px solid var(--color-light-grey);
}
.market-detail-row dt {
color: var(--color-medium-grey);
}
.market-detail-row dd {
overflow-wrap: anywhere;
}
.market-day-specific {
color: var(--color-medium-grey);
}
.market-edit-form .sg-component-row {
margin-top: var(--spacing-medium);
align-items: center;
}
@media (max-width: 767px) {
.market-detail-grid {
grid-template-columns: minmax(8rem, 0.9fr) minmax(0, 1.1fr);
}
}
.sg-card-list-page-drawer-backdrop {
position: fixed;
inset: 0;