diff --git a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php index 9cbd656cd..d148e82b7 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php @@ -17,6 +17,8 @@ use Chill\DocStoreBundle\Service\Signature\PDFPage; use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone; use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature; +use Chill\MainBundle\Entity\Workflow\EntityWorkflowSignatureStateEnum; +use Chill\MainBundle\Workflow\EntityWorkflowManager; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Messenger\MessageBusInterface; @@ -27,26 +29,20 @@ class SignatureRequestController public function __construct( private MessageBusInterface $messageBus, private StoredObjectManagerInterface $storedObjectManager, + private EntityWorkflowManager $entityWorkflowManager, ) {} #[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')] - //public function processSignature(EntityWorkflowStepSignature $signature): Response // using ParamConverter public function processSignature(EntityWorkflowStepSignature $signature, Request $request): JsonResponse { dump($signature); // $signature = $this->signatureRepository($signature); //not useful? // $entityWorkflow = $signature->getStep()->getEntityWorkflow(); // $storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($entityWorkflow); + $content = 'blop';// $this->storedObjectManager->read($storedObject); - dump($request); - // TODO parse payload: json_decode ou, mieux, dataTransfertObject - // dump($request); - $data = \json_decode((string) $request->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = \json_decode((string) $request->getContent(), true, 512, JSON_THROW_ON_ERROR); // TODO parse payload: json_decode ou, mieux, dataTransfertObject dump($data); - $signatureId = 1; - $storedObjectId = 9; //$data['storedObject']['id']; - $content = 'blop';// $this->storedObjectManager->read($storedObjectId); - $zone = new PDFSignatureZone( $data['zone']['index'], $data['zone']['x'], @@ -57,7 +53,7 @@ class SignatureRequestController ); $this->messageBus->dispatch(new RequestPdfSignMessage( - $signatureId, + $signature->getId(), $zone, $data['zone']['index'], 'test signature', //reason (string) @@ -67,4 +63,10 @@ class SignatureRequestController return new JsonResponse(null, JsonResponse::HTTP_OK, []); } + + #[Route('/api/1.0/document/workflow/{id}/check-signature', name: 'chill_docstore_check_signature')] + public function checkSignature(EntityWorkflowStepSignature $signature): JsonResponse + { + return new JsonResponse($signature->getState(), JsonResponse::HTTP_OK, []); + } } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts b/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts index 63d85a3df..1fc8b1cdd 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts @@ -80,4 +80,6 @@ export interface Signature { id: number, storedObject: StoredObject, zones: SignatureZone[], -} \ No newline at end of file +} + +export type SignedState = 'pending' | 'signed' | 'rejected' | 'canceled' | 'error'; \ No newline at end of file diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/DocumentSignature/App.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/DocumentSignature/App.vue index ee2daf498..268e75636 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/DocumentSignature/App.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/DocumentSignature/App.vue @@ -32,7 +32,11 @@ v-if="signature.zones.length > 1" >
-
@@ -71,7 +75,7 @@ -
+