Added ticket deletion; fixed some small issues with the ticket list on the home page
This commit is contained in:
parent
5683c0bc8b
commit
f3ac8a6965
@ -11,7 +11,7 @@ use BitGoblin\Goliath\Models\Ticket;
|
|||||||
class TicketController extends Controller {
|
class TicketController extends Controller {
|
||||||
|
|
||||||
public function getView(Request $request, Response $response, array $args): Response {
|
public function getView(Request $request, Response $response, array $args): Response {
|
||||||
$ticket = Ticket::where('id', $args['ticket_id'])->get()[0];
|
$ticket = Ticket::where('id', $args['ticket_id'])->first();
|
||||||
|
|
||||||
$view = Twig::fromRequest($request);
|
$view = Twig::fromRequest($request);
|
||||||
return $view->render($response, 'ticket/view.twig', [
|
return $view->render($response, 'ticket/view.twig', [
|
||||||
@ -69,4 +69,14 @@ class TicketController extends Controller {
|
|||||||
->withStatus(302);
|
->withStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDelete(Request $request, Response $response, array $args): Response {
|
||||||
|
$ticket = Ticket::where('id', $args['ticket_id'])->first();
|
||||||
|
|
||||||
|
$ticket->delete();
|
||||||
|
|
||||||
|
return $response
|
||||||
|
->withHeader('Location', '/')
|
||||||
|
->withStatus(302);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ $app->post('/ticket/create', '\\BitGoblin\\Goliath\\Controllers\\TicketControlle
|
|||||||
$app->get('/ticket/{ticket_id}/edit', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getEdit')->setName('ticket.edit');
|
$app->get('/ticket/{ticket_id}/edit', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getEdit')->setName('ticket.edit');
|
||||||
$app->post('/ticket/{ticket_id}/edit', '\\BitGoblin\\Goliath\\Controllers\\TicketController:postEdit')->setName('ticket.edit');
|
$app->post('/ticket/{ticket_id}/edit', '\\BitGoblin\\Goliath\\Controllers\\TicketController:postEdit')->setName('ticket.edit');
|
||||||
|
|
||||||
|
// ticket deletion route
|
||||||
|
$app->get('/ticket/{ticket_id}/delete', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getDelete')->setName('ticket.delete');
|
||||||
|
|
||||||
// /ticket/id route - displays ticket info to user
|
// /ticket/id route - displays ticket info to user
|
||||||
$app->get('/ticket/{ticket_id}', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getView')->setName('ticket.view');
|
$app->get('/ticket/{ticket_id}', '\\BitGoblin\\Goliath\\Controllers\\TicketController:getView')->setName('ticket.view');
|
||||||
|
|
||||||
|
@ -20,12 +20,15 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for ticket in tickets %}
|
{% for ticket in tickets %}
|
||||||
|
<tr>
|
||||||
<td><a href="{{ url_for('ticket.view', {ticket_id: ticket.id}) }}">{{ ticket.title }}</a></td>
|
<td><a href="{{ url_for('ticket.view', {ticket_id: ticket.id}) }}">{{ ticket.title }}</a></td>
|
||||||
<td>{{ ticket.severity }}</td>
|
<td>{{ ticket.severity }}</td>
|
||||||
<td>{{ ticket.due_at }}</td>
|
<td>{{ ticket.due_at ? ticket.due_at : 'N/a' }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('ticket.edit', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-pen-to-square"></i></a>
|
<a href="{{ url_for('ticket.edit', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-pen-to-square"></i></a>
|
||||||
|
<a href="{{ url_for('ticket.delete', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-trash"></i></a>
|
||||||
</td>
|
</td>
|
||||||
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends 'layout.twig' %}
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
{% block title %}Create new ticket{% endblock %}
|
{% block title %}Editing ticket{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends 'layout.twig' %}
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
{% block title %}Home{% endblock %}
|
{% block title %}{{ ticket.title }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<ul class="ticket-status">
|
<ul class="ticket-status">
|
||||||
<li class="ticket-actions">
|
<li class="ticket-actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{{ url_for('ticket.edit', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-pen-to-square"></i>Edit</a></li><li><a href="{{ url_for('ticket.edit', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-trash"></i>Delete</a></li>
|
<li><a href="{{ url_for('ticket.edit', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-pen-to-square"></i>Edit</a></li><li><a href="{{ url_for('ticket.delete', {ticket_id: ticket.id}) }}"><i class="fa-solid fa-trash"></i>Delete</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
Loading…
Reference in New Issue
Block a user