Skip to content

Commit

Permalink
imp: Allow to choose the type when opening a ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
marien-probesys committed Mar 1, 2023
1 parent df34ad0 commit 8bc053f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/Controller/Organizations/TicketsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function new(
'organization' => $organization,
'title' => '',
'message' => '',
'type' => Ticket::DEFAULT_TYPE,
'requesterId' => '',
'assigneeId' => '',
'status' => 'new',
Expand Down Expand Up @@ -111,14 +112,17 @@ public function create(
$messageContent = $request->request->get('message', '');
$messageContent = $appMessageSanitizer->sanitize($messageContent);

/** @var string $type */
$type = $request->request->get('type', Ticket::DEFAULT_TYPE);

/** @var int $requesterId */
$requesterId = $request->request->getInt('requesterId', 0);

/** @var int $assigneeId */
$assigneeId = $request->request->getInt('assigneeId', 0);

/** @var string $status */
$status = $request->request->get('status', 'new');
$status = $request->request->get('status', Ticket::DEFAULT_STATUS);

/** @var string $csrfToken */
$csrfToken = $request->request->get('_csrf_token', '');
Expand All @@ -130,6 +134,7 @@ public function create(
'organization' => $organization,
'title' => $title,
'message' => $messageContent,
'type' => $type,
'requesterId' => $requesterId,
'assigneeId' => $assigneeId,
'status' => $status,
Expand All @@ -145,6 +150,7 @@ public function create(
'organization' => $organization,
'title' => $title,
'message' => $messageContent,
'type' => $type,
'requesterId' => $requesterId,
'assigneeId' => $assigneeId,
'status' => $status,
Expand All @@ -163,6 +169,7 @@ public function create(
'organization' => $organization,
'title' => $title,
'message' => $messageContent,
'type' => $type,
'requesterId' => $requesterId,
'assigneeId' => $assigneeId,
'status' => $status,
Expand All @@ -179,6 +186,7 @@ public function create(

$ticket = new Ticket();
$ticket->setTitle($title);
$ticket->setType($type);
$ticket->setStatus($status);
$ticket->setOrganization($organization);

Expand All @@ -193,6 +201,7 @@ public function create(
'organization' => $organization,
'title' => $title,
'message' => $messageContent,
'type' => $type,
'requesterId' => $requesterId,
'assigneeId' => $assigneeId,
'status' => $status,
Expand All @@ -214,6 +223,7 @@ public function create(
'organization' => $organization,
'title' => $title,
'message' => $messageContent,
'type' => $type,
'requesterId' => $requesterId,
'assigneeId' => $assigneeId,
'status' => $status,
Expand Down
36 changes: 36 additions & 0 deletions templates/organizations/tickets/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,42 @@
{{ include('alerts/_error.html.twig', { message: error | trans }, with_context = false) }}
{% endif %}

<div>
<label class="sr-only">
{{ 'tickets.type' | trans }}
</label>

<div class="row row--always">
<div>
<input
type="radio"
id="type-request"
name="type"
value="request"
{{ type == 'request' ? 'checked' }}
/>

<label for="type-request">
{{ 'tickets.request' | trans }}
</label>
</div>

<div>
<input
type="radio"
id="type-incident"
name="type"
value="incident"
{{ type == 'incident' ? 'checked' }}
/>

<label for="type-incident">
{{ 'tickets.incident' | trans }}
</label>
</div>
</div>
</div>

<div class="flow-small">
<label for="title">
{{ 'tickets.title' | trans }}
Expand Down
3 changes: 2 additions & 1 deletion tests/Controller/Organizations/TicketsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public function testPostCreateCreatesATicketAndRedirects(): void
'title' => $title,
'requesterId' => $requester->getId(),
'assigneeId' => $assignee->getId(),
'type' => 'incident',
'status' => 'planned',
'message' => $messageContent,
]);
Expand All @@ -205,7 +206,7 @@ public function testPostCreateCreatesATicketAndRedirects(): void
$this->assertSame(20, strlen($ticket->getUid()));
$this->assertEquals($now, $ticket->getCreatedAt());
$this->assertSame($user->getId(), $ticket->getCreatedBy()->getId());
$this->assertSame('request', $ticket->getType());
$this->assertSame('incident', $ticket->getType());
$this->assertSame('planned', $ticket->getStatus());
$this->assertSame('medium', $ticket->getUrgency());
$this->assertSame('medium', $ticket->getImpact());
Expand Down

0 comments on commit 8bc053f

Please sign in to comment.