Skip to content

Commit

Permalink
imp: Allow to select observers during ticket creation
Browse files Browse the repository at this point in the history
  • Loading branch information
marien-probesys committed Dec 11, 2024
1 parent 936c7bc commit 4562501
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/Form/TicketForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'data-form-ticket-actors-target' => 'assignees',
],
]);

$form->add('observers', AppType\ActorType::class, [
'organization' => $organization,
'multiple' => true,
'by_reference' => false,
'required' => false,
'label' => new TranslatableMessage('tickets.observers'),
'block_prefix' => 'multiselect_actors',
]);
}

if ($this->authorizer->isGranted('orga:update:tickets:priority', $organization)) {
Expand Down
2 changes: 2 additions & 0 deletions templates/organizations/tickets/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
{% endif %}

{{ form_row(form.assignee) }}

{{ form_row(form.observers) }}
</div>
</details>
{% endif %}
Expand Down
10 changes: 9 additions & 1 deletion tests/Controller/Organizations/TicketsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public function testPostNewCreatesATicketAndRedirects(): void
list(
$user,
$requester,
) = Factory\UserFactory::createMany(2);
$observer,
) = Factory\UserFactory::createMany(3);
$client->loginUser($user->_real());
$organization = Factory\OrganizationFactory::createOne();
$this->grantOrga($user->_real(), [
Expand All @@ -233,6 +234,9 @@ public function testPostNewCreatesATicketAndRedirects(): void
$this->grantOrga($requester->_real(), [
'orga:create:tickets',
], $organization->_real());
$this->grantOrga($observer->_real(), [
'orga:see',
], $organization->_real());
$title = 'My ticket';
$messageContent = 'My message';

Expand All @@ -245,6 +249,7 @@ public function testPostNewCreatesATicketAndRedirects(): void
'title' => $title,
'content' => $messageContent,
'requester' => $requester->getId(),
'observers' => [$observer->getId()],
'type' => 'incident',
'urgency' => 'high',
'impact' => 'high',
Expand All @@ -270,6 +275,9 @@ public function testPostNewCreatesATicketAndRedirects(): void
$this->assertNull($ticket->getSolution());
$this->assertSame($requester->getId(), $ticket->getRequester()->getId());
$this->assertNull($ticket->getAssignee());
$observers = $ticket->getObservers();
$this->assertSame(1, count($observers));
$this->assertSame($observer->getId(), $observers[0]->getId());
$this->assertSame($organization->getId(), $ticket->getOrganization()->getId());
$message = Factory\MessageFactory::last();
$this->assertSame($messageContent, $message->getContent());
Expand Down

0 comments on commit 4562501

Please sign in to comment.