diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig index 5fcc60ed4..9149e9a94 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig @@ -42,7 +42,7 @@
{%- if step.transitionBy is not null -%} - {{ step.transitionBy|chill_entity_render_box({'at_date': step.transitionAt}) }} + {{ step.transitionBy|chill_entity_render_box({'at_date': step.transitionAt}) }} {% else %} {{ 'workflow.Automated transition'|trans }} {%- endif -%} @@ -105,7 +105,7 @@

{{ 'workflow.Users put in Cc'|trans }} :

{% endif %} @@ -123,7 +123,7 @@

{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :

{% endif %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/macro_breadcrumb.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/macro_breadcrumb.html.twig index 61189100c..6a1c66ae7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/macro_breadcrumb.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/macro_breadcrumb.html.twig @@ -9,11 +9,13 @@ {{ 'Le'|trans ~ ' : ' }} {{ step.previous.transitionAt|format_datetime('short', 'short') }} - {% if step.destUser|length > 0 %} + {% if step.destUser|length > 0 or step.destUserGroups|length > 0 %}
  • {{ 'workflow.For'|trans ~ ' : ' }} - {% for d in step.destUser %}{{ d|chill_entity_render_string({'at_date': step.previous.transitionAt}) }}{% if not loop.last %}, {% endif %}{% endfor %} + {% for d in step.destUser %}{{ d|chill_entity_render_string({'at_date': step.previous.transitionAt}) }}{% if not loop.last %}, {% endif -%}{% endfor -%} + {%- if step.destUser|length > 0 and step.destUserGroups|length > 0 %}, {% endif -%} + {%- for d in step.destUserGroups %}{{ d|chill_entity_render_box }}{% if not loop.last %}, {% endif %}{% endfor -%}
  • {% endif %} diff --git a/src/Bundle/ChillMainBundle/Tests/Workflow/SignatureStepStateChangerTest.php b/src/Bundle/ChillMainBundle/Tests/Workflow/SignatureStepStateChangerTest.php index fa3cd5c2d..8a239c441 100644 --- a/src/Bundle/ChillMainBundle/Tests/Workflow/SignatureStepStateChangerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Workflow/SignatureStepStateChangerTest.php @@ -37,7 +37,7 @@ use Symfony\Component\Workflow\WorkflowInterface; */ class SignatureStepStateChangerTest extends TestCase { - public function testMarkSignatureAsSignedScenarioWhichExpectsTransition() + public function testMarkSignatureAsSignedScenarioWhichExpectsTransitionSignatureWithPerson() { $entityWorkflow = new EntityWorkflow(); $entityWorkflow->setWorkflowName('dummy'); @@ -84,6 +84,40 @@ class SignatureStepStateChangerTest extends TestCase self::assertNotNull($signatures[1]->getStateDate()); } + public function testMarkSignatureAsSignedScenarioWhichExpectsTransitionSignatureWithUser() + { + $entityWorkflow = new EntityWorkflow(); + $entityWorkflow->setWorkflowName('dummy'); + $registry = $this->buildRegistry(); + $workflow = $registry->get($entityWorkflow, 'dummy'); + $clock = new MockClock(); + $user = new User(); + + $messengerBus = new MessageBus([]); + $changer = new SignatureStepStateChanger($registry, $clock, new NullLogger(), $messengerBus); + + // move it to signature + $dto = new WorkflowTransitionContextDTO($entityWorkflow); + $dto->futureUserSignature = $signer = new User(); + $workflow->apply($entityWorkflow, 'to_signature', ['context' => $dto, 'transitionAt' => $clock->now(), + 'byUser' => $user, 'transition' => 'to_signature']); + + // get the signature created + $signatures = $entityWorkflow->getCurrentStep()->getSignatures(); + + // we mark the first signature as signed + $changer->markSignatureAsSigned($signatures[0], 1); + // the next step should be done by handling an async message + $changer->onPostMark($signatures[0]); + + self::assertEquals(EntityWorkflowSignatureStateEnum::SIGNED, $signatures[0]->getState()); + self::assertEquals('post-signature', $entityWorkflow->getStep(), 'the entity workflow step should be post-signature'); + self::assertContains($signer, $entityWorkflow->getCurrentStep()->getAllDestUser()); + self::assertCount(1, $entityWorkflow->getCurrentStep()->getAllDestUser()); + self::assertEquals(1, $signatures[0]->getZoneSignatureIndex()); + self::assertNotNull($signatures[0]->getStateDate()); + } + public function testMarkSignatureAsSignedScenarioWithoutRequiredMetadata() { $entityWorkflow = new EntityWorkflow(); diff --git a/src/Bundle/ChillMainBundle/Workflow/SignatureStepStateChanger.php b/src/Bundle/ChillMainBundle/Workflow/SignatureStepStateChanger.php index 58a6485c2..cccfa2ab7 100644 --- a/src/Bundle/ChillMainBundle/Workflow/SignatureStepStateChanger.php +++ b/src/Bundle/ChillMainBundle/Workflow/SignatureStepStateChanger.php @@ -97,16 +97,20 @@ class SignatureStepStateChanger return; } - $previousUser = $this->getPreviousSender($signature->getStep()); + if ('person' === $signature->getSignerKind()) { + $futureUser = $this->getPreviousSender($signature->getStep()); + } else { + $futureUser = $signature->getSigner(); + } - if (null === $previousUser) { + if (null === $futureUser) { $this->logger->info(self::LOG_PREFIX.'No previous user, will not apply a transition', ['signatureId' => $signature->getId()]); return; } $transitionDto = new WorkflowTransitionContextDTO($entityWorkflow); - $transitionDto->futureDestUsers[] = $previousUser; + $transitionDto->futureDestUsers[] = $futureUser; $workflow->apply($entityWorkflow, $transition, [ 'context' => $transitionDto,