Liefere das Anfrageformular je Anfragegrund aus und gib dem Widget Gründe, Formularführung und Präsentation
Das Widget Anfrage wählt statt eines Anfrage-Einstiegs mehrere Anfragegründe, jeder zeigt auf ein veröffentlichtes Formular
(optional mit vorgewähltem Anliegen). Der Besucher erhält genau das Formular seines Grundes: /anfrage/formular/{vorlage}
mit Grund in der Adresse, dasselbe Token, dieselbe Auswertung und Annahme. Ein Dialog (dialog-Element) und die Grundauswahl
als Karten oder Auswahlfeld kommen aus resources/js/inquiry-widget.js. Seiten mit einem Einstieg bleiben darstellbar.
Bereiche lassen sich wie Gruppen anzeigen oder ausblenden.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f255bf5200
commit
fb479c1b01
18 files changed
+1394
-57
No files matched your search
@@ -4,9 +4,11 @@
|
||||
|
||||
use App\Domain\Communication\FormEvaluator;
|
||||
use App\Domain\Communication\FormPayload;
|
||||
use App\Domain\Communication\FormReason;
|
||||
use App\Domain\Communication\FormToken;
|
||||
use App\Domain\Communication\InquiryEntry;
|
||||
use App\Domain\Communication\InquiryService;
|
||||
use App\Domain\Communication\InquiryTemplate;
|
||||
use App\Domain\Communication\SubmissionException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -68,6 +70,59 @@ public function submit(Request $request, InquiryEntry $entry): JsonResponse
|
||||
return $this->json(['reference' => $result['reference']], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget „Anfrage“ (ADR-61): das veröffentlichte Formular einer Vorlage für den gewählten Anfragegrund. Der Grund
|
||||
* (Anliegen, Unteranliegen, Formularführung) steht in der Adresse, damit Zustand und Absendung ohne weitere
|
||||
* Angaben dasselbe Formular meinen.
|
||||
*/
|
||||
public function formDefinition(Request $request, InquiryTemplate $template): JsonResponse
|
||||
{
|
||||
$delivered = $this->service->deliverForm($template, FormReason::clean($request->query()));
|
||||
|
||||
if ($delivered === null) {
|
||||
return $this->json(['message' => 'Dieses Anfrageformular ist zurzeit nicht verfügbar.'], 404);
|
||||
}
|
||||
|
||||
return $this->json([
|
||||
...FormPayload::definition($delivered['form'], $this->evaluator),
|
||||
'token' => FormToken::issue($template->id, $delivered['version']->id, 'form'),
|
||||
'csrf' => csrf_token(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function formState(Request $request, InquiryTemplate $template): JsonResponse
|
||||
{
|
||||
$delivered = $this->service->deliverForm($template, FormReason::clean($request->query()));
|
||||
|
||||
if ($delivered === null) {
|
||||
return $this->json(['message' => 'Dieses Anfrageformular ist zurzeit nicht verfügbar.'], 404);
|
||||
}
|
||||
|
||||
$values = $request->input('values');
|
||||
|
||||
if (! is_array($values) || strlen((string) json_encode($values)) > 40000) {
|
||||
return $this->json(['message' => 'Die Eingaben sind ungültig.'], 422);
|
||||
}
|
||||
|
||||
return $this->json(FormPayload::state($delivered['form'], $values, $this->evaluator));
|
||||
}
|
||||
|
||||
public function formSubmit(Request $request, InquiryTemplate $template): JsonResponse
|
||||
{
|
||||
try {
|
||||
$result = $this->service->submitForm($template, FormReason::clean($request->query()), [
|
||||
'token' => $request->input('token'),
|
||||
'values' => $request->input('values'),
|
||||
'website' => $request->input('website'),
|
||||
'source' => $request->input('source'),
|
||||
]);
|
||||
} catch (SubmissionException $e) {
|
||||
return $this->json(['message' => $e->getMessage(), 'fields' => (object) $e->fields], $e->getCode() ?: 422);
|
||||
}
|
||||
|
||||
return $this->json(['reference' => $result['reference']], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user