From 77da2c1ac6a92b0a4ca536633ed8e6fa89df783a Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 11 Jul 2024 08:06:18 +0200 Subject: [PATCH] signature: add index on PDFSignatureZone + init POST signature --- .../Controller/SignatureRequestController.php | 42 +++++++++++++++---- .../Resources/public/types.ts | 3 +- .../public/vuejs/DocumentSignature/App.vue | 24 ++++++++--- .../Service/Signature/PDFSignatureZone.php | 5 ++- .../Signature/PDFSignatureZoneParser.php | 4 +- .../RequestPdfSignMessageSerializerTest.php | 6 +-- .../Signature/PDFSignatureZoneParserTest.php | 2 + 7 files changed, 66 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php index d76e9e5db..9cbd656cd 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php @@ -16,7 +16,9 @@ use Chill\DocStoreBundle\Service\Signature\Driver\BaseSigner\RequestPdfSignMessa use Chill\DocStoreBundle\Service\Signature\PDFPage; use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone; use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; -use Symfony\Component\HttpFoundation\Response; +use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature; +use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Routing\Annotation\Route; @@ -28,19 +30,41 @@ class SignatureRequestController ) {} #[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')] - public function processSignature(StoredObject $storedObject): Response + //public function processSignature(EntityWorkflowStepSignature $signature): Response // using ParamConverter + public function processSignature(EntityWorkflowStepSignature $signature, Request $request): JsonResponse { - $content = $this->storedObjectManager->read($storedObject); + dump($signature); + // $signature = $this->signatureRepository($signature); //not useful? + // $entityWorkflow = $signature->getStep()->getEntityWorkflow(); + // $storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($entityWorkflow); + + dump($request); + // TODO parse payload: json_decode ou, mieux, dataTransfertObject + // dump($request); + $data = \json_decode((string) $request->getContent(), true, 512, JSON_THROW_ON_ERROR); + dump($data); + $signatureId = 1; + $storedObjectId = 9; //$data['storedObject']['id']; + $content = 'blop';// $this->storedObjectManager->read($storedObjectId); + + $zone = new PDFSignatureZone( + $data['zone']['index'], + $data['zone']['x'], + $data['zone']['y'], + $data['zone']['height'], + $data['zone']['width'], + $page = new PDFPage($data['zone']['PDFPage']['index'], $data['zone']['PDFPage']['width'], $data['zone']['PDFPage']['height']) + ); $this->messageBus->dispatch(new RequestPdfSignMessage( - 0, - new PDFSignatureZone(10.0, 10.0, 180.0, 180.0, new PDFPage(0, 500.0, 800.0)), - 0, - 'test signature', - 'Mme Caroline Diallo', + $signatureId, + $zone, + $data['zone']['index'], + 'test signature', //reason (string) + 'Mme Caroline Diallo', //signerText (string) $content )); - return new Response('test

ok

'); + return new JsonResponse(null, JsonResponse::HTTP_OK, []); } } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts b/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts index 8fad4d9c8..63d85a3df 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts @@ -68,11 +68,12 @@ export interface PDFPage { height: number, } export interface SignatureZone { - PDFPage: PDFPage, + index: number, x: number, y: number, width: number, height: number, + PDFPage: PDFPage, } export interface Signature { diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/DocumentSignature/App.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/DocumentSignature/App.vue index 35e842243..ee2daf498 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/DocumentSignature/App.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/DocumentSignature/App.vue @@ -110,6 +110,7 @@