Align market cards with shared edit pattern
This commit is contained in:
1 parent
f2467f4411
commit
906c76a959
4 files changed
+67
-4
No files matched your search
@@ -36,10 +36,27 @@ if ($requestMethod === 'POST') {
|
||||
$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') {
|
||||
if ($scope === 'day') {
|
||||
market_management_update_day($pdo, $id, $fields);
|
||||
} elseif (in_array($scope, ['occurrence', 'status', 'overview', 'participation', 'infrastructure', 'travel', 'notes'], true)) {
|
||||
$organizerFields = [];
|
||||
foreach (['organization_contact_id', 'contact_person_id'] as $organizerField) {
|
||||
if (array_key_exists($organizerField, $fields)) {
|
||||
$organizerFields[$organizerField] = $fields[$organizerField];
|
||||
unset($fields[$organizerField]);
|
||||
}
|
||||
}
|
||||
if ($organizerFields !== []) {
|
||||
$existingOccurrence = market_management_get_occurrence($pdo, $id, true);
|
||||
$existingOrganizer = $existingOccurrence['organizer'] ?? null;
|
||||
$organizerFields['occurrence_id'] = $id;
|
||||
$organizerFields['organization_contact_id'] ??= $existingOrganizer['organization_contact_id'] ?? null;
|
||||
$organizerFields['contact_person_id'] ??= $existingOrganizer['contact_person_id'] ?? null;
|
||||
market_management_set_organizer($pdo, $organizerFields);
|
||||
}
|
||||
if ($fields !== []) {
|
||||
market_management_update_occurrence($pdo, $id, $fields);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidArgumentException('Ungültiger Bearbeitungsbereich.');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user